Created
March 27, 2018 20:49
-
-
Save rajcspsg/64a1b9e97da8509b4eaa5daf8c86bc00 to your computer and use it in GitHub Desktop.
The Node.js Event Loop: Not So Single Threaded
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.youtube.com/watch?v=zphcsoSJMvM | |
1. single threaded process | |
2. co-operative multi tasking | |
Application running on the operating system should yield the OS. | |
Once the application has yielded then the OS run the other tasks. | |
This has a big flaw if the application doesn't yield, then the OS will wait for long time. | |
3. pre-emptive multi tasking | |
OS has the ability to pause the application and execute its commands. | |
Which means that OS reloads the other application and runs it without knowing anything about the application. | |
This means that OS is saving the current State of running application and reloads other application. This causes the applications are interleaved for processing. | |
This means that if the application crashes OS won't crash. | |
4. Symmetric Multi Threading | |
Instructions in OS are executed in stages which are break into down into steps. | |
Steps in the processor is called pipeline. | |
Task is same thing as process | |
Process Vs Threads | |
Process Threads | |
-------------------------------------------------------------- | |
Top level execution container Runs inside process | |
Separate Memory Space Shared Memory Space | |
Communicate via IPC Pleathora of options available that depends on runtime | |
Node consists of JS, V8, chrome V8 and C++. | |
When node code calls synchronous method it C++ runs in main thread. | |
When node code calls asynchronous method it C++ may run in main or other thread. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment