Midterm II

Part of materials for 22C:50, Summer 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

 

Name: ________________________________________________ ID Number: ___________________

Please answer in the space provided! Your name must be legible and in the form used on your University ID card! Illegible and verbose answers will be penalized! This exam is open-book, open-notes, closed neighbor! This exam 10 points; allocate 4-5 minutes per point.

  1. Consider these two very artificial fragments of EAL code: (2 points)
         ; file1.a                         ; file2.a
            EXT A                             INT A
            INT B                             EXT B
            W   A                             W   A
         B: W   B                             W   B
            W   C                          C: W   C
         C  =   #200                       A  =   #300
    
    Assume that these have been assembled and that a linking loader is used to link first file1 and then file2 and load them into memory starting at address 30016. Show the resulting contents of memory as consecutive words:
       location      value                 location      value
    
         0300     ____________               030A     ____________
    
         0302     ____________               030C     ____________
    
         0304     ____________               030E     ____________
    
         0306     ____________               0310     ____________
    
         0308     ____________               0312     ____________
    

  2. Which of the following shell commands must be built-in to the shell and not merely the names of executables. For each that must be built-in, why? (1 point)

    a) exit <status>

    ________________________________________________________
    
    ________________________________________________________
    

    b) cd <filename>

    ________________________________________________________
    
    ________________________________________________________
    

     

     

     

    Name: ________________________________________________

     

  3. You have been asked to write an new suite of applications, callable from any Unix shell. The primary application in this suite is a program called if that executes the applicaton named by argv[1] and passes, as parameters, argv[2] and up. If the executed application terminates successfully, if exits normally. Otherwise, it reads standard input up to and including a line starting with the single keyword else or endif. If it finds end-of-file on this scan, it reports an error.

    a) The suite also includes an application called else. What does this do? (1 point)

    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________
    

    b) What other application programs must you write as part of this suite, and what do they do? (1 point)

    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________
    

     

  4. There was a time in the early PC era when external disk drives were sold that could be connected to the serial port of a computer. Typically, these had a command to set the disk address, one to write a sector's worth of data to a one-sector buffer inside the drive electronics, one to read the contents of that buffer, and one to read or write between the specified disk address and the internal buffer. Assume commands are one byte, disk addresses are 4 bytes, and sectors have 512 bytes.

    a) Assuming a fast serial port, is disk scheduling still relevant? (1 point)

    
    ________________________________________________________
    
    ________________________________________________________
    
    b) How many interrupts it would take to complete one disk transfer to or from this device? (1 point)
    
    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________
    

     

     

     

    Name: ________________________________________________

     

  5. Assume you are given a disk spinning at 100 revolutions per second, and with 100 sectors per track, and with 1000 bytes per sector, including intersector gap and header information, which take up 100 bytes (these numbers are round so you won't need a calculator).

    a) How many bytes per second does the interface for this disk process? (0.5 points)

    ________________________________________________________
    

    b) How many microseconds pass during reading the header on one sector? (0.5 points)

    ________________________________________________________
    
    c) Given that the disk interrupt service routine takes 2 microseconds, what is the minimum interleaving factor that will work for this disk, ignoring the count of sectors per track? (0.5 points)
    ________________________________________________________
    

    d) Given the number of sectors per track, what interleaving factor will be likely to be used? (0.5 points)

    ________________________________________________________
    

  6. Large sectors allow more efficient input/output for large files, but if a whole sector is allocated for each small file, this can lead to significant waste. One option, used by the Reiser File System under Linux, is to store "file tails" (the final fractional sector of a large file, or a whole small file) packed together into sectors.

    a) What information would you need to add to a classical UNIX i-node to allow the tail of a file to be packed together with other file tails in a single disk sector? (0.5 points)

    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________
    

    b) What file operations would be significantly slower with this scheme? (0.5 points)

    ________________________________________________________
    
    ________________________________________________________
    
    ________________________________________________________