大连交大os第二章作业

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第二章作业

14. What’s the biggest advantage of implementing thread in user space? What’s the biggest disadvantage?

Solution: The first advantage is that a user-level package can be implemented on an operating system that does not support threads. The second advantage is that they allow each process to have its own customized scheduling algorithm.

The disadvantage is the problem of how blocking system calls are implemented. Another problem is that if a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU.

35. Measurements of certain system have shown that the average process runs for

a time T before blocking on I/O. A process switch requires a time S, which is effectively wasted (overhead). For round-robin scheduling with quantum Q, give a formula for the CPU efficiency for each of the following:

(a) Q=∞CPU efficiency=T/ (T+S)

(b) Q>T CPU efficiency= T/ (T+S)

(c) S

(d) Q=S CPU efficiency=50%

(e) Q nearly 0 CPU efficiency is nearly 0

36. Five jobs are waiting to be run. Their expected run times are 9, 6, 3, 5, and X. In what order should they be run to minimize average response time?(Your answer will depend on X.)

Solution:

IF (X<=3): X, 3, 5, 6, 9

IF (X>=3 AND X<=5): 3, X, 5, 6, 9

IF (X>=5 AND X<=6): 3, 5, X, 6, 9

IF (X>=6 AND X<=9): 3, 5, 6, X, 9

IF (X>=9): 3, 5, 6, 9, X

37. Five batch jobs A through E, arrive at a computer center at almost the same time. They have estimated running times of 10, 6, 2, 4, and 8 minutes. Their (externally determined) priorities are 3, 5, 2, 1, and 4, respectively, with 5 being the highest priority. For each of the following scheduling algorithms, determine the mean process turnaround time. Ignore process switching overhead.

(a) Round robin

(b)Priority scheduling

(c)First-come, first-served (run in order 10, 6, 2, 4, 8)

(d)Shortest job first

For (a), assume that the system is multiprogrammed, and that each job gets its fair share of the CPU. For (b) through (d) assume that only one job at a time runs, until it finishes. All jobs are completely CPU bound.

Solution:

(a)Round robin (quantum=2)

Turnaround time:

A: 10+6+2+4+8=30

B: 30-4*2=22

C: 2+2+2=6

D: 2*8=16

E: 30-2=28

Mean turnaround time= (30+22+6+16+28)/5=80/5=20.4

(b)priority scheduling

Turnaround time:

A: 6+8+10=24

B: 6

C: 24+2=26

D: 26+4=30

E: 6+8=14

Mean turnaround time= (24+6+26+30+14)/5=100/5=20 (c) FCFS

Turnaround time: A: 10 B: 10+6=16 C: 16+2=18 D: 18+4=22 E: 22+8=30

Mean turnaround time= (10+16+18+22+30)/5=96/5=19.2 (d) Shorted job first

Turnaround time: A: 2+4+6+8+10=30 B: 2+4+6=12 C: 2 D: 2+4=6 E: 2+4+6+8=20

相关文档
最新文档