Operating Systems Final

Winter 2010
Due Thursday at 5:00pm
Paper under Lab 1 2010 or pdf via submit

The exam is takehome, open book and notes. Please do not use Google and the web to answer these questions except directed below through the class web pages. Your answers to these questions should all be outcomes of the experience with the lab projects you've been working on. Even if you have not done the labs, you are encouraged to answer the questions if you have studied the labs are confident you understand. But don't guess.

Although I have tried to be clear and specific, I suspect that it may turn out not be entirely clear what I am asking in some of the questions below, so for this exam I'm allowing some collaborative work. You must write up answers to these questions independently, but you may collaborate with other OS classmates to better understand the questions.

  1. Lab 2 Shell (Nutt Lab 2):
    1. Briefly outline the basic structure of a simple shell program.
    2. What system calls in a shell implementation are essential?
    3. When a Unix process spawn a child process, explain where and how the child process gets its code and data.
    4. Can a child and parent easily share variables? Explain how or explain why not.
    5. How do you pass arguments to the child process (eg, shell command line arguments)?
    6. How does a shell know when a command is done?

  2. Lab 3 Observing Linux Behavior through the proc File System (Nutt Lab 1)
    1. What is the purpose of the Linux proc file system?
    2. What information in general does the proc file system display?
    3. The proc files act like read only files, but what are they really?
    4. This lab asked you to write a C program to read, format, and display information that you extract from existing proc files. What does your program read and display?

  3. Lab 4 Kernel Timers (Nutt Lab 3)
    1. Briefly describe how the linux kernel Linux keeps track of the passage of time while it is booted up and running.
    2. How do Linux machines keep track of time when they are not booted?
    3. What is the granularity of accuracy of the Linux kernel clock?
    4. Describe each of the three per-process timers and what time they keep track of.
    5. Where does Linux keep per-process time information?
    6. When is per-process time information updated by the kernel?
    7. What is a Unix signal?
    8. How are Unix signals used in this lab to implement a process timer?
    9. Briefly describe how to set up a Unix signal handler.
    10. What does your signal handler do in this lab?
    11. What processes did you time?
    12. Were your results meaningful? Explain how you determined your timing results were meaningful.

  4. Lab 5 Kernel Modules (Nutt Lab 4)
    1. What is a kernel module and for what good reason do they exist in Linux?
    2. What is the interface we used in the proc file kernel module? There is a generic name and a specific structure name.
    3. Where specifically (in what file) do you find the interface definition?
    4. How does a kernel module interact with an interface to supply new kernel functionality? (By this I mean how do you as a programmer connect your functions into the kernel)?
    5. What specific proc file functions did you supply in your proc file module?
    6. Explain the purpose of each function you supplied in your proc file module.
    7. What system calls correspond to the proc file functions you supplied for the your proc file module?
    8. List the steps you need to go through to create and install a kernel module. Be brief but specific.
    9. What kernel module code gets executed when you install a kernel module?
    10. How do you remove a kernel module from the kernel?
    11. What kernel module code gets executed when you remove a kernel module?
    12. How does the Linux system know your module is kernel code with kernel priviledges and not just some user code?
    13. What do your proc file module system calls return and where do the results go?
    14. How does your proc module read signify an end of file to the caller?
    15. If you wrote a test program to use your proc file module, what proc file system calls does your test program call? Does your test program use more system calls than you actually provide in your module? Where is the code for the other module system calls?

  5. Lab 5 Kernel Modules (Syscall Examples)
    In the process of adding system calls to the kernel in Lab 6 below, we learned from the Linux Kernel Module Programmer's Guide that is is possible to do a system call as a kernel module. The following questions are specifically about doing system calls as modules as opposed to hard-coding system calls in the main kernel source tree as described in Lab 6 System Calls below. You may want to do the Lab 6 questions first. You also may want to skip this section if you did not do a system call as a module. Ordinarily you do not install new system calls using kernel modules unless you are just experimenting or testing.
    1. List the steps you need to go through in order to add a system call using a kernel module. Be specific. You may refer to your Lab 6 answer below for common steps.
    2. If you have not already done so in the previous questions, identify and discuss what is different about the process of adding a system call as a module as opposed to hard-coding a system call as in Lab 6 below.
    3. Describe a significant problem with adding a system call using a kernel module.

  6. Lab 6 System Calls - Hard-coded in the Kernel (Nutt Lab 5)
    1. What is a system call?
    2. How do you as a programmer usually access a system call?
    3. How do system calls initiated from user mode in user space safely switch to kernel mode and kernel space for processing?
    4. Why can't system calls be ultimately referenced by name when switching from user space to kernel space?
    5. What facility does Linux provide to simulate system calls by name and with appropriate typing? (Note: this facility is usually used only in the library functions that encapsulate system calls).
    6. What kernel file contains the table of all system calls?
    7. What is the name of the table of all system calls in the Linux kernel?
    8. How is the table of system calls organized?
    9. How does the kernel associate a system call instance with the proper kernel code?
    10. Specifically, how do you pass data in from user space to the kernel data space? Identify at least two ways and their restrictions if you can.
    11. Specifically, how do you pass data from the kernel space back into the user space? Identify at least two ways and their restrictions if you can.
    12. When building your hard-coded kernel system call, what C source code files did you need to modify in the Kernel?
    13. How did you compile your kernel code? Be specific.
    14. How did you modify the kernel Makefile to locate your kernel object code for linkage?
    15. What did your new kernel system call do?
    16. How did you test your kernel system call? Explain how you know your system called worked.

  7. Lab 7 and 8 Event Queues (Nutt Lab 8) Event Wait Queues are a facility available in the 2.4 kernel, but they are not supplied to the user-level system progammer. This lab guides you through adding Event Queues as a user level synchronization facility.

    1. What synchronization facilities does the Linux 2.4 system provide for user level system programmers? You can use the web links from the OS page to research this.
    2. What synchronization facilities does the Linux 2.4 kernel provide for kernel programmers? Again, use the web links from the OS web page to research this if you need to.
    3. What are wait queues used for in the kernel?
    4. Describe briefly how you used the kernel event queues to provide event queues for user level system programmers through your system calls.
    5. In your event queue design, how many event queues did you allow users to have?
    6. What system calls did you add to the kernel to provide an event queue facility?
    7. Briefly describe what each of your system calls do.
    8. Explain clearly how your event queue facility can be used as a synchronization facility by system programmers.
    9. Describe an example program illustrating how your event queues can be used.
    10. How did you test your event queue system calls?
    11. Explain how you know your event queue system calls worked.

  8. Lab 9 Device Drivers (Nutt Lab 10) This lab asks you to build a fifo device driver.
    1. What is the interface used in device driver modules? There is a generic name and a specific structure name.
    2. Where specifically (in what file) do you find the interface definition for device drivers?
    3. What specific device driver functions did you supply in your device driver module?
    4. Explain the purpose of each function you supplied in your device driver module.
    5. What data structure did you use for your fifo buffer?

    6. What synchronization and mutual exclusion did you provide for your fifo buffer?
    7. The following questions relate to your fifo design.
      1. What is your intended multi-process access to your fifo? That is, do you allow one writer and one reader, multiple writers and multiple readers, or some other option?
      2. What is your synchronization design. Do you block writers and readers? Do you block just readers or just writers? Do you block neither readers or writers? Do you allow one writer and multiple readers? Explain.
      3. What happens when your writers try to write more than there is fifo space available in your fifo buffer?
      4. What happens when your readers read more than the size of your fifo buffer?
      5. How does your fifo close down? For example, does the writer indicate an end of file to the reader? Do the writer and/or reader close their end of the fifo when the reader and/or writer close the fifo?
      6. Elaborate briefly on the design of your fifo behavior with these questions in mind.