Sie sind auf Seite 1von 8

MOI UNIVERSITY

OFFICE OF THE CHIEF ACADEMIC OFFICER

UNIVERSITY EXAMINATIONS
2011/2012 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

Marking Scheme

COE 251

Marking scheme

Page 2 of 8

Question one
Qn Answer a) Convenient access to operating system data structures i) Monolithic access from any part of the kernel to any other part is possible. With a microkernel access is via message passing. Addition of new operating system components ii) Microkernel no (or little) modification is required in the kernel the new service is in user space. iii) Security and reliability Microkernel services are isolated from each other. If one service crashes it does not directly affect others. Another acceptable answer on security would be both, if implemented well. b) Remarks 2 marks 2 marks

2 marks

User mode Kernel mode Mode bits Executing system call in Kernel mode 4 marks

c) i)

3 marks ii) When processes descend to level 3 the system can be locked up by a level 3 process running in an infinite loop. Fix it by giving level 3 processes a long but fixed time-slice and scheduling them 2 marks round-robin. If they weren't indivisible, it would be possible for multiple waits and signals to occur simultaneously (on a multiprocessor) or at least interleaved with each other. 1 mark This would corrupt the value of the semaphore and prevent it working properly. No. Strictly only processes accessing the same semaphore at that time need to stop. Any processes not wanting to change or access the semaphore should be allowed to continue. 2 marks Total 18 marks

d) i)

ii)

COE 251

Marking scheme

Page 3 of 8

Question two
Qn
a) i)

Answer
Non Pre-Emptive, First Come, First Serve Executes the processes in the order they arrive and to execute them to completion. It is an easy algorithm to implement. When a process becomes ready it is added to the tail of ready queue. This is achieved by adding the Process Control Block (PCB) to the queue. When the CPU becomes free the process at the head of the queue is removed, moved to a running state and allowed to use the CPU until it is completed. The problem with FCFS is that the average waiting time can be long. Round Robin The processes to be run are held in a queue and the scheduler takes the first job off the front of the queue and assigns it to the CPU (so far the same as FCFS). In addition, there is a unit of time defined (called a quantum). Once the process has used up a quantum the process is preempted and a context switch occurs. The process which was using the processor is placed at the back of the ready queue and the process at the head of the queue is assigned to the CPU. Of course, instead of being preempted the process could complete before using its quantum. This would mean a new process could start earlier and the completed process would not be placed at the end of the queue (it would either finish completely or move to a blocked state whilst it waited for some interrupt, for example I/O). The average waiting time using RR can be quite long.

Remarks
3 marks

ii)

3 marks

b) i)

A child is an exact copy of the (parent) caller itself i.e. it's image is a physical bitwise copy of the parent's 1 mark sys/types.h -defines the pid_t data type which represents process IDs. You can get the process ID of a process by calling getpid. The function getppid returns the process ID of the parent of the current process (this 2 marks is also known as the parent process ID). sys/wait.h - declarations for waiting; define the symbolic constants for use with wait() system call, that allows a parent to sleep until one of its children 2 marks exits, and then get its exit status.

ii)

iii)

If - Exit with 0 Else if - Exit with 1

1 mark

Total

13 marks

COE 251

Marking scheme

Page 4 of 8

Question Three
Qn
a) i)

Answer
Race condition: A Situation where the correctness of the computation performed by co-operating processes can be affected by relative timing of the processes execution. Bounded use: a process only executes in its critical section for some indefinite time and may not terminate while in its critical section. Busy-waiting: The repeated execution of a loop of code while waiting for an event to occur; the CPU is not engaged in any real productive activity during this period, and the process does not progress toward completion.
FALSE TRUE TRUE TRUE FALSE

Remarks

ii) iii)

3 marks 5 marks

b)
i) ii) iii) iv) v)

c)

Note: this is an explicit explanation of the algorithm. A summarized version is acceptable. Bankers algorithm decides whether to grant a resource request. Assuming the following data structures: n: integer # of processes m: integer # of resources available[1..m] avail[i] is # of avail resources of type i max[1..n,1..m] max demand of each Pi for each Ri allocation[1..n,1..m] current allocation of resource Rj to Pi need[1..n,1..m] max # of resource Rj that Pi may still request Let request[i] be a vector of the #of instances of resource Rj that Process Pi wants. The Basic Algorithm: 1. If request[i] > need[i] then error (asked for too much) 2. If request[i] > available[i] then wait (cant supply it now) 3. Resources are available to satisfy the request: Lets assume that we satisfy the request. Then we would have: available = available - request[i] allocation[i] = allocation [i] + request[i] need[i] = need [i] - request [i] Now, check if this would leave us in a safe state; if yes, grant the request, if no, then leave the state as is and cause process to wait. Safety Check 1. free[1..m] = available ; how many resources are available finish[1..n] = false (for all i) ; none finished yet 2. Find an i s.t. finish[i]=false and need[i] <= work (find a proc that can complete its request now) if no such i exists, go to step 4 (were done) 3. Found an i: finish [i] = true ; done with this process free = free + allocation [i] (assume this process were to finish , and its allocation back to the available list) go to step 2 4. If finish[i] = true for all i, the system is safe.

1 mark

1 mark

2 marks

1 mark

Total

13 marks

COE 251

Marking scheme

Page 5 of 8

Question Four
Qn
a) i) ii) iii) iv) b) i)

Answer
Single relocatable partition X=Logical address; Y=physical address Addition (+) 14346

Remarks
4 marks

Free memory is maintained in linked lists, each of equal sized blocks. Any such block is of size 2^k. When some memory is required by a process, the block size of next higher order is chosen, and broken into two. Note that the two such pieces differ in address only in their kth bit. Such pieces are called buddies. When any used block is freed, the OS checks to see if its buddy is also free. If so, it is rejoined, and put into the original free-block linked-list.

4marks

ii) 1 mark for each correct allocation 4 marks

1mark The effect of the 25K process terminating is that the memory is occupies (32K) is 1mark added to the 32K free list. The memory cannot be merged at this point as the free memory next to it (its buddy) would only add up to 56K. It would need the returning of the 8K process to give 64K of memory to combine lists.

iii)

Total

13 marks

COE 251

Marking scheme

Page 6 of 8

Question Five
Qn
a)

Answer

Remarks

Pages are blocks of logical memory while segments divides a program into a 2 marks number of smaller blocks called segments The process has touched a page not currently in memory. Check an internal table for the target process to determine if the reference was valid (do this in hardware.) If page valid, but page not resident, try to get it from secondary storage. Find a free frame; a page of physical memory not currently in use. (may need to free up a page.) Schedule a disk operation to read the desired page into the newly allocated frame. When memory is filled, modify the page table to show the page is now resident. Restart the instruction that failed

b)

5 marks

c) i)

Before -,-,7,-,0,7,1,0,7 2,1,0 2,1,0 3,2,0 3,2,0 4,3,0 2,4,0 3,2,4 0,3,2 0,3,2 0,3,2 1,3,2 1,3,2 0,1,2 0,1,2 7,0,1 7,0,1

Page 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

Fault * * * * * * * * *

After 7,-,0,7,1,0,7 2,1,0 2,1,0 3,2,0 3,2,0 4,3,0 2,4,0 3,2,4 0,3,2 0,3,2 0,3,2

1 mark

1 mark

1 mark

* * *

1,3,2 1,3,2 0,1,2 0,1,2 7,0,1 7,0,1 7,0,1

1 mark

1 mark

ii)

12 faults

1 mark

Total

13 marks

COE 251

Marking scheme

Page 7 of 8

Question Six
Qn a) Answer Name Identifier (generally a number) Type Location (device: location) Size (bytes, words or blocks) Protection (rwx) Time, date, & user identification (creation, last modification, last use) There is a performance impact in using copy/delete as the entire file is copied. If you use rename then only the index entry has to be changed. If you copy a file you create a brand new file and some of the attributes will change (for example, date created). If you rename a file the, date created attribute, for example, would not be changed. Excessive copying of files can have unexpected consequences when repeated often. The most obvious is fragmentation. This occurs when a large file is split into smaller segments as there is not enough contiguous free space for the entire file. Remarks 4 points 2 marks

b)

1 mark 2 marks

2 marks

c) i)

203 The entire file must be relocated by one block. All 101 blocks would have to be 2 marks read and rewritten. Then the new block could be written. 1 Only the new block would have to be written 2 marks

ii)

iii)

100 The 50 blocks after the middle block would have to be read and then rewritten one 2 marks block earlier

Total

13 marks

COE 251

Marking scheme

Page 8 of 8

Question Seven
Qn a) Answer Remarks

As a computer deals with multiple processors over a period of time, a list of request to access the disk build up. The operating system uses a disk scheduling technique to determine which request to satisfy: Minimize
starvation and use hardware efficiently. b)

4 marks

Polling
The system interrogates each device in turn to determine if it is ready to communicate. a round-robin strategy No device has a particular advantage (like say a priority) over other devices Polling is quite commonly used by systems to interrogate ports on a network.

Interrupt driven
Program may initiate I/O request and advance without suspending its operation. The device raises an interrupt to seek communication Priority driven interrupt makes some devices to have priority over others Used to transfer data in Ethernets; in system timers, disks I/O, poweroff signals

3 marks

c)

6 marks

Total

13 marks

Das könnte Ihnen auch gefallen