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
- Describe the basic mechanism for reading the names of the files and directories in a given directory.
- Describe the functionality of each of the commands in the ftp assignment.
- 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).
- Give an overview of how to use regcomp() and regexe().
- What were the critical sections in the search program?
- Describe the concept of a threadpool.
- Explain the mechanism you used to make unused threads wait until they were needed by Threadpool::dispatch().
- How does one implement the blocking/non-blocking feature of Threadpool::dispatch()?
Example Topic Questions
-
What is a Unix signal?
-
How are a thread and a process different? What are advantages of threads over processes?
-
Describe the concept of a semaphore. Include a description of how they are used.
- Describe the concept of a Unix pipe. Explain how they can be used to provide producer-consumer synchronization.
- What does it mean if a set of process are deadlocked?
- Describe the waitpid() function. Mention both the blocking and non-block behavior.
- Outline the critical section problem. Give an example of a solution to this problem.
- If two 20000 byte messages are sent on a socket connection, how many messages will be received at the other end?
- Draw a diagram of the memory segment of a process. Include the runtime-stack, dynamic memory, and global variables.
- What are the ramifications of preemptive scheduling on concurrent processes.
- What does the C pre-processor do?
- Describe how pthread conditional variables work.
- Describe how two separate processes can manage to use the same semaphore set, shared memory, or message queue.
- Give an overview of how to write a function that takes a variable number of arguments.
- Describe the concept of a UNIX pipe. Explain how processes communicate using pipes.
- 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?
- Describe how multiple process can use a shared memory segment to share data. Address how race conditions can be prevented.
Example problem solving questions
-
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.
- 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.
- Using Pthreads write a program that demonstrate a race
condition. How could the program be modified to remove the race
condition.
- 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.
- Write a function that takes a pointer to another function and executes it.
- 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.
- Solve the one-lane bridge problem using semaphores.
- Solve the one-lane bridge problem using mutex locks and conditional variables.
- Write a producer/consumer problem where the process communicate using a POSIX message queue.