CSCI 640, Operating Systems
Sample Final Questions
Fall 2007

This document contains some sample questions for the final.  You should also use the list of topics to organize your preparation.

There will be three types of questions:  (1) questions about the assignments (2) topic questions and  (3) questions in which students solve a problem using C/C++ or pseudo-code.

You don't have to remember the names or syntax of system calls.  If you forget the name of a function, you can comment what it does or give it a descriptive name.  For example, readdir() returns the next item from an open directory.  If you forgot the name of the function you could write something like this:

get_next(my_directory) // return next entry in the directory

Or if you forgot the name of the fork() function, you could write:

child_pid = create_new_process()


Example Assignment Questions
  1. Describe the basic mechanism for reading the names of the files and directories in a given directory.
  2. Describe the functionality of each of the commands in the ftp assignment.
  3. When sending binary files across a socket there is no character that can be used to indicate the end of the file.  Describe a mechanism that can be used to definitively identify the end of a file (there are two common methods, describe only one of them).
  4. Give an overview of how to use regcomp() and regexe().
  5. What were the critical sections in the search program?
  6. Describe the concept of a threadpool.
  7. Explain the mechanism you used to make unused threads wait until they were needed by Threadpool::dispatch().
  8. How does one implement the blocking/non-blocking feature of Threadpool::dispatch()?


Example Topic Questions

  1. What is a Unix signal?
  2. How are a thread and a process different?  What are advantages of threads over processes?
  3. Describe the concept of a semaphore.  Include a description of how they are used.
  4. Describe the concept of a Unix pipe.  Explain how they can be used to provide producer-consumer synchronization.
  5. What does it mean if a set of process are deadlocked?
  6. Describe the waitpid() function.  Mention both the blocking and non-block behavior.
  7. Outline the critical section problem.  Give an example of a solution to this problem.
  8. If two 20000 byte messages are sent on a socket connection, how many messages will be received at the other end?
  9. Draw a diagram of the memory segment of a process.  Include the runtime-stack, dynamic memory, and global variables.
  10. What are the ramifications of preemptive scheduling on concurrent processes.
  11. What does the C pre-processor do?
  12. Describe how pthread conditional variables work.
  13. Describe how two separate processes can manage to use the same semaphore set, shared memory, or message queue.
  14. Give an overview of how to write a function that takes a variable number of arguments.
  15. Describe the concept of a UNIX pipe.  Explain how processes communicate using pipes.
  16. How does UNIX keep track of time?  How would one go about converting the internal representation of time to a format that is easy for humans to understand?
  17. Describe how multiple process can use a shared memory segment to share data.  Address how race conditions can be prevented.


Example problem solving questions

  1. Write code that creates a child process that performs a calculation (such as adding two numbers).  Have the parent process wait for the child process to finish and perform a calculation using the result of the calculation performed by the child.  Clearly document how the result is communicated from the child process to the parent process.  Assume the result of the calculation the child process performs is a double.
  2. The dining philosophers problem is summarized as five philosophers sitting at a table doing one of two things - eating or thinking. While eating, they are not thinking, and while thinking, they are not eating. The five philosophers sit at a circular table with a large bowl of spaghetti in the center. A fork is placed in between each philosopher, and as such, each philosopher has one fork to his or her left and one fork to his or her right. As spaghetti is difficult to serve and eat with a single fork, it must be assumed that in order for a philosopher to eat, the philosopher must have two forks. In the case of the dining philosopher, the philosopher can only use the fork on his or her immediate left or right.  Assuming each philosopher is represented by a process and each fork is a limited resource, write a code segment that uses semaphores to provide the synchronization necessary to solve this problem.  Make sure your solution does not deadlock.
  3. Using Pthreads write a program that demonstrate a race condition.  How could the program be modified to remove the race condition.
  4. When a process terminates the parent process receives a SIGCHLD signal.  When a process terminates the operating system does not completely delete it until the process' parent performs a wait() for it.  Write a program that forks several processes and uses the SIGCHLD signal to make sure wait() is called for each terminated child.  Assume the parent process continually prompts the user for a word and then prints the word until the user enters ^D (EOF).  This last assumption means that you can't have the parent block on the wait() command, you must use the SIGCHLD signal.
  5. Write a function that takes a pointer to another function and executes it.
  6. Assume the following test and set function is atomic:  bool test_and_set(bool &value) {bool temp = value; value = true; return temp;}.  Use it to solve the critical section problem.
  7. Solve the one-lane bridge problem using semaphores.
  8. Solve the one-lane bridge problem using mutex locks and conditional variables.
  9. Write a producer/consumer problem where the process communicate using a POSIX message queue.