CSCE 451/851 Operating Systems Principles

Fall 1999
Steve Goddard

Homework 4/Study Aid

 

Due: never; this assignment need not be handed in.

However, your final will include at least one question from this assignment.

  1. Consider the following sequence of memory references from a 460-byte program:
  2. 10, 11, 104, 170, 73, 309, 185, 245, 246, 434, 458, 364.

    a) Give the reference string, assuming a page size of 100 bytes.

    b) Find the page-fault rate for the reference string in part a, assuming 200 bytes of primary memory available to the program and a FIFO replacement algorithm.

    c) Calculate what the page-fault rate would be if you used an LRU replacement algorithm.

    d) Determine what the page-fault rate would be for the optimal replacement algorithm.

     

  3. Consider the following segment table:
  4. Segment

    Base

    Length

    0

    219

    600

    1

    2300

    14

    2

    90

    100

    3

    1327

    580

    4

    1952

    96

    What are the physical addresses for logical addresses (0,430), (1,10), (1,11), (2,500), (3,400), and (4,112)?

     

  5. Why are segmentation and paging sometimes combined into one scheme?
  6.  

  7. Consider a file currently consisting of 100 blocks. Assume that the file-control block (an index block in the case of indexed allocation) is already in memory. Calculate how many disk I/O operations are required for contiguous, linked, and indexed (single-level) allocation strategies, if, for one block, the following hold:
  8. (In the contiguous-allocation case, assume that there is no room to grow in the beginning, but there is room to grow in the end. Assume that the block information to be added is stored in memory.)

    a) The block is added at the beginning.

    b) The block is added in the middle.

    c) The block is added at the end.

    d) The block is removed from the beginning.

    e) The block is removed from the middle.

    f) The block is removed from the end.

     

  9. When the average queue length is small, all disk-scheduling algorithms reduce to FCFS scheduling. Explain why this is true.
  10.  

  11. From a user’s perspective, what are the ramifications of adopting a free space allocation scheme for secondary storage based on a simple linked list of free blocks?
  12.  

  13. Much of secondary storage management is driven by the desire to reduce the impact of high seek times. As disks become smaller and smaller the physical distance a head must travel between tracks is also becoming smaller and smaller. Soon it will be the case that the limiting factor in the performance of a disk will be the rotational latency and not the average seek time. Discuss the impact of this event on the design and implementation of secondary storage management systems.
  14. UNIX is famous for not providing any general synchronization primitive such as semaphores. Years ago, when asked about this, Dennis Ritchie, one the original developers of UNIX said that if someone wanted semaphores, they could build binary semaphores using the file system. Specifically, he claimed that one could use a file as binary semaphore and use the create() and unlink() system calls to implement the up() and down() semaphore operations.

These system calls behave as follows:

int create(name) — this creates a file with the given name in the current working directory and returns an integer status code. If the return value is 0 then the create operation succeeded, if the value is -1, then the create operation failed. The operation can fail because a file with the same name already exists in the current working directory or if a disk I/O error occurs during the create operation.

int unlink(name) — this deletes a file with the given name from the current workingdirectory. (It’s called unlink because it "unlinks" the file’s i-node from the current working directory.) Like create(), an integer status code is returned. If the return value is 0 then the unlink operation succeeded, if the value is -1, then the operation failed. The unlink can fail because no file with the given name exists in the current working directory or if a disk I/O error occurs during the operation.

a) Show how a binary semaphore can be implemented with the create() and unlink() system calls.

  1. What property(s) must (the implementation of) these file system system calls have to have in order for your up() and down() operations to work correctly? Explain.

  1. Consider the concept of cylinder groups for file allocation.
  2. a) Explain the concept of file allocation based on cylinder groups?

    b) Why are cylinder groups a good idea?

    c) Prior to the use of cylinder groups, files were allocated (more or less) at random places on the disk. Compared with this scheme, are cylinder groups better or worse for storing: (explain your answers)

    • small files (e.g., a simple e-mail message)

    • medium size files (e.g., the source code for a program)

    • very large files (e.g., an uncompressed, color image)

  3. None of the disk-scheduling disciplines we covered, except FCFS, are truly fair (starvation may occur).

  1. Explain why this assertion is true.
  2. Describe a way to modify algorithms such as SCAN and SSTF to ensure fairness.
  3. Explain why fairness is an important goal in a time-sharing system.
  4. Give two examples of circumstances in which it is important that the operating system be unfair in serving I/O requests.