Background development knowledge

Multi-process and multi-threaded differences:
data between separate processes 1, the communication requires a special mechanism ipc (pipes, semaphores, shared memory, message queues) between the processes, there are threads in a process, the process of sharing between threads stack section global static storage area, and each has its own independent stack space, synchronization of data with a mutex
created 2 process, destruction, switching complex, slow, threads are lightweight processes.
3. The process consumes more memory, cpu utilization rate. Thread take up less memory, high CPU utilization.
4. The process will not affect each other, a process of thread hang will cause the entire process to hang.
Thread private content: thread id, private data register values, stack memory, thread scheduling, thread, errno variable

Guess you like

Origin www.cnblogs.com/goingnow/p/12177057.html