Due date: Thursday, September 18th
You must turn in your homework in written form by the beginning of class on the date it is due. Note, there are no late-dates allowed for this homework since a solution will be posted the afternoon it is due to help with mid-term exam preparation.
The questions are based on material presented in class and reading material from the text.
Give brief answers to the following questions:
Given the following set of processes with their CPU burst times:
Process Burst Time A 5 B 7 C 4
Assume processes arrive in the order A, B, C at times 0, 1, and 2 respectively. Draw a Gantt chart and compute the average waiting time for Round Robin (RR) scheduling with time slice 2 (do not have idle time slots).
When is the Windows NT/2000 scheduler like the basic Round-Robin scheduler as presented in class?
Explain in what ways a software interrupt is similar to a hardware interrupt. Explain in what ways it is different.
What is a critical section? What are the three requirements for correctly solving a critical section problem?
Both busy waiting and blocking methods can be used as means to address critical section problems and process synchronization. Describe how blocking is different from busy waiting, and discuss the advantages and disadvantages of each.
Suppose your OS does not yet have semaphores but the computer
system does have the Test_and_Set()
function. Assuming
only a single semaphore is needed, implement the functions
wait(void)
and signal(void)
using the
Test_and_Set()
function. You may use a shared boolean
variable called "lock
". What are the potential
drawbacks, if any, of this semaphore implementation?
Do semaphores solve the problem of process synchronization completely? What are some of the things that might still go wrong in a solution that requires synchronization?
What is a monitor? Explain how it can be used to solve a synchronization problem.
Following is an implementation of a mailbox that can contain one message at a time. Use semaphore(s) to make the consumer prints the message once if and only if there is a message in the mailbox created by the producer.
struct message mbox; /* shared */ producer() { struct message my_msg; while(1) { create_msg(&my_msg); /* create my message */ put_msg(mbox, my_msg); /* put my message in the mbox */ } } consumer() { struct message my_msg; while(1) { get_msg(&my_msg, mbox); /* get message from the mbox */ print_msg(my_msg); /* print my message */ } }
Consider the following solution for the Dining Philosophers for 6 philosophers:
semaphore chopstick[6]; /* shared array of sems */ while (1) { /* think */ wait(chopstick[i]); wait(chopstick[i+1 % 6]); /* eat */ signal(chopstick[i+1 % 6]); signal(chopstick[i]); }
What is a potential problem with this solution? Modify the above solution to avoid deadlock by allowing only a philosopher to "sit" in every alternate chair. You may declare additional semaphores as needed and shared variables as needed.
Return to the CS3013 Home Page
Send all questions to the TA mailing list.