## CS 110 Homework Assignment 2 Due: Friday, October 12, 9 PM

The material for the questions below can be found in any operating system text.
Remember, no hand written material. Use a text processor - you might try troff or latex/xfig.
Also remember to date and time stamp your homework.

1. Points 3, T.2.5, pg 71.
Consider a computer that does not have a Test & Set Lock instruction, but does have an instruction to swap the contents of a register and a memory word in a single indivisible action. Can that be used to write a routine enter_region such as the one discussed in class.
2. Points 3, T.2.20, pg 72,
Measurements of a certain system have shown that the average process runs for a time T before blocking on i/o. A process switch requires a time S, which is effectively wasted (overhead). For round robin scheduling with quantum Q, give a formula for the CPU efficiency for each of the following:
• Q = infinity
• Q > T
• S < Q < T
• Q = S
• Q nearly 0
Note: CPU efficiency = useful CPU time / total CPU time
3. Points 3, gen.3
A soft real-time system has four periodic events with periods of 50, 100, 200, and 250 msec each. Suppose that the four events required 35, 20, 10, and X msec of CPU time, respectively. What is the largest value of X for which the system is schedulable.
4. Points 3, T.2.23, pg 72,
Five jobs are waiting to be run. Their expected run timers are 9, 6, 3, 5, and X. In what order should they be run to minimize average response time? (Your answer will depend on X).
5. Points 5 s.5.5, pg. 151
Consider a variant of the RR (RoundRobin) scheduling algorithm where the entries in the ready queue are pointers to the PCBs (Process Control Block).
1. What would be the effect of putting two pointers to the same process in the ready queue?
2. What would be the major advantages and disadvantages of this scheme?
3. How would you modify the basic RR algorithm to achieve the same effect without the duplicate pointers?
6. Points 3, s.5.9, pg 152
Suppose that a scheduling algorithm (at least of short-term CPU scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor I/O bound programs and yet not permanently starve CPU-bound programs?
7. Get on turing. Run ps and determine:
1. the parent process owned by you for your session
2. the parent process of the system for which your parent process is a child
3. the longest chain of parent/children processes for your session.
4. the scheduling priority of your processes.

Turn in an annotated script file of your ps answering the questions above.
8. Points 3, mos2.3.2, pg 186.
Students working at individual PCS in a computer lab send their files to be printed by a server which spools the files on its hard disk. Under what conditions may a deadlock occur if the disk pack for the print spool is limited? How may the deadlock be avoided?
9. Points 3, mos2.3.3, pg 186.
In the preceding question which resources are preemptable and which are nonpreemptable?
10. Points 3, mos2.3.19, pg 187.
The banker's algorithm is being run in a system with m resource classes and n processes. In the limit of large m and n, the number of operations that must be performed to check a state for safety is proportional to m**a * n**b. What are the values of a and b. Note: ** is exponentiation, which could have been written m^a, but i use to do Fortran.
11. Points 4, mos2.3.26, pg 188.
A computer science student assigned to work on deadlocks thinks of the following brilliant way to eliminate deadlocks. When a process requests a resource, it specifies a time limit. If the process blocks because the resource is not available, a timer is started. If the time limit is exceeded, the process is released and allowed to run again. If you were the professor, what grade would you give this proposal and why?