Interview difference between process and threads

Here Insert Picture Description

1. The process is the basic unit of resource allocation, the thread is the basic unit of CPU scheduling and dispatch

2. A thread is part of the process, a thread can only belong to a process, a process can have multiple threads, but there is at least one thread

3. Each process has its own code and data space (application context), the overhead of switching between programs large,
the thread can be seen as lightweight processes, threads share the same type of code and data space, each thread has its own independent runtime stack and program counter (PC), the thread switching overhead between small

4. In the operating system running multiple processes simultaneously (program)
in the same process (program) executed in multiple threads simultaneously (by the CPU scheduling, the film only one thread executes at each time)

5. system at run time will be different for each process allocates memory space
(resources from their respective processes of resource thread used) threads in addition to CPU, the system does not allocate memory for the thread, the thread group can only be shared between resources

6. No process can be seen as ready-made single-threaded, if there are multiple threads within a process, perform the procedure is not a line, Davis multiple lines (threads) have completed
the thread is part of the process, it is called a thread It is light weight processes / lightweight processes

Published 114 original articles · won praise 16 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44026997/article/details/104796244