[Linux] multi-process and multi-threaded

1. In the Linux system, start a new process must be assigned to its separate address space, the establishment of a large number of data tables to maintain its code segment, stack and data segments, this is an "expensive" multitasking work the way.
2. while running on multiple threads within a process, using the same address space between each other, share most of the data, start a thread space it takes far less than it takes to start a process space, and, inter-thread the time required for switching between each other far less than the time required for the process of switching

3. the fundamental difference is this: with multi-process each process has its own address space (address space), the thread is a shared address space. All other differences are resulting in :
1) speed: speed of the thread produced fast communication between threads fast, fast switching, etc., because they are in the same address space.
2) resource utilization: the thread is better resource utilization but also because they are within the same address space.
3) synchronization issues: the need to use a thread synchronization mechanism or because the public variables / memory they are in the same address space.

Multi-threaded shared address space

 

Guess you like

Origin www.cnblogs.com/taoshihan/p/11279919.html