Anda di halaman 1dari 4

1

Answers to Final Examination of Operating Systems


2006/01/11 (Wed.)

1. (15% )
(a) What is internal fragmentation?
(b) What is the degree of multiprogramming?
(c) What is a race condition?
(a) Internal fragmentation is the area in a region or a page that is not used by the job occupying
that region or page. This space is unavailable for use by the system until that job is finished and the
page or region is released.
(b) The degree of multiprogramming is the number of processes in memory.
(c) A race condition is the situation where several processes access and manipulate the same data
concurrently and the outcome of the execution depends on the particular order in which the access
takes place.
2. (5%) Which of the following scheduling algorithms could result in starvation?
(a) First-come, first-served (b) Shortest job first
(c) Round robin (d) Priority
(b) and (d)
3. (5%) Which of the following components of program state are shared across threads in a
multithreaded process?
(a) Register values (b) Heap memory
(c) Global variables (d) Stack memory
(b) and (c)
4. (10%) What are two differences between user-level threads and kernel-level threads?
(a) User-level threads are unknown by the kernel, whereas the kernel is aware of kernel threads.
(b) User-level threads are scheduled by the thread library and the kernel schedules kernel-level
threads.
5. (10%) Consider the following set of processes, with the length of the CPU-burst time given in
milliseconds:
Process Burst Time Priority
P
1
10 3
P
2
1 1
P
3
2 4
P
4
1 5
P
5
5 2
The processes are assumed to have arrived in the order P
1
, P
2
, P
3
, P
4
, P
5
, all at time 0.
(a) Draw four Gantt charts illustrating the execution of these processes using FCFS, SJ F, a
nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum=1)
scheduling.
(b) What is the waiting time of each process for each of scheduling algorithms in part a?
(a)
(b) Waiting time
FCFS SJ F Priority RR
P
1
0 9 6 9
P
2
10 0 0 1
P
3
11 2 16 5
P
4
13 1 18 3
P
5
14 4 1 9

6. (10%) Consider a paging system with the page table stored in memory.
(a) If a memory reference takes 200 nanoseconds, how long does a paged memory reference take?
(b) If we add associative registers, and 75 percent of all page-table references are found in the
associative registers, what is the effective memory reference time? (Assume that finding a
page-table entry in the associative registers takes zero time, if the entry is there.)
(a) 400 nanoseconds; 200 nanoseconds to access the page table and 200 nanoseconds to access the
word in memory.
(b) Effective access time =0.75 * (200 nanoseconds) +0.25 * (400 nanoseconds) =250 nanoseconds
7. (15%) Consider the following snapshot of a system:
Allocation Max Available
ABC ABC ABC
P
0
0 1 0 7 5 3 3 3 2
P
1
2 0 0 3 2 2
P
2
3 0 2 9 0 2
2
3
P
3
2 1 1 2 2 2
P
4
0 0 2 4 3 3

Answer the following questions using the bankers algorithm:
(a) What is the content of the matrix Need?
(b) Is the system in a safe state?
(c) If a request from process P
0
arrives for (0, 2, 0), can the request be granted immediately?
(a) The values of Need for processes P
0
through P
4
respectively are
(7, 4, 3), (1, 2, 2), (6, 0, 0), (0, 1, 1), and (4, 3, 1).
(b)Yes. The sequence <P
1
, P
3
, P
4
, P
2
, P
0
>satisfies the safety criteria.
(c) Yes. The sequence <P
3
, P
1
, P
2
, P
0
, P
4
>satisfies the safety criteria.
8. (10%) Consider the following 3-process concurrent program which uses semaphores S1, S2, and S3.
The semaphore operation, which are sometimes called wait and signal, are denoted here with the
classical notation of P and V.
Process 1 Process 2 Process 3
L1: P(S3); L2: P(S1); L3: P(S2);
print(T); print(U); print(B);
V(S2); V(S3); V(S1);
goto L1; gotoL2; goto L3;
(a) Are there initial values that can be given to the semaphores so that the processes cooperate to
print the string BUTBUTBUTBU? If so, give the initial values (tell which value is to be used
for which semaphore) and explain how the string is printed.
(b) Suppose the initial values are S1=0, S2=0, S3=0. Is it possible for the processes to cooperate to
produce a string that begins with BBTTUTT? Explain your answer.
(a) Yes. S1 =0, S2 =1, S3 =0
(b) No. (Explanation is omitted.)
9. (10%) Consider the following segment table:
Segment Base Length
0 219 600
1 2300 14
2 90 100
What are the physical addresses for the following logical addresses?
(a) 0, 430
(b) 2, 500
(a) 649
(b) illegal reference, trap to operating system
10. (10%) Explain why implementing synchronization primitives by disabling interrupts is not
appropriate in a single-processor system if the synchronization primitives are to be used in user-level
4
programs.
If a user-level program is given the ability to disable interrupts, then it can disable the timer interrupt
and prevent context switching from taking place, thereby allowing it to use the processor without
letting other processes to execute.