pop up description layer
Last modified: 20070925:123207/copied from cse2302 document with very minor changes

FIT2022 AJH-2007-xx

CSE2302 Examination 2001

  1. Answer all questions
  2. All questions are of equal value: marks for each question part shown

SECTION A - Multiple Choice (20 marks - 1 mark per question)

In the following multiple choice questions, more than one choice may be correct. Circle all correct answers. Full marks will be given where all correct answers are circled. Marks will be deducted within each question for incorrect answers.

  1. Steps in handling a page fault may include
    1. restarting the instruction once the missing page is in memory
    2. update page table
    3. obtaining a free frame (with or without invoking the page replace algorithm)
    4. swapping the current process
    5. none of the above
  2. A multiprogramming operating system
    1. requires a memory management system
    2. allows CPU scheduling
    3. improves system utilization
    4. manages system resources
    5. none of the above
  3. Privileged instructions
    1. can only be executed in monitor (supervisor) mode
    2. include the instruction to return from an interrupt
    3. include the instruction to change the limit register of memory protection system
    4. always update the memory base register
    5. none of the above
  4. An operating system has a least recently used page replacement algorithm and a fixed allocation of 3 frames per process, where frames are assumed to be initially empty. . How many page faults would occur for a process with a page reference string of 1, 2, 1, 5, 3, 4, 1, 6
    1. 4
    2. 5
    3. 6
    4. 7
    5. 8
  5. In the implementation of a file system, two choices are to use a tree structured directory, or an acyclic graph directory. The difference between these two choices is that
    1. the tree is more flexible than the acyclic graph
    2. the tree does not have a root directory
    3. the tree prohibits the sharing of files or directories
    4. the tree doesn't allow users to access the files of other users
    5. none of the above
  6. The short term scheduler
    1. selects from processes that are ready to execute and loads them into memory for execution
    2. executes more frequently compared to the long term scheduler
    3. controls the degree of multiprogramming
    4. needs to select between I/O bound or CPU bound processes
    5. does none of the above
  7. Chained allocation of disk blocks in a file system
    1. uses a pointer in each block to the next block in the chain
    2. needs just a single entry for each file
    3. is an allocation on an individual block basis
    4. does not accommodate for the principle of locality
    5. is none of the above
  8. A nonmaskable interrupt
    1. is reserved for events such as unrecoverable memory errors
    2. can be turned off by the CPU before the execution of critical instruction sequences that must not be interrupted
    3. is used by device controllers to request service
    4. is a software interrupt
    5. does none of the above
  9. Dispatch latency refers to
    1. the time it takes for the dispatcher to load and start a waiting process
    2. the time it takes for the dispatcher to switch between processes
    3. the time it takes for the dispatcher to complete the executing of a running process
    4. the time it takes for the dispatcher to terminate a completed process
    5. none of the above
  10. Which of the following disk scheduling algorithms perform better on average for systems that place a heavy load on the disk?
    1. FCFS
    2. SSTF
    3. LOOK (accept either or both for full marks)
    4. C-SCAN (accept either or both for full marks)
    5. none of the above
  11. The earliest point at which address bindings in a program can be made is
    1. edit time
    2. compile time
    3. load time
    4. link time
    5. execution time
  12. A physical address is an address that under all circumstances is
    1. compiled into a program
    2. issued by the CPU
    3. accepted by memory
    4. translated by a memory management unit
    5. none of the above
  13. Internal fragmentation can be avoided by
    1. not using any memory management at all
    2. making the unit of memory allocation a single word
    3. memory management by segmentation
    4. rounding memory requests up to the unit of memory allocation
    5. none of the above
  14. Virtual memory can be implemented by
    1. demand paging
    2. demand segmentation
    3. swapping
    4. page replacement
    5. none of the above
  15. Page replacement algorithms are designed to
    1. reduce the size of memory
    2. increase the memory efficiency
    3. reduce the page fault rate
    4. increase process throughput
    5. none of the above
  16. Program locality is a concept that
    1. relieves thrashing
    2. allows the "working set window" to be optimised
    3. relies on dirty bits
    4. improves the swapping rate
    5. none of the above
  17. Pre-emptive scheduling may occur whenever the processor state
    1. is running (acceptable/omittable without penalty)
    2. is waiting
    3. transfers into the wait state
    4. transfers into the ready state
    5. transfers out of the running state (must have this choice)
  18. A monitor is a high level programming construct designed to ensure
    1. mutual exclusion
    2. circular waiting
    3. spin locking
    4. blocking
    5. none of the above
  19. Which of the following conditions is NOT required for deadlock to occur?
    1. mutual exclusion
    2. hold and wait
    3. bounded wait
    4. circular wait
    5. no pre-emption
  20. Which of the following attributes does NOT represent a security threat?
    1. Trojan Horse
    2. Microsoft Outlook
    3. Trap Door
    4. Internet Worm
    5. Internet Spider

SECTION B - Answer all questions

  1. Santa Claus sleeps in his shop at the North Pole and can only be wakened by either

    To allow Santa to get some sleep, the elves can only wake him when three of them have problems. When three elves are having their problems solved, any other elves wishing to visit Santa must wait for those elves to return.

    If Santa wakes up to find three elves waiting at his shop's door, and the last reindeer has returned from the tropics, Santa has decided that the elves must wait until after Christmas, because it is more important to get the sleigh ready. (It is assumed that the reindeer don't want to leave the tropics, and therefore they stay there until the last possible moment.)

    The last reindeer to arrive must wake up Santa while the others wait in a warming hut before being harnessed to the sleigh.

    Write a suite of synchronized processes that will solve this problem. You may use any programming language you prefer, including pseudo code, and you must show the design and development of your solution. Python solutions will attract a bonus mark. (20+ marks)

    Solution

    I solved this problem by writing a process skeleton for each active participant type, and then adding the synchronization and mutual exclusion semaphores. Finally the appropriate initializations were added.

    Santa Outline: (one only instance) 5 total

    while (TRUE) do    wait(WakeSanta) 1 for loop forever in each process; OR, identification of process set    if (reindeer at door) then 1 for test on why woken        1 for handling reindeer        check that reindeer has rousted other reindeer         ready sleigh        deliver toys    else 1 for handling elves        for (each elf) do 1 for remembering there's 3 of them            solve problem            send back to work        end for    end ifend while

    Reindeer Outline: (one instance per reindeer, i.e., nine instances) 5 total

    while (TRUE) do see Santa    while(not Dec. 24 and not tired of South Pacific) do        vacation in South Pacific    end while 1 for non-synchronized stuff    return to North Pole    if last reindeer to return then 1 for last reindeer test        for (each reindeer in warming hut) do            signal(AllReindeerPresent) 1 for rousting other reindeer        end do        signal(WakeSanta) 1 for signalling wake up    else        # wait in warming hut        wait(AllReindeerPresent) 1 for handling not last reindeer    end if    hook up to sleigh    fly Santa around world    return to South Pacificend while

    Elf Outline: (one instance per elf; arbitrarily many) 8 total

    while (TRUE) do see Santa    while (no problem) do 1 for non--synchronized stuff        build toy    end while    wait(mutex); problemElfCount++; signal(mutex) 1 for mutex    if problemElfCount < 3        wait(NeedMoreElves)  1 for less than 3 need to wait    else if problemElfCount >= 3 then        # gather other 2 elves with problems         signal(NeedMoreElves); signal(NeedMoreElves);  1 for gathering 3 elves        wait(mutex); problemElfCount -= 3; signal(mutex) 1 for mutex    end if    # if a group of elves off to see Santa    #    have your group wait    wait(ElvesGroupFinished) 1 for only 1 group at a time    # this group OK to go    signal(WakeSanta) 1 for signalling wake up    see Santa    # On returning, send another group of elves if there is one waiting    signal(ElvesGroupFinished) 1 for releasing next groupend while

    Initialization 2 total

    semaphore mutex = 1 1 for correct initializations; OR identification of event setsemaphore WakeSanta = 0semaphore AllReindeerPresent = 0semaphore NeedMoreElves = 0semaphore ElvesGroupFinished = 1 1 for correct semaphores; OR identification of variable set
    1 bonus mark if solution presented in Python. Either Exact syntax, or extensive class description (e.g., __init__ and/or run definitions, etc., required for this mark!

    Be lenient in the interpretation of these statements. For example, if a student correctly identifies that each of the elves and reindeer processes has a "wakeup Santa" requirement, then award the mark for this, even if not correctly coded.

    1. Explain what reference semantics are, and why programmers of a real operating system might avoid using a language that has reference semantics as its default semantics. (5 marks)

      Solution

      RS require that objects are identified by a reference to them, rather than their actual value. Usually the term "reference semantics" does not require this regime to be applied to scalar values as well (for efficiency reasons), but this may be the case, particularly for stylised use. RS mean that when objects are passed around by their references, alterations to the object are propogated and seen by other contects also holding a reference to the same object. 1 mark for basic definition, 2 more for depth of discussion OSs are not likely to use RS, since value semantics are usually required anyway, RS requires more sophisticated memory management (garbage collection), and a higher level of run-time support. 1 mark for each argument to a max of 2

    2. Draw a diagram that shows 3 user-level processes labelled U1, U2, U3 running, together with the operating system OS process and a disk controller D, and show on your diagram the control flow transfers when user level process U2 invokes a blocking read from disk D. (5 marks)

      Solution

      A diagram similar to is required. 2 marks for correct (consistent) diagram, 1 mark for control flow, 1 mark for parallel execution of IO, 1 mark for concurrent (interleaved) flow of process execution.

    3. Draw a diagram of a modern multi-platter disk, and use it to discuss what is meant by the terms read/write arms, read/write heads, tracks, sectors, cylinders, seek time, seek latency, and rotational latency. (5 marks)

      Solution

      A diagram such as below is required.
      read/write arms
      label to diagram
      read/write heads
      label to diagram
      tracks
      label to diagram
      sectors
      label to diagram
      cylinders
      label to diagram
      seek time
      Time taken to move r/w arm to correct track
      seek latency
      same as seek time
      rotational latency
      time taken for correct sector to rotate into position under r/w head
      1 mark for correct diagram, 1/2 mark for each correct definition or label.

    4. Consider the following attempt at a critical section algorithm (written in Python).
      blocked = [false,false]turn = 0class P(Thread):    global blocked,turn    def __init__(self,id): self.id = id    while true:        # entry code        blocked[self.id] = true        while turn != self.id:            while blocked[1-self.id]:                turn = self.id        # end entry code        # critical section        # exit code        blocked[self.id] = false        # end exit codep0 = P(0); p1 = P(1); p0.start(); p1.start();

      Explain why the algorithm fails. (5 marks)

      Solution

      Consider p1 starts executing before p0, and reaches the first nested while. turn will be 0, and the condition is true, so the loop runs (1 mark). The body of the loop is a single while, whose condition blocked[0] will be false (1 mark). Hence the inner loop does not execute (1 mark). Nothing changes the condition of the while turn loop, so it continues executing indefinitely (1 mark), and the algorithm fails, since there is no bounded wait on p1 (1 mark).

      Alternatively, just give 5 marks for a coherent explanation of all detail

  2. Consider the following set of processes with the arrival for execution at the times indicated and the total required burst times listed.

    Process Arrival Time (mS) Burst Time (mS)
    P107
    P2210
    P385
    P4133
    P5186

    Answer the following questions (using illustrations or tables as necessary) for the two CPU scheduling algorithms:

    1. Round Robin (RR) for time quantum of 4mS,
    2. Non-preemptive Shortest Job First (SJF).

    1. Draw a Gantt chart for each of the scheduling algorithms. (4 marks)

      Solution

      There is an ambiguity about whether arriving processes get priority over jobs already in the system, hence there are two valid solutions for the Round Robin, depending upon whether processes already in the system have priority (a), or arriving processes have priority (b).

      Round Robin (a: resident processes have priority)

      0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
      P1 P1 P1
      P2 P2 P2 P2 P2 P2
      P3 P3 P3 P3
      P4 P4
      P5 P5 P5 P5

      Round Robin (b: arriving processes have priority)

      0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
      P1 P1 P1
      P2 P2 P2 P2 P2 P2
      P3 P3 P3 P3
      P4 P4
      P5 P5 P5 P5
      2 for correct diagram; 1 for incorrect data points but general structure correct (including correct ordering of processes)

      Non-preemptive Shortest Job First

      0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
      P1
      P2 P2
      P3 P3
      P4 P4
      P5 P5
      2 for correct diagram; 1 for incorrect data points but general structure correct (including correct ordering of processes)

    2. Compute the turnaround time of each process for each of the scheduling algorithms. (8 marks)

      Solution

      ProcessRR(a)RR(b)SJF
      P111117
      P2222715
      P3211517
      P4997
      P5131313
      -1/2 for each one wrong

    3. Compute the waiting time of each process for each of the scheduling algorithms. (8 marks)

      Solution

      ProcessRR(a)RR(b)SJF
      P1440
      P212175
      P3161012
      P4664
      P5777
      -1/2 for each one wrong

  3. Consider an operating system MicroHard Doors 2001, which is using a basic paging system (without using demand paging) with a logical address space of 4,096Kbyte and page size of 128Kbyte. The hardware characteristics of the computer system are as follows:

    Main memory size = 32 Mbyte (1M = 1024K, 1K = 1024 bytes)
    Main memory access time = 75 nS
    Smallest addressable unit = 4 bytes (i.e. 1 word)

    1. How many frames are there in the system? Show the format of the logical address (i.e. How many bits for page number? How many bits for page offset?). (6 marks)

      Solution

      Memory size (physical space) is 8M words (2^23)
      Logical space is 1024K words (2^20)
      Page size is 32768 words (2^15) Number of frames = physical size/page size = 2^25/2^17 = 2^23/2^15 = 2^8 = 256 2 marks
      Number of pages = logical size/page size = 2^22/2^17 = 2^20/2^15 = 2^5 = 32
      PPPPPOOOOOOOOOOOOOOO (5 bits for page number, 15 bits for offset, total 20 bits for logical address) 2 marks for each page number, offset. If they fail to allow for 4 bytes per word smallest addressable unit, then 1 mark each (i.e., max 2 for this part of the question)

    2. Assuming the page table is stored in main memory, what is the effective memory access time of this system? (4 marks)

      Solution

      Effective Access Time is 1 memory cycle to retrieve page table entry, 1 memory access to retrieve datum = 150nS 4 marks

    3. If a translation look-aside buffer (associative register) with an average access time of 15nS is available in the hardware, assuming a hit ratio of 95%, what is the effective memory access time now? (4 marks)

      Solution

      If the word is in the cache, it takes the lookup time plus the memory time to retrieve, i.e., 15+75=90nS. If it is not, then we need two memory cycles (page table and target word) plus the TLB lookup time, i.e., 15+75+75=165nS

      EAT = h*(15 + 75) + (1-h)*(15+75+75) = 0.95*90 + 0.05*165 = 85.5+8.25 = 93.75nS 4 marks

    4. If demand paging was implemented and a process, P, was allocated 4 frames, sometime into the execution of process P, a reference to the virtual address of 0x1a7de68 (hexadecimal) was made. To which page and what offset from the beginning of this page does the virtual address refer? (2 marks)

      Solution

      The given virtual address is 25 bits long, and is outside the range of valid virtual addresses. The address translation fails. 2 marks. If they assumed that it referred to the real address, and stated this, then they should get an answer of 1101001 111101111001101000 or page 0x69, offset 0x3de68, 1 mark

    5. Assuming an average page fault service time of 30mS and a page fault probability of 0.07%, what is the effective memory access time? (4 marks)

      Solution

      EAT = 0.9993*(93) + 0.0007*(30000000) = 92.9349 + 21000 = 21.093uS 4 marks

      It is worth noting that I (ajh) computed these values by hand. They are not onerous calculations. However, many students found them so:

      "Sorry, but my head can't calculate this"
      "I need a calculator"
      "Please note: due to lack of calculator I did not have time to caltulate exact values."
      "Don't have calculator - NOT COOL."
      "Something i'd figure out better with/if I had a calculator."
      "Not enough time to calculate."
      "...you expect them to do that kind of maths without a calculator? What planet are you on ?!"
      "grrr.... need a calculator!"


Document History

20070925:123207 1.0.0 ajh copied from cse2302 document with very minor changes

This page maintained by John Hurst.
Copyright Monash University Copyright Policy
1048 accesses since
26 Sep 2007
My PhotoTrain Photo

Generated at 20090706:1610 from an XML file modified on 20071024:1103
Maintainer use only; not generally accessible: Local ServerWork ServerCSSE Server

142 accesses since 09 Jul 2009, HTML cache rendered at 20120520:2229