[問題] Linux pthread 問題

看板LinuxDev作者 (阿通)時間13年前 (2011/04/22 00:34), 編輯推噓2(2014)
留言16則, 6人參與, 最新討論串1/2 (看更多)
There are two different implementations of POSIX pthreads in Linux. One is at user level, the other is as kernel threads . Which one is installed on the system you are using? 這是小弟的作業, 我花了兩小時,上網找資料,看課本,還是不知道答案是什麼... 請各位幫忙. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.193.40.219

04/22 11:14, , 1F
阿他不是叫你去你的system找? 不過這問題也很怪
04/22 11:14, 1F

04/22 16:45, , 2F
I guess the user level.
04/22 16:45, 2F

04/22 18:06, , 3F
應該兩種都會用吧?但是以使用者來說是user level
04/22 18:06, 3F

04/23 22:56, , 4F
用ps看看一個小程式(開兩個threads)有沒有出現個別pid
04/23 22:56, 4F

04/23 22:57, , 5F
有的話就是kernel thread, 不然就是user thread
04/23 22:57, 5F

04/24 00:09, , 6F
NPTL(Native Posix Thread Library)和LT(Linux Thread)嗎?
04/24 00:09, 6F

04/24 00:10, , 7F
試試"getconf GNU_LIBPTHREAD_VERSION"
04/24 00:10, 7F

04/24 00:12, , 8F
我目前看到用NPTL和LT的Linux都是kernel-aware threads
04/24 00:12, 8F

04/24 00:13, , 9F
純user-level threads大概是指GNU pth
04/24 00:13, 9F

04/24 00:13, , 10F
http://www.gnu.org/software/pth/ 推薦看看這網站
04/24 00:13, 10F

04/24 00:14, , 11F
或在看看恐龍本(6e版以後才有threads章節)
04/24 00:14, 11F

04/24 00:44, , 12F
剛找了一下,確實還是要看系統,每種系統使用會有所不同!
04/24 00:44, 12F

04/24 00:48, , 13F
http://tinyurl.com/42n882r ←找到的threads中文解釋。
04/24 00:48, 13F

04/24 00:55, , 14F
就端看板大在學校的桌上,是挑到兩種系統中的哪種了。
04/24 00:55, 14F

04/24 01:25, , 15F
如果你使用pthread(假設使用clone),會使用到kernel
04/24 01:25, 15F

04/24 01:26, , 16F
thread (pid會只有一個, tid才會有多個不同的)
04/24 01:26, 16F
文章代碼(AID): #1Di5oRHg (LinuxDev)
文章代碼(AID): #1Di5oRHg (LinuxDev)