Operating Systems Exam - CS 220

University of Dodoma
College of Informatics and Virtual Education
School of Informatics

Undergraduate University Examinations
Second Semester 2018/2019
CS 220: Operating Systems

Date: 1st July, 2019
Time Allocated: 3 Hours


Instructions:

  1. This question paper consists of seven questions.
  2. Answer all questions in Section A and any three questions in Section B.
  3. All University of Dodoma examination regulations apply.

SECTION A (40 Marks)

Question One

Select the letter with the most correct answer
(1 Mark Each)

  1. Disk scheduling includes deciding
    a. which should be accessed next
    b. order in which disk access requests must be serviced
    c. the physical location of the file
    d. the logical location of the file

  2. What does Belady’s Anomaly relate to?
    a. Page Replacement Algorithm
    b. Memory Management Algorithm
    c. Deadlock Prevention Algorithm
    d. Disk Scheduling Algorithm

  3. What are the two types of Semaphore?
    a. Digital Semaphores and Binary Semaphores
    b. Analog Semaphores and Octal Semaphores
    c. Counting Semaphores and Binary Semaphores
    d. Critical Semaphores and System Semaphores

  4. Which of the following is the allocation method of a disk space?
    a. Contiguous allocation
    b. Linked allocation
    c. Indexed allocation
    d. All of the above

  5. Which of the following concept is best to preventing page faults?
    a. Paging
    b. The working set
    c. Hit ratios
    d. Address location resolution

  6. An I/O bound program will typically have:
    a. a few very short CPU bursts
    b. many very short I/O bursts
    c. many very short CPU bursts
    d. a few very short I/O bursts

  7. Size of virtual memory depends on
    a. size of data bus
    b. size of address bus
    c. size of main memory
    d. none of above

  8. Physical memory is broken into fixed-sized blocks called ______.
    a. Frames
    b. Pages
    c. backing store
    d. None of the above

  9. In contiguous memory allocation:
    a. each process is contained in a single contiguous section of memory
    b. all processes are contained in a single contiguous section of memory
    c. the memory space is contiguous
    d. None of the above

  10. In indexed allocation:
    a. each file must occupy a set of contiguous blocks on the disk
    b. each file is a linked list of disk blocks
    c. all the pointers to scattered blocks are placed together in one location
    d. None of the above


Question Two

Carefully read the following and write TRUE for the correct sentence and FALSE for the incorrect sentence.
(1 Mark Each)

  1. The TestAndSet instruction is executed periodically.
  2. The resource allocation graph is not applicable to a resource allocation system with a single instance of each resource type.
  3. In the LOOK algorithm, the disk arm starts at one end of the disk and moves toward the other end, servicing requests till the other end of the disk. At the other end, the direction is reversed and servicing continues.
  4. Multiprocessor systems contain two or more processors that share physical memory and peripheral devices.
  5. Security measures control the access of processes or users to the resources made available by the computer system.
  6. Protection measures are responsible for defending a computer system from external or internal attacks.
  7. In batch operating system, the response time is very crucial.
  8. A page fault occurs when the Deadlock happens
  9. Several data structures that are fundamental to computer science are widely used in operating systems, including lists, stacks, queues, trees, hash functions, maps, and bitmaps.
  10. Virtual memory is commonly implemented by demand paging.

Question Three

(5 Marks Each)

  1. Is busy waiting always less efficient (in terms of using processor time) than a blocking wait? Explain.

  2. Why is multiprogramming central to the operation of a modern operating system?

  3. Consider a logical address space of 256 pages with a 4-KB page size, mapped onto a physical memory of 64 frames. a. How many bits are required in the logical address? b. How many bits are required in the physical address?

  4. How can the hold-and-wait condition be prevented?
    By requiring that a process request all its required resources at one time and blocking the process until all requests can be granted simultaneously.


Question Four

  1. Consider the following snapshot of a system:
ProcessAllocation (A B C D)Max (A B C D)Available (A B C D)
P02 0 0 14 2 1 23 3 2 1
P13 1 2 15 2 5 2
P22 1 0 32 3 1 6
P31 3 1 21 4 2 4
P41 4 3 23 6 6 5

Answer the following questions using the banker’s algorithm: a. Illustrate that the system is in a safe state by demonstrating an order in which the processes may complete. (3 Marks) b. If a request from process ( P_1 ) arrives for (1, 1, 0, 0), can the request be granted immediately? (3 Marks) c. If a request from process ( P_4 ) arrives for (0, 0, 2, 0), can the request be granted immediately? (4 Marks)

  1. Using any high-level programming language, implement the banker’s algorithm. (10 Marks)

SECTION B

Question Five

  1. Consider the following set of processes, with the length of the CPU burst given in milliseconds:
ProcessBurst TimePriorityArrival Time
P12 (4)20 (4)
P2111
P38 (-6)(9)42 c
P44 (12)23
P55 (-3)(11)34

a. Draw four Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: preemptive SJF, nonpreemptive priority (a larger priority number implies a higher priority), and RR (quantum = 2). (3 Marks)

b. What is the turnaround time of each process for each of the scheduling algorithms in part a? (3 Marks)

c. What is the waiting time of each process for each of these scheduling algorithms? (4 Marks)

  1. Using any high-level programming language, implement the First Come First Served CPU scheduling algorithm. (10 Marks)

Question Six

  1. Suppose that a disk drive has 5,000 cylinders, numbered 0 to 4,999. The drive is currently serving a request at cylinder 143, and the previous request was at cylinder 125. The queue of pending requests, in FIFO order, is: 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130. Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requests for each of the following disk-scheduling algorithms?

a. SSTF (5 Marks)
b. SCAN (5 Marks)

  1. Write a program that implements the SCAN disk-scheduling algorithm. Your program will service a disk with 5,000 cylinders numbered 0 to 4,999. The program will generate a random series of 1,000 cylinder requests and service them according to each of the algorithms listed above. The program will be passed the initial position of the disk head (as a parameter on the command line) and report the total amount of head movement required by each algorithm. (10 Marks)

Question Seven

Consider the following page reference string:
7, 2, 3, 1, 2, 5, 3, 4, 6, 7, 7, 1, 0, 5, 4, 6, 2, 3, 0, 1

  1. Assuming demand paging with three frames, how many page faults would occur for the following replacement algorithms?

a. LRU replacement (3 Marks)
b. FIFO replacement (3 Marks)
c. Optimal replacement (4 Marks)

  1. Given six memory partitions of: 10 KB, 20 KB, 18 KB, 9 KB, 12 KB, and 15 KB (in order), how would the first-fit, best-fit, and worst-fit algorithms place processes of size 12 KB, 10 KB, 9 KB, and 15 KB (in order)? Rank the algorithms in terms of how efficiently they use memory. (10 Marks)

END OF EXAMINATION