作者mycallmax (阿冠)
看板b95902HW
標題Re: [討論] 雙班系統程式期末考
時間Sun Jun 15 20:19:28 2008
雙班系程期末考,老師說會把下面題目列入考慮囉
以下是參考的解答
有錯的話大家就提出來吧
1. What is Zombie and Orphan?
1.Zombie: 若一個child process在parent process還沒有wait它之前就已經結束時,
我們稱此process為Zombie. Kernel會保留它的最少資訊,直到parent process執行wait
的動作.
2.Orphan: 若一個parent process在child process結束之前就已經結束,此時這個child
process被稱為Orphan. 它的parent process會被設成process "init"(PID 1),而init會
在這個child process結束的時候,會執行wait()來取得termination status.
延伸閱讀:講義的Why do we need Zombie?
(a)A parent can end up with two different children that share the same PID.
(b)A parent can end up trying to wait for the return code of another process'
child.
(c)The kernel won't be able to correctly track which return code goes with
which process.(unless it uses additional complex logic.)
2.Please draw the graph of the typical memory arrangement.
參考課本figure 7.6
(有修改過)
3.Please describe the adavetage and disadvantage of shared library
and static library.
shared library
優點:
1.當library更新的時候方便更新,不必要重新compile或link
2.可以減少程式的檔案大小
缺點:
1.在程式loading或呼叫到shared library function的時候因為
需要dynamic linking,所以所花時間較多
2.程式執行的時候要確定系統裡有shared library
static library
優點:
1.比起shared library程式執行速度較快
2.不用要求系統內建library,library已經包含在程式中
缺點:
1.當library要更新時需要重新link或compile.
2.程式的檔案大小較大
When to use shared library?
1.library常常需要更新的時候
2.若使用shared library可清楚切割source code和GPL source code,可不用
follow GPL license.
3.減少程式的體積
When to use static library?
1.避免系統不存在shared library
2.自己寫的library.
3.加速讀取的時間
4.We know that we can register an exit handler by atexit(). But it seems that
we can't unregister an exit handler.Can we still have the effect that
just like we unregister some exit handler? How to do it?
1.yes
2.可以宣告一個global variable當作flag(例如 ex1_flag),然後在function的最開頭
先判斷,若ex1_flag=1時就往下執行,若ex1_flag=0時就不執行,這樣就算這個function
已經被註冊為exit handler,還是可以利用這個flag來選擇要不要被執行,有同樣的效果
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.84
※ 編輯: mycallmax 來自: 140.112.30.84 (06/15 20:23)
1F:推 hpttw:頭推 06/15 20:29
2F:推 kobe761021:推推推 06/15 20:33
3F:推 kevintpd:頸推 06/15 20:33
4F:→ kevintpd:QQ 06/15 20:33
5F:推 fbi43:推 06/15 20:34
6F:推 hakusin:再推 06/15 20:36
7F:推 TARK:神!有神! 06/15 20:39
8F:推 ec2522:推!! 06/15 20:47
9F:推 askus: 拜推<(_ _)> 06/15 20:52
10F:推 kuokuo321:推!!! 06/15 20:56
11F:推 mardaban1:推 06/15 21:01
12F:推 angela7736:推 06/15 21:24
13F:推 tobyhuang:淚推 06/15 21:33
14F:推 goingon:推推 06/15 21:49
15F:推 eric20000:只能推了~~ 06/15 22:02
16F:推 daviddavid:推推推!! 06/15 22:05
17F:推 mt01020:推~~~~~ 06/15 22:25
18F:推 yease:推~~ 06/15 22:40
19F:推 aliby:推~~~~ 06/15 22:52
20F:推 dimensioner:推強者 06/15 23:01
21F:推 tobyhuang:推 06/15 23:07
22F:推 noskid:推~ 06/15 23:17
23F:推 tobyhuang:再推 06/15 23:18
24F:推 cyril928:這一篇100分!!! 06/15 23:29
25F:推 edwardhw:啾咪! 06/15 23:30
26F:推 joehuang92:娘子快出來看神!!! 06/15 23:42
27F:推 ubiquitin:謝謝~~~ ^^ 06/16 00:11
28F:推 daisyhamu:謝謝關羽~ 好用心 06/16 00:34
29F:推 wangshichen:相當辛苦~~大家考試加油!! 06/16 00:50
30F:推 et220870:娘子,快出來看上帝~~ 06/16 01:22
31F:推 sasbluesea:般若般羅密~~ 06/16 01:42
32F:推 whitesara931:謝謝關羽~~ 06/16 08:40
33F:推 hideys:大推關羽! 06/16 11:29
※ 編輯: mycallmax 來自: 140.112.30.84 (06/16 15:45)
34F:推 hakusin:關上就會好! 06/17 08:43