Operating Systems: HW 2

Due 5PM Feb 19, 2010


Answer each of the following questions. Please submit your solution through Spark in either TXT or PDF format if possible.

1. (10 points) On a dual core system, how many processes can be in the ready state at the same time? What about in the running state?

2. (30 points) Using the execlp, fork, kill, and waitpid functions described below, write psuedo code for a program which does the following:

The parent process starts a child process. The child process starts two additional "grandchild" processes. The first and second grandchild processes each execute a new program: "grandchild_1" and "grandchild_2" respectively. The original child process waits for grandchild_2 to complete, and then kills grandchild_1. The original parent process waits for the child to complete, and then prints a message saying "All children have completed".

You can assume that execlp("program") will execute "program", fork() will fork a new process and return the ID of the child to the parent or 0 to the child process, kill(pid) will kill the process with ID=pid, and waitpid(pid) will wait for the process with ID=pid to complete before returning.

3. (15 points) What process cooperation techniques are each of the following activities most similar to? Describe one benefit and one draw back for each approach to process communication.

(a.) Two students writing information to a black board.

(b.) Sending postcards between two cities.

4. (15 points) Describe the differences between Kernel and User level threads. If an application has several threads that are all performing I/O activities, would it be better to use kernel or user level threads? Why?

5. (30 points) For the following mix of jobs, lengths, and arrival times, determine the scheduling order and average wait time for the First Come First Served (FCFS), Round Robin (RR), and Shortest Job First (SJF) schedulers. Assume all times are in msec. For the RR scheduler, use a 5 msec time slice and a 0 msec context switch cost; assume that when new tasks arrive they are placed at the head of the queue for jobs waiting to be scheduled.

Fill in the following table with the time of completion and time spent waiting for each task. Use the reported average wait times to check your answer.

Time of Completion Wait Time
Job Arrival Length FCFS RRSJF FCFS RRSJF
1 0 40
2 5 15
3 20 25
4 40 20
Average Wait Time: 27.5 36.25 26.25

IMPORTANT: There was an error in the original version of the homework. The average wait time was reported as 43.75 for FCFS -- this was incorrect. The correct time should be 27.5


Prashant Shenoy