Browser threads and processes

Time:2020-2-23

Browser threads and processes

Threads vs processes

Multithreading can process tasks in parallel, butThreads cannot exist alone. They are started and managed by processes

A process is a running instance of a program. The detailed explanation is that when starting a program, the operating system will create a block of memory for the program to store code, running data and a main thread executing tasks. We call such a running environmentprocess

Browser threads and processes

Threads are dependent on the process, and the use of multi-threaded parallel processing in the process can improve the efficiency of operation.

In summary, the relationship between processes and threads has the following four characteristics.

  1. If any thread in the process fails to execute, the whole process will crash.
  2. Data in the process is shared between threads.
  3. When a process is shut down, the operating system reclaims the memory used by the process.
  4. Content between processes is isolated from each other.

Only one page has been opened. Why are there four processes?

Because opening a page requires at least one network process, one browser process, one GPU process and one rendering process, a total of 4; if the opened page has a plug-in running, another plug-in process needs to be added.

However, there are two sides to everything. Although the multi process model improves the stability, fluency and security of the browser, it also inevitably brings some problems:

  • Higher resource usage。 Because each process will contain a copy of the common infrastructure (such as the JavaScript runtime environment), this means that the browser will consume more memory resources.
  • More complex architecture。 The problems of high coupling and poor scalability among browser modules will make the current architecture difficult to adapt to the new requirements.

Recommended reading

  1. The relationship between IP, UDP and TCP
  2. Restful API architecture style for the front end
  3. Tips: reuse your code with mixins of vue.js

Reference: geek time “browser working principle and practice”, 01 | chrome architecture: only one page has been opened, why are there four processes? https://time.geekbang.org/col…

Recommended Today

Hot! Front and rear learning routes of GitHub target 144K

Hello, Sifu’s little friend. I’m silent Wang Er. Last week, while appreciating teacher Ruan Yifeng’s science and technology weekly, I found a powerful learning route, which has been marked with 144K on GitHub. It’s very popular. It covers not only the front-end and back-end learning routes, but also the operation and maintenance learning routes. As […]