pthread 的 p 是 posix,也就是 posix 標準的 thread api。
fork 的 parent 和 child 沒有任何共用的地方。
但是
thread_create 出來的 thread 和 mother(?) process/thread 共用 所有的東西。
所以 thread 間的同步控制就更重要。 pthread 的標準就包含很多 process 間同步的物件。
從resource 共用來看 process 和 thread:
thread 間要共用一個 array,就宣告一個 global array 就可以。
但是
process 間要共用一個 array,在 fork 之前就要先用 shmget,shmat 準備好。
1 則留言:
fork 的 parent 和 child 似乎會共用kernel space
張貼留言