2008-2009-1 solution

Upload: rks

Post on 05-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 2008-2009-1 Solution

    1/9

    www.uobview.com

    Uploaded By: Smart Error

    1/9

    UNIVERSITY OF BAHRAINCOLLEGE OF INFORMATION TECHNOLOGY

    DEPARTMENT OF COMPUTER SCIENCE

    ITCS 322 Operating Systems

    FINAL EXAM

    Semester I, 2008-2009

    Time Allowed: 2 Hours

    Name

    I.D.

    Section

    [1][2] Please tick one[3][A]

    Notes:

    Please make sure that you write your FULL NAME, ID and Section number before youstart the paper.

    Write your answers in the space provided for the purpose. The answers to allmultiple choice questions should be written in the table given at the start of eachquestion.

    You must switch off your mobile before starting the examination.

    Question 1 06

    Question 2 12

    Question 3 15

    Question 4 20

    Question 5 18

    Question 6 09

    TOTAL 80

  • 7/31/2019 2008-2009-1 Solution

    2/9

    www.uobview.com

    Uploaded By: Smart Error

    2/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 followingstatement is correct?

    a. When there are few other users, the task is large, and the hardware isfast, time-sharing makes sense.

    b. A time sharing system is best when the job is small enough to be executedreasonably.

    c. A time sharing system is the best choice when there are multiple user who donot have to share recourses.

    d. All of the above are correct2. 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 serversb. 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 connectedthrough a networkd. None of the above is correct

    3. For handheld systems, the operating system needs to provide virtual memory, butdoes not need to provide time-sharing.

    a. Trueb. False

    4. Which of the following are the main goal(s) today in the design of operating systems?a. Convenience for userb. efficient utilization of the computer resourcesc. Evolutiond. All of the above

    5. Which of the following feature is required in batch multiprogramming systems?a. CPU schedulingb. Memory managementc. Allocation of devicesd. 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 areslaves

    c. In asymmetric multiprocessing, each processor runs an identical copy of theoperating system

    d. In symmetric multiprocessing, the OS schedules processes/threads across allthe processors

    i. All of the above are correctii. Only (a) and (b)iii. Only (a), (b) and (c)iv. Only (a), (b) and (d)

  • 7/31/2019 2008-2009-1 Solution

    3/9

    www.uobview.com

    Uploaded By: Smart Error

    3/9

    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 blockedb. A trap to OS occursc. The process is moved to suspend stated. 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 addressspace of a single process

    b. User level thread can run can run on any operating systemc. Process preemption occurs when an executing process is interrupted by the

    processor so that another process can be executedd. 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 instructionb. A process tries to use a resource (such as a file) that it is not allowed to usec. The process attempts to access a memory location outside its process address

    spaced. The processes executes wait() system call

    i. All of the aboveii. 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 tothe PCB of each process?a. Process descriptorb. Process tablec. Ready queued. Device queues

    5. A process switch may occur under which of the following events?a. A process makes a system callb. A trap happensc. A running process is blockedd. A timer interrupt ilos generated

    i. All of the aboveii. (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. Trueb. False

  • 7/31/2019 2008-2009-1 Solution

    4/9

    www.uobview.com

    Uploaded By: Smart Error

    4/9

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

    Answer:

    Question 3 CLO 3 [8+7]

    Part1

    Consider an operating system uses multilevel feedback queue scheduling algorithm. Thealgorithm works as follows: There are 3 queues (Q0, Q1, Q2). Q0 has highest priority whileQ2 has the lowest priority. Every new process is admitted to Q0. A round robin with a timequantum of 2 ms is used for Q0. A process is moved to Q1 only if it completes its timequantum (i.e. 2 ms) in Q0. Q1 uses round robin with time quantum 5 ms algorithm to selecta process that should get the CPU. A process is moved to Q2 only if it completes its timequantum (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 aprocess from Q1 is selected. If both Q0 and Q1 are empty, then a process from Q2 isselected. If a new process arrives in a higher priority queue while the CPU is executing aprocess from a low level queue, the currently executing process is preempted and put atthe front of the same queue and the new process from high level queue is selected.

    Process Arrival time CPU burst(ms)

    P1 0 2

    P2 1 8

    P3 3 12P4 9 3

    P5 13 3

    Which processes will be in each queue at time 13?

  • 7/31/2019 2008-2009-1 Solution

    5/9

    www.uobview.com

    Uploaded By: Smart Error

    5/9

    Part 2.

    Round robin algorithm does not suffer from starvation. Why? Also, what is the effect ofhaving too large or too small time quantum on the performance of round robin algorithm?

    AnswerRound 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 morethan (n-1)q time units until its next time quantum (n is number of processes in the queueand q is the time quantum).

    The performance of the RR depends heavily on the size of the time quantum. If the timequantum is very large, then RR policy is the same as FCFS policy and therefore suffers fromthe same disadvantages as FCFS (e.g. convoy effect). If the time quantum is very smallthen 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 sectionenable_int();d. All of the above

    2. If wait(s) and signal(s) semaphore operations are not executed atomically, thenmutual exclusion may be violated.

    a. Trueb. False

    3. What will be the output if the following three processes are run concurrently? Theinitial value of both S1 and S2 is set to 0.

    wait(S1);cout

  • 7/31/2019 2008-2009-1 Solution

    6/9

    www.uobview.com

    Uploaded By: Smart Error

    6/9

    4. Disabling interrupts is one of the solutions for race condition problem. This solutionworks well on a multiprocessor system.

    a. Trueb. 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 enterthe critical section, it should be allowed to do so

    b. The hardware solutions to critical section problem rely on some specialhardware instructions

    c. The TestandSet instruction is an atomic instructiond. 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 waitb. They work if a process fails inside the critical sectionc.

    They do not work if a process fails in the remainder sectiond. All of the above are correct

    7. If there is only one instance of a resource type then the following resource allocationgraph 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 cannotbe immediately allocated to it, then all resources currently being held are releasedis an approach to deny which of the following condition?

    a. Circular waitb. No preemptionc. Mutual exclusiond. Hold and wait

    9. A process must give up all resources and then request all immediately needed is anapproach to prevent hold and wait condition. What is the drawback of this approach?

    a. A process may not know required resources at start of runb. Low resource utilizationc. Starvation is possibled. All of the above

  • 7/31/2019 2008-2009-1 Solution

    7/9

    www.uobview.com

    Uploaded By: Smart Error

    7/9

    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 timeTi is as follows:

    ProcessAllocation

    Max Available Brief explanation

    R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4P1 1 0 2 1 3 0 2 3 1 1 1 2 Initial

    P2 1 1 1 0 2 2 2 1 0 0 0 1 Given to P2

    P3 0 1 0 1 2 1 3 1 2 2 2 2 P2 completes

    0 2 2 0 Given to P13 2 4 3 P1 completes

    1 2 1 3 Given to P3

    3 3 4 4 P2 completes

    1. What is the need matrix? Write your answer in the table below.Process Need

    R1 R2 R3 R4P1 2 0 0 2

    P2 1 1 1 1

    P3 2 0 3 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 aprocess always by starting from the top of the list of incomplete processes. Ifthe above state is a safe state, write the safe sequence; otherwise explainwhy the above state is not a safe state.

    Safe sequence: P2, P1, P3

    Question 5 [10+9 marks] CLO 5Part 1 Select the most appropriate answers.

    1. An absolute code can be loaded into anywhere in the memory.a. Trueb. False

    2. The hardware that translates logical address into physical address is known asa. Address translatorb. Address-mapperc. Memory management unitd. Memory addressing unit

    3. In Linux/Unix, it is possible for the link editor to combine relocatable objectmodules created from compilers for different programming languages.

    a. Trueb. False

  • 7/31/2019 2008-2009-1 Solution

    8/9

    www.uobview.com

    Uploaded By: Smart Error

    8/9

    4. The fixed-size multiple partition allocation provides better memory utilization ascompared to MVT.

    a. Trueb. False

    5. Assume there are three holes of sizes 3K, 10 K and 7K. If we want to load a processof 12 K, then there will be internal fragmentation.

    a. Trueb. False

    6. Assume a system is using paging technique with a frame size of 1K. The free framelist contains 2 5 1 6. In which frames the process with a size of 6K will be loaded?

    a. Frame 2, 5, and 1b. Frame 2, 5, 1, and 6c. Frame 6, 1, 5, and 2d. None of the above

    7. Assume that we have a total memory of 10 frames. There are 8 pages loaded intothe memory. The system uses first come first out algorithm. If a page fault isgenerated, then

    a. The page that was loaded first should be replacedb. No page replacement is requiredc. The processes should be aborted/terminatedd. 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 thelogical address is 0000110000000011, what will be the physical address if the pagetable for the process is given below [2 marks]

    11

    0221

    15

    16

    a. 30723b. 15363c. 21507d. None of above

    9. Consider the following segment table for a processBase Limit

    100 4006400 1000

    9000 256

    1000 128

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

  • 7/31/2019 2008-2009-1 Solution

    9/9

    www.uobview.com

    Uploaded By: Smart Error

    9/9

    Part 2

    Assume a virtual memory system. There are total 3 frames. The reference string is asfollows:

    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 1 4 9 6 4 9 1 4 1 3 4 1 6

    0 7 7 7 9 9 9 3 6

    1 1 1 1 6 1 1 1

    2 4 4 4 4 4 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. Whichof these three have a busy wait?

    2. Compare C-Scan and C-Look disk scheduling algorithm.Answer1. In programmed I/O, I/O module performs the action, not the processor. Data transferbetween memory and I/O device takes place through the CPU. The CPU cannot execute anyother instruction while an I/O operation is in progress. After an I/O completes, the I/Ocontroller sets the appropriate bits in the I/O status register. The processor keeps checkingstatus until operation is complete. In an interrupt driven I/O, to start an I/O operation, theCPU loads the appropriate registers within the device controller. The device controllerexamines the contents of these registers and determines what action to take and thenperforms the action. The CPU is free to execute other instructions after executing the I/Oinstruction. However, an interrupt is raised when a data byte is to be transferred betweenthe I/O device and the memory and the CPU executes an interrupt service routine whichperforms the transfer of the byte. In a DMA scheme, after setting up buffers, pointers, andcounters 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 DMAcontroller 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 itgoes. When it reaches the other end, however, it immediately returns to the beginning ofthe disk, without servicing any requests on the return trip. C-Look is a version of C-Scan inwhich the arm only goes as far as the last request in each direction, then reverses directionimmediately, without first going all the way to the end of the disk.