From 66f08166725cc7c76ae9fa4cb115c3e7d4918aa7 Mon Sep 17 00:00:00 2001
From: Tomas Vitvar
Date: Mon, 26 Feb 2024 09:51:23 +0100
Subject: [PATCH] webarch updated
---
lecture1.html | 64 +++++++++++++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 28 deletions(-)
diff --git a/lecture1.html b/lecture1.html
index 7cbcb63..0ba6142 100644
--- a/lecture1.html
+++ b/lecture1.html
@@ -26,7 +26,8 @@
‒ #SLIDE_NO# ‒
@@ -38,7 +39,8 @@ #META_LECTURE#: #TITLE#
@@ -100,7 +102,7 @@ Recall: Application Server
Programming Models
-
+
- Concurrency
@@ -124,14 +126,14 @@ Programming Models
- Threads can access shared memory; you need to controll this
-
+
-
+
Asynchronous I/O
-
+
- Asynchronous I/O
@@ -143,16 +145,16 @@ Asynchronous I/O
- Tasks are running in so called event loop
- A task is able to "pause" when they wait for some result
-
+
- A task let other tasks to run
- Asynchronous code faciliates concurrent execution
- It gives the "look and feel" of concurrent execution
-
-
-
+
+
+
@@ -164,7 +166,8 @@ Asynchronous I/O
Web 2.0 Application Architecture
-
+
@@ -176,7 +179,7 @@
JavaScript
Client-side (browser) and server-side (node.js, AppsScript)
Standard
- - Current stable release is ECMAScript 2020
+ - Current stable release is ECMAScript 2021/June 2021
Major characteristics
@@ -200,8 +203,9 @@ JavaScript
Javascript Runtime
-
-
+
+
- Stack
- Contains frames, i.e. function parameters and local variables
@@ -222,7 +226,7 @@ Javascript Runtime
Stack
-
+
- When running a program...
function foo(b) {
@@ -235,7 +239,7 @@ Stack
return foo(x * y)
}
- console.log(bar(7)) //returns 42
+ console.log(bar(7)) //returns 42
- calling
bar
: a frame is created with bar's arguments and variables.
bar
calls foo
: a new frame with foo's args and vars is created.
@@ -249,12 +253,12 @@ Stack
Event Loop
-
while (queue.waitForMessage()) {
queue.processNextMessage()
- }
+ }
- Message = data + callback to be processed
- Messages are process completely one by one
@@ -262,7 +266,7 @@ Event Loop
- No "clashes" across messages' processing
- Processing should not block for a long time – Workers
- - Brwoser adds a new message when an event occurs and there is an event listener
+ - Brwoser adds a new message when an event occurs and there is an event listener
- Run-to-completion
@@ -280,19 +284,20 @@ Event Loop
Handling Request
-
+
Multiple Runtimes
-
+
- Runtime
-
- - Stack, Heap, Message Queue
- iframe
and a Web worker has its own runtimes
-
+
+ - Stack, Heap, Message Queue
+ iframe
and a Web worker has its own runtimes
+
- Communication between runtimes
- Runtimes communicate via
postMessage
@@ -336,7 +341,7 @@ Web Workers
}
// ... and terminate
- myWorker.terminate()
+ myWorker.terminate()
@@ -357,7 +362,8 @@ Node.js
You do not need to deal with concurrency issues
More threads to realize I/O
- Open sourced, @GitHub, many libraries
+ Open sourced, @GitHub, many libraries
Future platform for Web 2.0 apps
Every I/O as an event
@@ -403,7 +409,9 @@ Node.js Event Loop
- Six phases, each phase has a FIFO queue of callbacks to execute.
- - timers – executes callbacks sheduled by
setTimeout()
and setInterval()
+ - timers – executes callbacks sheduled by
setTimeout()
and
+ setInterval()
+
- I/O callbacks – executes all I/O callbacks except close callbacks.
- idle/prepare – used internally
- poll – retrieve new I/O events