作者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