You are on page 1of 9

www.uobview.

com Uploaded By: Smart Error

UNIVERSITY OF BAHRAIN COLLEGE OF INFORMATION TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE


ITCS 322 Operating Systems FINAL EXAM
Semester I, 2008-2009 Time Allowed: 2 Hours

Name I.D. [1] [2] [3] [A] [A] Question 1 Question 2 Question 3 Question 4 Question 5 Question 6 TOTAL 06 12 15 20 18 09 80

Section

Please tick one

Notes: Please make sure that you write your FULL NAME, ID and Section number before you start the paper. Write your answers in the space provided for the purpose. The answers to all multiple choice questions should be written in the table given at the start of each question. You must switch off your mobile before starting the examination.

1/9

www.uobview.com Uploaded By: Smart Error

Question 1. [6 marks] CLO 1 Select the most appropriate answer. 1. Comparing time sharing systems and a single user PC, which of the following statement is correct? a. When there are few other users, the task is large, and the hardware is fast, time-sharing makes sense. b. A time sharing system is best when the job is small enough to be executed reasonably. c. A time sharing system is the best choice when there are multiple user who do not have to share recourses. d. All of the above are correct 2. With regard to client-server and peer-to-peer systems, which of the following is correct? a. In peer-to-peer model, all nodes in the system are considered equal and thus may act as either clients or servers b. In client-server model, a node may request a service from another node, or the node may in fact provide a service to other nodes in the system c. In client-server and peer-to-peer models, all the nodes must be connected through a network d. None of the above is correct 3. For handheld systems, the operating system needs to provide virtual memory, but does not need to provide time-sharing. a. True b. False 4. Which of the following are the main goal(s) today in the design of operating systems? a. Convenience for user b. efficient utilization of the computer resources c. Evolution d. All of the above 5. Which of the following feature is required in batch multiprogramming systems? a. CPU scheduling b. Memory management c. Allocation of devices d. On-line file system 6. Which of the following is/are correct with regard to multiprocessing? a. Symmetric multiprocessing treats all processors as equals, and I/O can be processed on any CPU. b. Asymmetric multiprocessing has one master CPU and the remainder CPUs are slaves c. In asymmetric multiprocessing, each processor runs an identical copy of the operating system d. In symmetric multiprocessing, the OS schedules processes/threads across all the processors i. All of the above are correct ii. Only (a) and (b) iii. Only (a), (b) and (c) iv. Only (a), (b) and (d)

2/9

www.uobview.com Uploaded By: Smart Error


Question 2 [6+6] CLO 2 Part 1. Select the most appropriate answers. 1. What will happen when a running process executes a privileged instruction? a. The process is blocked b. A trap to OS occurs c. The process is moved to suspend state d. The process will continue after the privileged instruction 2. Which of the following is NOT correct? a. User level thread switching does not require kernel mode privileges because all of the thread management data structures are within the user address space of a single process b. User level thread can run can run on any operating system c. Process preemption occurs when an executing process is interrupted by the processor so that another process can be executed d. An trap is due to some sort of event that is external to and independent of the currently running process, such as the completion of an I/O operation 3. Under which of the following conditions, a running process is terminated? a. The process attempts to execute a privileged instruction b. A process tries to use a resource (such as a file) that it is not allowed to use c. The process attempts to access a memory location outside its process address space d. The processes executes wait() system call i. All of the above ii. Only under conditions (a), and (b) iii. Only under conditions (a), (b) and (c) iv. Only under conditions (a), (c) and (d) 4. In which of the following data structure, an operating system maintains a pointer to the PCB of each process? a. Process descriptor b. Process table c. Ready queue d. Device queues 5. A process switch may occur under which of the following events? a. A process makes a system call b. A trap happens c. A running process is blocked d. A timer interrupt ilos generated i. All of the above ii. (a) and (b) iii. (a), (b) and (c) iv. (b), (c) and (d) 6. All the register values of a process are also known as context switching. a. True b. False

3/9

www.uobview.com Uploaded By: Smart Error


Answer:

Part 2. What are advantages of threads over processes? Explain your answer.

Question 3 CLO 3 [8+7] Part1 Consider an operating system uses multilevel feedback queue scheduling algorithm. The algorithm works as follows: There are 3 queues (Q0, Q1, Q2). Q0 has highest priority while Q2 has the lowest priority. Every new process is admitted to Q0. A round robin with a time quantum of 2 ms is used for Q0. A process is moved to Q1 only if it completes its time quantum (i.e. 2 ms) in Q0. Q1 uses round robin with time quantum 5 ms algorithm to select a process that should get the CPU. A process is moved to Q2 only if it completes its time quantum (i.e. 5 ms) in Q1. Q2 uses first come first server algorithm. Whenever the CPU becomes free, a process form Q0 is selected. If Q0 is empty, then a process from Q1 is selected. If both Q0 and Q1 are empty, then a process from Q2 is selected. If a new process arrives in a higher priority queue while the CPU is executing a process from a low level queue, the currently executing process is preempted and put at the front of the same queue and the new process from high level queue is selected. Process P1 P2 P3 P4 P5 Arrival time 0 1 3 9 13 CPU burst (ms) 2 8 12 3 3

Which processes will be in each queue at time 13?

4/9

www.uobview.com Uploaded By: Smart Error


Q Head

Q0

P5

Q1

P4

P3

Q2

P2

Part 2. Round robin algorithm does not suffer from starvation. Why? Also, what is the effect of having too large or too small time quantum on the performance of round robin algorithm? Answer Round robin does not suffer from starvation since 1) no process can monopolize the CPU and will be interrupted after it expire its time quantum and 2) no process waits more than (n-1)q time units until its next time quantum (n is number of processes in the queue and q is the time quantum). The performance of the RR depends heavily on the size of the time quantum. If the time quantum is very large, then RR policy is the same as FCFS policy and therefore suffers from the same disadvantages as FCFS (e.g. convoy effect). If the time quantum is very small then most of the CPU time will be spent on context switching. Generally speaking, turnaround time also depends on the time quantum. Question 4 [10+10 marks] CLO 4 Part 1 Select the most appropriate answer. 1. Which of the following algorithms have a busy wait? a. wait(s) critical section; signal(s); /* each semaphore s is
associated with a queue */ b. while (turn != i); critical section; turn = j; c. disable_int(); critical section enable_int();

d. All of the above

2. If wait(s) and signal(s) semaphore operations are not executed atomically, then mutual exclusion may be violated. a. True b. False 3. What will be the output if the following three processes are run concurrently? The initial value of both S1 and S2 is set to 0. wait(S1); cout << 1 wignal(S2); a. b. c. d. 123 321 312 213 5/9 wait(S2); cout << 2 signal(S2); cout << 3; signal(S1);

www.uobview.com Uploaded By: Smart Error


4. Disabling interrupts is one of the solutions for race condition problem. This solution works well on a multiprocessor system. a. True b. False 5. Which of the following is NOT correct? a. According to the mutual exclusion condition, if there is no process executing in its critical section and a process exists that wishes to enter the critical section, it should be allowed to do so b. The hardware solutions to critical section problem rely on some special hardware instructions c. The TestandSet instruction is an atomic instruction d. All of the above are not correct 6. Which of the following is correct about the software solutions to the race condition? a. They have a busy wait b. They work if a process fails inside the critical section c. They do not work if a process fails in the remainder section d. All of the above are correct 7. If there is only one instance of a resource type then the following resource allocation graph shows that there is a deadlock.

a. Yes Why: __Because there is a cycle __________ b. No Why: ______________________________________________ 8. If a process that is holding some resources requests another resource that cannot be immediately allocated to it, then all resources currently being held are released is an approach to deny which of the following condition? a. Circular wait b. No preemption c. Mutual exclusion d. Hold and wait 9. A process must give up all resources and then request all immediately needed is an approach to prevent hold and wait condition. What is the drawback of this approach? a. A process may not know required resources at start of run b. Low resource utilization c. Starvation is possible d. All of the above

6/9

www.uobview.com Uploaded By: Smart Error


Part 2 Assume that we have five processes from P1 through P5 and four different resource types R1 (3 instances), R2(3 instances), R3 (4 instances), and R4 (4 instances). State snapshot at time Ti is as follows: Process Allocation R1 R2 R3 1 0 2 1 1 1 0 1 0 Max R4 1 0 1 R1 3 2 2 R2 0 2 1 R3 2 2 3 R4 3 1 1 R1 1 0 2 0 3 1 3 Available Brief explanation

P1 P2 P3

R2 R3 R4 1 1 2 Initial 0 0 1 Given to P2 2 2 2 P2 completes 2 2 0 Given to P1 2 4 3 P1 completes 2 1 3 Given to P3 3 4 4 P2 completes

1. What is the need matrix? Write your answer in the table below. Process P1 P2 P3 R1 2 1 2 Need R2 R3 0 0 1 1 0 3 R4 2 1 0

2. Use Bankers algorithm to find out whether the above state is SAFE of not. You MUST show all your work in the available column of table 1 given above. Also explain each step in the last column of the table. You MUST select a process always by starting from the top of the list of incomplete processes. If the above state is a safe state, write the safe sequence; otherwise explain why the above state is not a safe state.
Safe sequence: P2, P1, P3 Question 5 [10+9 marks] CLO 5 Part 1 Select the most appropriate answers. 1. An absolute code can be loaded into anywhere in the memory. a. True b. False 2. The hardware that translates logical address into physical address is known as a. Address translator b. Address-mapper c. Memory management unit d. Memory addressing unit 3. In Linux/Unix, it is possible for the link editor to combine relocatable object modules created from compilers for different programming languages. a. True b. False

7/9

www.uobview.com Uploaded By: Smart Error

4. The fixed-size multiple partition allocation provides better memory utilization as compared to MVT. a. True b. False 5. Assume there are three holes of sizes 3K, 10 K and 7K. If we want to load a process of 12 K, then there will be internal fragmentation. a. True b. False 6. Assume a system is using paging technique with a frame size of 1K. The free frame list contains 2 5 1 6. In which frames the process with a size of 6K will be loaded? a. Frame 2, 5, and 1 b. Frame 2, 5, 1, and 6 c. Frame 6, 1, 5, and 2 d. None of the above 7. Assume that we have a total memory of 10 frames. There are 8 pages loaded into the memory. The system uses first come first out algorithm. If a page fault is generated, then a. The page that was loaded first should be replaced b. No page replacement is required c. The processes should be aborted/terminated d. A page that has not been updated should be swapped out. 8. Consider a system uses 16-bit logical address with a page size of 1024 bytes. If the logical address is 0000110000000011, what will be the physical address if the page table for the process is given below [2 marks] 11 02 21 15 16 a. b. c. d. 30723 15363 21507 None of above

9. Consider the following segment table for a process Base 100 6400 9000 1000 Limit 400 1000 256 128

What will be the physical address if the logical address is (1,60)? a. 6460 b. 160 c. 1060 d. A trap will happen

8/9

www.uobview.com Uploaded By: Smart Error


Part 2 Assume a virtual memory system. There are total 3 frames. The reference string is as follows: 7, 1, 4, 9, 6, 1, 7, 1, 2, 5, 9, 7, 1, 6 Determine the number of page faults using least recently used page replacement strategy. Show graphically the page replacement process, step by step. 7 0 1 2 7 1 7 1 4 7 1 4 9 9 1 4 6 9 6 4 4 9 1 9 1 4 4 1 3 3 1 4 4 1 6 6 1 4

Number of page faults: 8 ___________________ Question 6 [09] CLO 6 1. Discuss programmed I/O, interrupt driven I/O and DMA based I/O techniques. Which of these three have a busy wait? 2. Compare C-Scan and C-Look disk scheduling algorithm. Answer 1. In programmed I/O, I/O module performs the action, not the processor. Data transfer between memory and I/O device takes place through the CPU. The CPU cannot execute any other instruction while an I/O operation is in progress. After an I/O completes, the I/O controller sets the appropriate bits in the I/O status register. The processor keeps checking status until operation is complete. In an interrupt driven I/O, to start an I/O operation, the CPU loads the appropriate registers within the device controller. The device controller examines the contents of these registers and determines what action to take and then performs the action. The CPU is free to execute other instructions after executing the I/O instruction. However, an interrupt is raised when a data byte is to be transferred between the I/O device and the memory and the CPU executes an interrupt service routine which performs the transfer of the byte. In a DMA scheme, after setting up buffers, pointers, and counters for the I/O device by the CPU, the device controller transfers blocks of data from buffer storage directly to main memory and vice versa without CPU intervention. The DMA controller sends an interrupt when the whole block of data has been transferred. Programmed I/O is the only technique that has a busy wait. 2. In C-Scan, the head moves from one end of the disk to the other, servicing requests as it goes. When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip. C-Look is a version of C-Scan in which the arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk.

9/9

You might also like