| Process |
In-memory programs. Has its own independent exclusive virtual CPU, virtual Memory, virtual IO devices. (1) Each process occupies a separate address space. The address space here includes code, data, and other resources. (2) communication overhead between processes is large and subject to many constraints. Object (or function) interface, communication protocol (3) The switching overhead between processes is also large. Also known as context Switch. The context includes code, data, stacks, processor state, and resources. |
| Thread |
Lightweight process. In modern operating systems, it is the smallest unit of program execution flow in a process. A standard thread consists of a thread ID, a current instruction pointer (PC), a collection of registers, and a stack. (1) Multiple threads share the address space of a process (code, data, other resources, and so on). Threads also need their own resources, such as program counters, register groups, call stacks, and so on. (2) communication overhead between threads is less and simpler. Because sharing reduces the content that needs to be communicated. However, shared resources cannot be protected because they are fully shared. (3) The switching overhead between threads is also small. Just save the program counters, register groups, stacks, and so on for each thread. No need to switch or copy the entire address space, resulting in a much lower cost (about 1/10) |
| Co-process |
Lightweight threads. is a function that can be executed concurrently, by a compile or user-specified location, giving control to the way the scheduler executes. It is non-preemptive, avoids repeated system calls, and the overhead of process switching, giving you thousands of logical streams, also known as user-level threads. |