[理工] OS幾個問題

看板Grad-ProbAsk作者 (21)(21)時間10年前 (2013/12/12 21:37), 編輯推噓7(7016)
留言23則, 3人參與, 最新討論串1/5 (看更多)
[1]After a user program starts an I/O operation, it has to wait for the completion of the I/O operation to resume its program execution. 此題要選對的 這是其中一個選項 但答案卻沒有選 是否和nonblocking和asynchronous system call有關呢? [2]有關thread pool 1.想請問當有人要一條thread 且thread pool有一條available的 那當該條thread被要走後 該條thread是還在thread pool中但not available 還是不在thread pool中呢? 我看到恐龍書有句寫Once the thread completes its service, it returns to the thread pool.所以應該算是不在嗎? 2.Only when a thread finishes and leaves the pool, we can allow new threads to enter the pool. 答案寫此敘述是對的 沒寫原因 恐龍書寫thread pool的地方也沒看到有關的描述 但根據1.提到恐龍書的描述 當有一個thread finishes 不是應該returns to the thread pool嗎? 為什麼會寫leave呢? 還是是說thread finishes後也有可能把memory還給系統的意思呢? 3.A preemptibe CPU scheduler may choose a thread to leave the thread pool before the thread finishes. 此敘述是錯的 同樣對leave有疑問 若暫且假設2.的最後一句是對的 此外 這項敘述似乎也代表著1.提到的疑問是thread使用時還在thread pool? 是否把leave the thread pool改成block this thread就正確了呢? 4.In Many-to-Many model, the number of kernel threads can be specific to either a particular application or a particular machine. 此敘述是對的 但我看不懂它的意思...... [3]Response time 假設Process Pi在t=1時到達 t=3時開始做 t=6時被較高Priority的Process插隊 則Pi的Response time是3-1=2 還是6-1=5 或是都不對呢? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.67.81 ※ 編輯: jack0602 來自: 140.113.67.81 (12/12 21:37)

12/12 22:30, , 1F
response time = 3-1
12/12 22:30, 1F

12/13 00:39, , 2F
1. non-blocking I/O可以選擇不等I/O
12/13 00:39, 2F

12/13 00:42, , 3F
2.這是電機丙出過的題目
12/13 00:42, 3F

12/13 00:43, , 4F
恐龍說 thread完成服務回到pool的意思是
12/13 00:43, 4F

12/13 00:43, , 5F
從pool挑出thread去serve一個user thread
12/13 00:43, 5F

12/13 00:44, , 6F
當服務完成 雙方thread終止 此時OS會在創一個thread到pool
12/13 00:44, 6F

12/13 00:45, , 7F
(因pool有空位,以上過程恐龍描述為thread服務完回來pool)
12/13 00:45, 7F

12/13 00:45, , 8F
response time這樣問很怪 你那樣是wating time
12/13 00:45, 8F

12/13 00:47, , 9F
3.爭奪CPU是process的事 CPU為一種resource
12/13 00:47, 9F

12/13 00:47, , 10F
而process拿到CPU,其中CPU time的分配才是thread的事情
12/13 00:47, 10F

12/13 00:47, , 11F
cpu排班algo只看turnaround 和wating time
12/13 00:47, 11F

12/13 00:49, , 12F
4. many-many是節省system overhead的作法
12/13 00:49, 12F

12/13 00:50, , 13F
response time是指送出到第一個回應出現的時間
12/13 00:50, 13F

12/13 00:50, , 14F
OS把user thread所需的service map到特定kernelthread
12/13 00:50, 14F

12/13 00:53, , 15F
此model中你想成kernel thread為一群特定的service即可
12/13 00:53, 15F

12/13 00:55, , 16F
最後一題 答案為6-1=5 原因為 搶到CPU 才有做事情
12/13 00:55, 16F

12/13 00:56, , 17F
有做事情 資料才會有更改 直到第一次context switch出去時
12/13 00:56, 17F

12/13 00:56, , 18F
就會有第一次write back的動作 代表user接收到了回應之意
12/13 00:56, 18F

12/13 01:14, , 19F
下一process拿到cpu 會把上一個process的cache block換下
12/13 01:14, 19F

12/13 01:14, , 20F
來 此時data第一次寫回M.M
12/13 01:14, 20F
感謝各位回應!!! 所以當thread pool中可用的thread皆在使用中 也就是沒有available的thread 此時有人request a thread 則會等待(或許放入一個Queue中) 直到有thread終止 然後就會create a new thread給等待的使用 也就是說會維持thread pool中thread的數量是個定值 請問上面這段敘述是否正確呢? 另外關於Response time process正在被執行且不是在做context switch的時候 也可能因為cache miss而需要把cache block換下去寫回memory不是嗎? 我覺得或許process執行到中途就有response 所以由題目給的資訊或是看Gantt chart等應該不能知道Response time才對 ※ 編輯: jack0602 來自: 140.113.67.81 (12/13 16:17)

12/13 19:01, , 21F
基本上這樣講沒什麼問題,有關於response time其實我們求
12/13 19:01, 21F

12/13 19:01, , 22F
的都是一個average time,任何人都無法保證data什麼時候會
12/13 19:01, 22F

12/13 19:01, , 23F
寫回M.M 這也是少考的原因
12/13 19:01, 23F
文章代碼(AID): #1IgRmU4M (Grad-ProbAsk)
文章代碼(AID): #1IgRmU4M (Grad-ProbAsk)