The differences between processes and threads?

来源:互联网 发布:情绪 知乎 编辑:程序博客网 时间:2024/06/10 06:13

Why threads over processes?

(1) Creating a new process can be expensive.

             1)Time

                         A call into the operating system is needed
                         Context-switching involves the operating system

             2)Memory

                         The entire process must be replicated

             3)The cost of inter-process communication and synchronization of shared data

                         May involve calls into the operation system kernel

(2)Threads can be created without replicating an entire process

          1)Creating a thread is done in user space rather than kernel
          2)Sharing virtual address spaces.

0 0