CSC520 - Test 1 - Answer Scheme

Embed Size (px)

Citation preview

  • 7/22/2019 CSC520 - Test 1 - Answer Scheme

    1/3

    FSKM/CTN/CSC520/ADORAENDUT/MAY2011/TEST1

    1Name: Stud Id

    CSC520 PRINCIPLES OF OPERATING SYSTEMS

    TETS 1

    PART A (30 MARKS)

    1. Briefly explain TWO (2)main responsibilities of the operating system.(4 marks)

    The OS provides standard facilities such as file systems, standard libraries, graphical interfaces, etc 2 m

    The OS provides the illusion of a dedicated machine with infinite memory and CPU 2 m

    protecting users from each other, allocating resources efficiently and fairly, and providing secure and safe communication 2 m

    Or any suitable answer

    2. What is the timer interrupt? How does the OS use it for scheduling?The timer interrupt is an interval timer device which produces an interrupt whenever the timer expires. The OS uses the timer interrupt

    to force periodic interrupts of any process execution, particularly in an involuntary CPU sharing environment. In this way, even though

    a particular process is executing an infinite loop, it cannot block other processes from running

    (4 marks)

    3. Briefly explain the characteristics of a distributed computing.Distribute computations among several processors in several locations 2 m

    A loosely coupled system 2 m

    Each processor has its own local memory, bus & clock 2 m

    Any two or any suitable answer

    (4 marks)

    4. What is the mode bit used for?A flag, usually in hardware, that selects between two modes of operation: user mode and kernel/supervisor mode. The mode bit act as

    a mechanism by which a process does not interfere with others currently using the machine.

    (2 marks)

    5. The most critical part of the Operating System is a kernel. Briefly explain how to implement the kernel.Monolithic kernelAll software and data structures are placed in one logical module with no explicit interface between any parts of

    OS software

    Modular/Hybrid kernelFunctionality is partitioned among logically independent components with well-defined interfaces among

    the related modules. It is easier to maintain and modify

    MicrokernelThe near-minimum amount of software that can provide the mechanisms needed to implement and OS. Traditional

    kernel tasks are removed from the kernel to run in user space

    (4 marks)

    6. Briefly explain TWO (2)main types of resources.Reusable resourceResources that can be allocated and later returned to the system after the process has finished using them. Thesystem always has a fixed, finite number of units of reusable resource

    Consumable resourceResources that can be allocated but that is never subsequently released. The number of units of a consumable

    resource is unbounded

    (4 marks)

    7. Shortest Job Next is a form of optimal CPU scheduling algorithm. Explain why it is not used in real operating systems.Main problem: starvation of large threads

    (4 marks)

    8. Briefly explain why Operating Systems are interrupt-driven.Since hardware has a slower speed than CPU, a mechanism is needed to notify the CPU when a particular hardware device becomes

    ready for service, rather than require the CPU to poll repeatedly for an I/O completion. In this manner, the CPU can increase its degree

    of multiprogramming by executing another program while the first program is blocked waiting for an I/O completion.

    (4 marks)

    PART B (45 MARKS)

    1. Given the following diagram:

    a. What are the entities represented by A and B?ACPU

    BWait queue

  • 7/22/2019 CSC520 - Test 1 - Answer Scheme

    2/3

    FSKM/CTN/CSC520/ADORAENDUT/MAY2011/TEST1

    2Name: Stud Id

    (2 marks)

    b. Name the action shown in C and D.CSwap out

    DSwap in

    (2 marks)

    c. The actions taken in C and D are controlled by a scheduler. Name the scheduler.Medium-term Scheduler

    (1 marks)

    d. Name the scheduler responsible for the transition from the Ready Queue to A and briefly describe one of its functions.CPU scheduler chooses one of the ready threads to use the CPU.

    Enqueuer component of CPU scheduler places a pointer to the descriptor into a list of processes that are waiting for the CPU.

    The context switcher component saves the contents of all CPU registers for the thread being removed from the CPU in its

    descriptor

    The Dispatcher component selects one of the ready threads from the ready list & then allocates the CPU to that thread

    (3 marks)

    2. Given the following information:PROCESS BURST TIME ARRIVAL TIME PRIORITY NO

    A 6 0 3

    B 7 3 1

    C 4 5 2D 3 9 4

    E 8 12 3

    F 2 15 2

    a. Draw the Gantt Chart for the following scheduling algorithms:i. Priority

    ii. Round Robin (time quantum = 4)

    iii. Shortest Job Next

    (12 marks)

    b. Calculate the turnaround time and waiting time for processes Aand Din each of the above scheduling algorithms.Priority RR SJN

    Trnd(A) = 60 = 6

    Wait(A) = 0

    Trnd(D) = 309 = 21

    Wait(D) = 279 = 18

    Trnd(A) = 230 = 23

    Wait(A) = 214 = 17

    Trnd(D) = 159 = 6

    Wait(D) = 129 = 3

    Trnd(A) = 60 = 6

    Wait(A) = 0

    Trnd(D) = 139 = 4

    Wait(D) = 109 = 1

    (6 marks)

    c. Calculate the average waiting time for all the processes in each of the above scheduling algorithms.Priority RR SJN

    Wait(A) = 0

    Wait(B) = 63 = 3

    Wait(C) = 135 = 8

    Wait(D) = 279 = 18

    Wait(E) = 1912 = 7Wait(F) = 1715 = 2

    Avg = (0+3+8+18+7+2)/6 = 6.33

    Wait(A) = 17

    Wait(B) = 1 + 15 = 16

    Wait(C) = 3

    Wait(D) = 3

    Wait(E) = 3 + 7 = 10Wait(F) = 4

    Avg = (17+16+3+3+10+4)/6 = 8.83

    Wait(A) = 0

    Wait(B) = 10

    Wait(C) = 1

    Wait(D) = 1

    Wait(E) = 10Wait(F) = 5

    Avg = (0+10+1+1+10+5)/6 = 4.5

    (9 marks)

    d. What is the effect of increasing the time quantum to a very large number for Round Robin scheduling?RR converges to FCFS scheduling since every job has its entire need met the first time it receives a time quantum.

    A B C F E D

    0 6 13 17 19 27 30

    A

    0 4

    B

    8

    C

    12

    D

    15

    E

    19

    F

    21

    A

    23

    B

    26

    E

    30

    A

    0 6

    C

    10

    D

    13

    B

    20

    F

    22

    E

    30

  • 7/22/2019 CSC520 - Test 1 - Answer Scheme

    3/3

    FSKM/CTN/CSC520/ADORAENDUT/MAY2011/TEST1

    3Name: Stud Id

    (4 marks)

    3. Explain TWO (2) methods by which a program in user mode can request the services of the operating system.Two techniques by which program in user mode can request kernels services:

    System callA system call is how a program requests a service from an operating system's kernel that it does not normally have

    permission to run. System calls provide the interface between a process and the operating system. Most operations interacting with

    the system require permissions not available to a user level process, e.g. I/O performed with a device present on the system, or any

    form of communication with other processes requires the use of system calls

    Message passingIn this model, processes or objects can send and receive messages (comprising zero or more bytes, complex data

    structures, or even segments of code) to other processes. By waiting for messages, processes can also synchronize.

    (6 marks)