A process is a program with a certain set of independent functions on a data collection of a running activity, the process is a system for resource allocation and scheduling of a separate unit, each process has its own independent memory space, different processes through interprocess communication to communicate. Because of the process weight, occupy the independent memory, so the switching overhead between the context process (stack, register, virtual memory, file handle, etc.) is relatively large, but relatively safe and stable.
A thread is an entity of a process, a succession unit of CPU dispatch and dispatch, which is a smaller unit that can run independently than a process, and the thread itself does not own system resources, but has only a few resources (such as program counters, a set of registers and stacks) that are essential to the operation. However, it can share all of the resources owned by the process with other threads that belong to one process. Inter-thread communication mainly through shared memory, context switching, resource overhead is less, but compared to the process, not stable enough, easy to lose data.
The process is a kind of user-state lightweight thread, the scheduling of the association is completely user-controlled. The co-process has its own register context and stack. When the scheduling switch, the register context and the stack is saved to another place, in the cut back, the recovery of the saved register context and stack, the direct Operation Stack is basically no kernel switching overhead, can not lock the access to global variables, so the context of the switch is very fast.
About threads, processes, and co-routines