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 @@ @@ -38,7 +39,8 @@

#META_LECTURE#: #TITLE#

• -

+ +

@@ -100,7 +102,7 @@

Recall: Application Server

Programming Models

- + - + - +

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
                1. calling bar: a frame is created with bar's arguments and variables.
                2. bar calls foo: a new frame with foo's args and vars is created.
                3. @@ -249,12 +253,12 @@

                  Stack

                  Event Loop

                  -
                    +
                    • 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