Professional Documents
Culture Documents
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
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
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
3/9
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
4/9
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();
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);
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
P1 P2 P3
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
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
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