[理工] OS kernel thread, user thread
想請教各位
user thread 跟 kernel thread有什麼關係嗎?
或是我應該問 kernel thread到底是什麼?
定義上來說
user thread是由process自行管理 kernel不知道他的存在
kernel thread是由OS來管理
然後有1 to 1, many to 1, many to many的model
洪逸課本、原文書都只有寫到這樣
然後就是OS會依據process內的kernel thread來分配CPU time
但剛剛讀一讀突然就覺得 恩....怎麼感覺怪怪的
因為寫過pthread程式 大概可以「意會」user thread是什麼東西
那kernel thread是什麼? 什麼叫做由OS來建立管理?
他跟user thread的關聯是什麼?
(有關聯才有所謂的mapping model吧 不然mapping的「意義」是?)
我的想法是:
是不是在建立process時
同時就會建立一個kernel thread (可以看成一個main thread的概念)
然後OS是透過這個kernel thread來管理process
排程~更改PCB~給資源...等等 以及跟硬體層的溝通
像是若process呼叫system call時是用這個kernel thread(main thread)來執行
以上都是我腦補出來的 因為網路上實在找不到完整的說法
如果這樣想是對的 那我又有一個問題
在many to 1的model下
每個process的kernel thread就固定是創建process時所建立的
因此所有user thread都mapping到他
在many to many之下
也可以透過事先定義好建立什麼process要建幾個kernel thread
這兩個還可以理解
但1 to 1呢?
洪逸上課是說建立user thread時就會建立一個kernel thread
但重點是....OS不就是不知道user thread的存在嗎?
那他怎麼在建立user thread時就建立一個kernel thread.....
而且剛剛查了一下才發現好像call API就可以建立kernel thread
所以感覺我好像誤解kernel thread的功用...
有點與user thread是獨立不相干的感覺
那..... 那個model是在mapping什麼呢?mapping的意義是?
kernel thread到底是什麼?
還請知道的大大幫忙QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.255.28.110
※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1481387370.A.213.html
推
12/11 00:47, , 1F
12/11 00:47, 1F
→
12/11 00:47, , 2F
12/11 00:47, 2F
→
12/11 00:47, , 3F
12/11 00:47, 3F
→
12/11 00:47, , 4F
12/11 00:47, 4F
→
12/11 00:47, , 5F
12/11 00:47, 5F
→
12/11 00:47, , 6F
12/11 00:47, 6F
→
12/11 10:47, , 7F
12/11 10:47, 7F
→
12/11 10:47, , 8F
12/11 10:47, 8F
→
12/11 10:47, , 9F
12/11 10:47, 9F
→
12/11 10:47, , 10F
12/11 10:47, 10F
推
12/11 13:24, , 11F
12/11 13:24, 11F
→
12/11 13:24, , 12F
12/11 13:24, 12F
推
12/11 13:28, , 13F
12/11 13:28, 13F
→
12/11 13:28, , 14F
12/11 13:28, 14F
→
12/11 13:28, , 15F
12/11 13:28, 15F
→
12/11 13:28, , 16F
12/11 13:28, 16F
→
12/11 13:28, , 17F
12/11 13:28, 17F
→
12/11 14:23, , 18F
12/11 14:23, 18F
→
12/11 14:23, , 19F
12/11 14:23, 19F
→
12/11 14:23, , 20F
12/11 14:23, 20F
推
12/11 22:38, , 21F
12/11 22:38, 21F
→
12/11 22:53, , 22F
12/11 22:53, 22F
→
12/11 22:53, , 23F
12/11 22:53, 23F
→
12/11 22:54, , 24F
12/11 22:54, 24F
→
12/11 22:55, , 25F
12/11 22:55, 25F
→
12/11 22:56, , 26F
12/11 22:56, 26F
→
12/11 22:56, , 27F
12/11 22:56, 27F
→
12/11 22:57, , 28F
12/11 22:57, 28F
→
12/11 22:57, , 29F
12/11 22:57, 29F
→
12/12 10:50, , 30F
12/12 10:50, 30F
→
12/12 10:50, , 31F
12/12 10:50, 31F
→
12/12 10:50, , 32F
12/12 10:50, 32F
→
12/12 10:50, , 33F
12/12 10:50, 33F
推
12/12 14:23, , 34F
12/12 14:23, 34F