Assignment 10, due Apr. 23
Part of
the homework for 22C:112, Spring 2010
|
Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated (usually a Friday). The only exceptions to this rule will be by advance arrangement unless there is what insurance companies call "an act of God" - something outside your control. Homework must be turned in on paper and in class! Late work may be turned in to the teaching assistant's mailbox, but see the late work policy. Never push late work under someone's door!
When there is a system call that has a return value, the system call trap service routine stores the return value in a designated register of the calling process. Call this the return register, r[return].
A Question: The fork() kernel call must create a new process description by copying some of these fields from the calling process description and changing others. Give detail, for each field, what is copied and what is changed. (1.0 points)
Look at the code for thread_relinquish(). The function of this code is very similar to the function you would expect from the real-time clock interrupt service routine in the kernel, except that threads call it voluntarily when they wish to let other threads have a chance at the CPU. You will need to look up some routines in the C standard library to understand how this code works. Use the man command, or google, to look these up.
A Question: With the real-time clock service routine, entry to the interrupt service routine saves the state of the former running process, and exit from the interrupt service restores the state of the new running process. How does the state of the former running thread get saved and how does the state of the new running thread get restored in the thread manager's relinquish routine? (1.0 points)
a) Give appropriate C code for exit from a critical section. This is just a matter of deleting the lock file. (0.5 points)
b) Give appropriate C code for entry to a critical section. This requires creating the lock fiel with file creation options set to notify the caller if creation failed because the lock file already existed. (Hint. Each time around the polling loop, it is appropriate for the calling process to sleep for a moment to give other processes a chance to run.) (0.5 points)