1/8/2024 0 Comments Settimeout nodejs![]() JavaScript is an asynchronous single-threaded language-it is one call stack and it can only do one thing at a time. To follow along with this post, you need to have: This post will cover the event loop in Node.js, how it works, its function, async and sync programming, and how to use the event loop effectively. If a processor has multiple threads of control, it can perform more than one task at a time. Resources, such as open files and signals.Ī traditional/heavyweight process has a single thread of control. It also shares with other threads belonging to the same process its code section, data section and other operating system Each program may have several processes in it, and each process has several threads executing in it.Ī thread is a basic unit of execution or CPU utilization it comprises a thread ID, a program counter, a register set and a stack. The process can be defined as the program under execution, while a thread is a basic execution unit. Hence, we execute instructions in stages. With SMT the OS can take advantage of new assembly-level instructions in the processor itself. Questions like “How can multiple-core processors be utilized for maximum performance?” led to a lot of research thatīrought about symmetric multi-threading (SMT). So many people kept researching how to improve performance, especially when there were multi-core processors released in the early 2000s. It helps the operating system work without depending on the applications, thereby gaining more stability and efficiency. It will pause the application, save the state somewhere elseĪnd load another application. That led to the introduction of preemptive multitasking, where there is no reliance on the application anymore-instead, the OS can pause any application at a given time. ![]() ![]() Still, the issue here is that it depends on the user’s application calling the yield function, i.e., if the yield function is notĬooperative multitasking was an improvement-we could run multiple things, but we still had some problems with it, and stability was the primary problem. Signals back to the OS that the application has completed in order for other applications to continue execution. This is primarily via a function written into the application called yield, which The way that cooperative multitasking works is you have an application that is running, and then it gets to a stage where it takes a break so that other things can run. In order to solve this problem, cooperative multitasking was introduced, which makes things much more efficient. Program, it automatically stopped the current one running, which was quite limiting. When running a program, if you were to switch to another There was no background task or running of multiple programs. If we look into the MS-DOS and the first Apple OS, they could run one thing at a time. Once upon a time, we only had a single process. This post covers a detailed explanation of what it is and how it works. An in-depth understanding of the event loop may be one of the things many developers neglect.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |