What is parallel processing?

Parallel processing in computers is dealing with multiple tasks at the same timeCopy the code
  • Task 1 is to calculate A=1+2;
  • Task 2 is to calculate B=20/5;
  • Task 3 is to calculate C=7*8;
  • Task 4 is to display the result of the final calculation.

Single-threaded: to process, that is, to execute each of the four tasks in four steps in sequence

Multithreading: The first step is to use three threads to perform the first three tasks simultaneously. Second, perform the fourth display task. (Parallel processing can greatly improve performance)

Threads vs. processes

Multithreading can process tasks in parallel, but threads cannot exist alone. They are started and managed by processes. (The operating system creates a block of memory for the program to hold its code, running data, and a main thread to perform tasks. We call such a runtime environment a process.) Thread is attached to process, and using multi-thread parallel processing in process can improve computing efficiency.

  • A process is a running instance of a program.
  • Threads share data in a process.
  • The failure of any thread in the process will cause the entire process to crash.
  • Thread is attached to process, and using multi-thread parallel processing in process can improve computing efficiency.
  • When a process is shut down, the operating system reclaims the memory occupied by the process.
  • Content isolation between processes (mechanism for interprocess Communication usage (IPC))

Page memory leaks are also an important cause of single-process slowdowns. Usually the browser kernel is very complex, running a complex page and then closing the page, there will be a situation of memory can not be fully reclaimed, which leads to the problem is that the longer the use time, the higher the memory footprint, the slower the browser will become.

Early single-process browsers

Single-process browser means that all the functional modules of the browser run in the same process. These modules include the network, plug-ins, JavaScript runtime environment, rendering engine and pages.Copy the code

Manage multiple threads in one process, including network threads, page threads, etc. Cons: * Unstable The accidental crash of one plug-in can cause the entire browser to crash. * The render engine module is also unstable, and often some complex JavaScript code can cause the render engine module to crash. * Inconsistencies are in the same thread, which means that only one module can be executed at a time. Page memory leaks are also an important cause of single-process slowdowns. Usually the browser kernel is very complex, running a complex page and then closing the page, there will be a situation of memory can not be fully reclaimed, which leads to the problem is that the longer the use time, the higher the memory footprint, the slower the browser will become. * Insecure Any resources of the operating system can be obtained through plug-insCopy the code

Multi-process browser era

As you can see, Chrome pages run in a separate rendering process, and plugins run in a separate plug-in process, which communicates with each other through an IPC mechanism (dotted line).Copy the code

  • Processes are isolated from each other, so when a page or plug-in crashes, it only affects the current page or plug-in process, not the browser or other pages
  • JavaScript also runs in the renderer process, so even if JavaScript blocks the renderer process, it only affects the current rendering page, not the browser and other pages, whose scripts run in their own renderer process.
  • You can think of a sandbox as a lock placed on a process by the operating system. Programs inside the sandbox can run, but they can’t write any data to your hard drive or read any data from sensitive locations, such as your documents and desktop. Chrome locks the plugin and renderer processes in a sandbox, so that even if a malicious program is executed in the renderer or renderer process, the malicious program cannot break through the sandbox to obtain system permissions.

Current multi-process architecture