What is the difference between a thread/process/task?

后端 未结 7 2114
离开以前
离开以前 2021-01-29 20:04

What is the difference between a thread/process/task?

7条回答
  •  离开以前
    2021-01-29 20:26

    Wikipedia sums it up quite nicely:

    Threads compared with processes

    Threads differ from traditional multitasking operating system processes in that:

    • processes are typically independent, while threads exist as subsets of a process
    • processes carry considerable state information, whereas multiple threads within a process share state as well as memory and other resources
    • processes have separate address spaces, whereas threads share their address space
    • processes interact only through system-provided inter-process communication mechanisms.
    • Context switching between threads in the same process is typically faster than context switching between processes.

    Systems like Windows NT and OS/2 are said to have "cheap" threads and "expensive" processes; in other operating systems there is not so great a difference except the cost of address space switch which implies a TLB flush.

    Task and process are used synonymously.

提交回复
热议问题