2015年11月24日 星期二

process與thread差異


Both processes and threads are independent sequences of execution. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces.
Process和Thread都是獨立的執行序列。不同的是,(同一個Process的)Threads 在共享的記憶體空間中運行,而processes在不同的記憶體中運行

在2.4內核中,不存在線程組的概念,當運行一個多線程得程式時,使用ps命令,可以看到有許多個進程,在ps命令看來,線程基本上是等同於進程,在信號處理中,情況也是如此,只有指定進程號的線程,可以接收到信號。在2.6內核中引入了線程組的概念,在2.6內核中,如果使用ps命令看,一個多線程的進程,只會顯示一個進程,在給線程組中的任何一個線程發送信號的時候,整個線程組中的進程都能收到信號。

PTT
NDark:
code是炮操手冊 cpu是兵 process是跳完砲操 thread是砲管數
lovdkkkk:
各個 Process 共享 CPU/Memory 的資源
然後 Thread 共享 Process 的資源

參考資料:
http://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread  What is the difference between a process and a thread
http://www.longene.org/forum/viewtopic.php?f=5&t=94&p=399#p399  Linux2.6内核中的线程组初探
http://blog.chinaunix.net/uid-24774106-id-3650136.html  Linux线程 之 线程 线程组 进程 轻量级进程(LWP)
https://www.ptt.cc/bbs/Soft_Job/M.1406625146.A.971.html  [請益] 要如何讓人搞懂Process與Thread



沒有留言:

張貼留言