You are on page 1of 7

MOI UNIVERSITY

OFFICE OF THE CHIEF ACADEMIC OFFICER

UNIVERSITY EXAMINATIONS
2009/2010 ACADEMIC YEAR
SECOND YEAR FIRST SEMESTER EXAMINATIONS

FOR THE DEGREE OF BACHELOR OF TECHNOLOGY IN COMPUTER ENGINEERING COURSE CODE: COE 251 COURSE TITLE: OPERATING SYSTEMS DATE: TIME:

INSTRUCTIONS TO CANDIDATES
1. THIS PAPER CONTAINS SEVEN (7) QUESTIONS 2. QUESTION ONE (1) IS COMPULSORY. ATTEMPT ANY OTHER FOUR QUESTIONS

THIS PAPER CONSISTS OF (7) PRINTED PAGES PLEASE TURN OVER

COE 251: Operating Systems

Semester I

Academic year: 2009/10

Question one (compulsory)


a) In what significant way does the role of the operating system as resource allocator differ from its role as control program?
[2 marks]

b) Below is a simple structuring model for an operating system.

i) Identify this model. ii) What is the role of each of the components highlighted in this model?
[4 marks]

c) Distinguish between interrupts and traps, and provide a detailed account of the procedure that an operating system follows in handling an interrupt.
[4 marks]

d) Suppose a short-term scheduling algorithm favors those processes that have used little processor time in the recent past. i) Explain why this algorithm favors I/O-bound processes. ii) Explain why this algorithm does not permanently deny processor time to CPU bound processes.
[3 marks]

e) Mwai Kibaki, Raila Odinga, and Kalonzo Musyoka, like all members of Kenyan political drama, often eat at Ranalos. But Mwai, Raila, and Kalonzo would rather NOT eat at Ranalos on the same evening as one of the other two. Think of Ranalos as a system resource (e.g., file). Think of Mwai, Raila, and Kalonzo as three processes needing access to this resource. Does the following solution to the critical section problem for three processes satisfy the desired mutual exclusion requirements? Justify your response.
[3 marks]
Have three flags (shared variables): Mwai, Raila, and Kalonzo Have neon sign (shared variable) which flashes either "Mwai-K" or "Raila-O" or "Kalonzo-M" Initially: all flags are down and sign flashes "Mwai"

COE 251: Operating Systems

Semester I

Academic year: 2009/10

Mwai
Repeat [play golf] Raise Mwai; SIGN = Mwai-K; While (((Raila is up) OR (Kalonzo is up)) AND (SIGN==Mwai-K)) (do nothing); (eat dinner); Lower Mwai; Forever;

Raila
Repeat [play football] Raise Raila; SIGN = Raila-O; While (((Mwai is up) OR (Kalonzo is up)) AND (SIGN==Raila-O)) (do nothing); (eat dinner); Lower Raila; Forever;

Kalonzo
Repeat [Go to church] Raise Kalonzo; SIGN = Kalonzo-K; While (((Raila is up) OR (Mwai is up)) AND (SIGN==Kalonzo-K)) (do nothing); (eat dinner); Lower Kalonzo; Forever;

f) In the context of Dijkstra's Banker's Algorithm, determine whether the following state is safe or unsafe. If safe, show how it is possible that all processes complete.

[3 marks]

Question two
a) i) How is 'concurrent process execution' achieved if there is only a single CPU? ii) State ONE reason why a switch between threads may be cheaper than a switch between processes.
[2 marks]

b) The following state transition table is a simplified model of process management, with the labels representing transitions between states of READY, RUN and BLOCKED.

Give an example of an event that can cause each of the above transitions.
[2 marks]

c) Given a system using multilevel feedback queues (MFQ), a totally CPU-bound process requires 50 seconds to execute. If the first queue uses a time quantum of 5, and at each lower level the time quantum doubles, determine: i) How many times the job will be interrupted. ii) The queue on which the job will terminate.
[2 marks]

COE 251: Operating Systems

Semester I

Academic year: 2009/10

d) Consider the following table showing three processes (P1, P2 and P3), their respective arrival times and CPU burst times.

Process P1 P2 P3

Arrival time 0.0 0.4 1.0

Processing time 8 4 1

Determine the average turnaround and waiting time for these processes using the following algorithms: i) First Come First Served ii) Shortest Job First (non-preemptive)
[4 marks]

e) i) What is the role of the fork() and exec() system calls in UNIX.
[2 marks]

ii) Assume that you have executed the following C program:


main () { int pid; pid = fork (); printf ("%d \n", pid); }

What are the possible outputs, assuming the fork succeeded?


[1 mark]

Question three
a) Define the following concepts: i) Co-operating process ii) Race condition iii)Critical section. iv) Busy waiting
[2 marks]

b) Study the following implementation of mutual exclusion using mailboxes with nonblocking send_mailbox and blocking receive_mailbox primitives. Assume the primitives are executed as indivisible atomic operation.

COE 251: Operating Systems

Semester I

Academic year: 2009/10

In the context of the mutex implementation above, which of the following statements are TRUE? i) For this primitive to hold, mailbox mutex can only have a single message. ii) Only when a process actually receives a message can it enter its critical section. iii)According to the conditions stated above, a process doesnt have to receive a message to enter its critical section. iv) On leaving its critical section, a process returns the message it received back to the mailbox. v) Since there is only one message, only one process can be in its critical section at a time.
[4 marks]

c) What is the difference between a deadlocked and an unsafe state?


[2 marks]

d) If deadlock is controlled by the banker's algorithm, which of the following changes can be made safely and under what circumstances? i) Increase Available (add new resources)
[1 mark]

ii) Decrease Available (remove resources)


[1 mark]

iii)Increase Max for one process


[1 mark]

iv) Increase the number of processes


[2 marks]

Question Four
a) Explain the difference between logical and physical addresses. Why are logical addresses important?
[3 marks]

b) Suppose a fixed partitioning memory system with partitions of 100K, 500K, 200K, 300K, and 600K (in memory order) exists. All five partitions are currently available. i) Using the best fit algorithm, show the state of memory after processes of 212K, 417K, 112K, and 350K (in request order) arrive.
[2 marks]

ii) At the end of part i), how much internal fragmentation exists in this system?
[2 marks]

c) Consider the following factors: i) Internal fragmentation, ii) Process table size, iii)I/O overhead, iv) Locality of reference. Which of these factors could be used to argue for a large page size, and which could be used to argue for a smaller page size? Why?
[4 marks]
5

COE 251: Operating Systems

Semester I

Academic year: 2009/10

d) Consider a logical address space of eight pages of 1024 bytes each, mapped onto a physical memory of 32 frames. i) How many bits are there in the logical address? ii) How many bits are there in the physical address?
[2 marks]

Question Five
a) i) Explain how demand paging augments a simple paging scheme with the concept of a page fault. In your answer describe the actions of the OS on a page fault and explain any necessary changes to the page table.
[4 marks]

ii) Explain how a demand paged Virtual Memory benefits from temporal and spatial locality in programs.
[2 marks]

b) Explain the concept of working set and describe how it can be used in page replacement algorithms.
[4 marks] c) A virtual memory system exhibits the follow trace of page numbers:

12326341561642 Simulate the page replacements for the following scenarios: i) LRU with 3 page frames. ii) LRU with 4 page frames. Show the number of page faults that occur in each scenario. Does Belady's anomaly occur?
[3 marks]

Question Six
a) With the aid of examples, explain the following file management concepts: i) Root directory ii) Home directory iii)Current working directory
[3 marks]

b) State ONE example of an application in which data in a file should be accessed in the following order: i) Sequentially ii) Randomly
[2 marks]

COE 251: Operating Systems

Semester I

Academic year: 2009/10

c) i) A sequential access file has fixed-size 150-byte records. Assuming the first record is record 1, the first byte of record 5 will be at what logical location?
[1 mark]

ii) A direct access file has fixed-size 150-byte records. Assuming the first record is record 1, the first byte of record 5 will be at what logical location?
[1 mark]

iii)Comment on the answer(s) obtained in i) and ii).


[1 mark]

d) i) Clearly distinguish between spanned and unspanned blocking.


[2 marks]

ii) Given a system using unspanned blocking and 60-byte blocks. A file contains records of 15, 35, 20, 10, 30, 35, 30 bytes. What percentage of space will be wasted in the blocks allocated for the file?
[3 marks]

Question seven
a) Explain why it makes sense to store recently used data (e.g., recently referenced pages) in cache.
[4 marks]

b) Explain what device controllers and device drivers are and briefly describe their purposes.
[4 marks]

c) Suppose that a disk drive has 200 cylinders numbered from 0 to 200. There are pending requests that have come in the order 59, 41, 172, 74, 52, 85, 139, 12, 194, and 87. Assume that the head pointer is 100. Identify the following disk scheduling policies representing the above disk requests.
[3 marks]

i)

ii)

iii)

d) A magnetic disk with 5 platters has 2048 tracks/platter, 1024 sectors/track (fixed number of sectors per track), and 512-byte sectors. What is its total capacity?
[2 marks]

You might also like