Applicable occasions and commonly used programming models for muduo library learning 03-processes and threads

Dongyang's study notes

Processes and threads

  • Each process has its own independent space. "In the same process" or "not in the same process" is an important decision point for the division of system functions.
  • Threads are characterized by sharing address space, thereby efficiently sharing data. Multiple processes on a machine can efficiently share code segments (the operating system can be mapped to the same physical memory ), but cannot share data. If multiple processes share a large amount of memory, it is tantamount to writing a multi-process program as a multi-threaded program.

Why use multithreading

The author believes that it is to better play the performance of multi-core processors. If there is only one CPU and one execution unit, it is the most efficient to write the program according to the state machine idea.

Guess you like

Origin blog.csdn.net/qq_22473333/article/details/113508954