From Prof. Anthony D. Joseph
- Which of the following instructions should be allowed only in kernel mode?
- Disable all interrupts
- Read the time-of-day clock
- Set the time-of-day clock
- Five jobs are waiting to be run. Their expected running times are 9, 6, 3, 5, and X. In what order should they be run to minimize average response time? State the scheduling algorithm that should be used AND the order in which the jobs should be run. (Your answer will depend on X)
- Consider a system that starts with a total of 150 units of memory, which is then allocated to three processes as shown in the following table of processes, their maximum resource requirements, and their current allocations:
Process Max Demand Currently Holds P1 70 45 P2 60 40 P3 60 15 P4 60
Determine whether it would be safe to grant each ofthe following requests. If YES, give an execution order that could be guaranteed possible. If NO, show the resulting allocation table.
- Evaluate the Banker’s algorithm for its usefulness in real life. Give at least two reasons to justify your choice.
For Q1
Disabling interrupts is a serious thing and if user can do it, the control of the system will be lost to the user. As kernel is the sole controlling authority it can do it. So only Kernel Mode.
Reading is quite a harmless operation. so both User and Kernel Mode operation can be done.
Setting the time is also a very serious matter. There are many schedules, daemons, time dependent tasks running in a system and all of them would be affected so only Kernel Mode.
For Q2 Professor Anthony answers
Shortest job first is the way to minimize average response time
(we also accepted Shortest Remaining Time).
if 0 < X <= 3: X, 3, 5, 6, 9.
if 3 < X <= 5: 3, X, 5, 6, 9.
if 5 < X <= 6: 3, 5, X, 6, 9.
if 6 < X 9: X, 3, 5, 6, 9, X.
Just see how the question is answered, no nonsense and full marks
For Q3 Professor Anthony answers
The fourth process arrives, it must make some initial request.
If the initial request for 25 units.
YES, safe. 25 units will be left after the allocation for P4, so there is sufficient memory to guarantee the termination of either P1 or P2. After that, the remaining three jobs can be completed in any order.
If the initial request is for 35 units?
NO, unsafe. 15 units will be left after the allocation for P4, so this is insufficient to guarantee the termination of any process. Minimum 20 must be free for at least P2 to complete.
Assumptions are very important as you see to successfully attempt questions.
For Q4:
Not only it is unrealistic, it is impossible to know max demands in advance, number of processes can change over time, number of resources can change over time. It is so very complex.
So generally, most Operating Systems ignore deadlock condition.
A couple of Questions from I don’t know who at Berkely
1. Why is the process table needed in a timesharing system? Is it also needed in personal computer systemsin which only one process exists (taking over the entire machine until it is finished)?
Answer: The process table is used to keep, for every process in the system, all information that must besaved when the process is switched from running to ready or blocked state, so that it can be re-started lateras if nothing had happend. Now, if there were only one process that is never context-switched out, then a process table would not be that useful.
2. Can a multithreaded solution using multiple user-level threads achieve better performance on a multipro-cessor system than on a single-processor system? Explain why.
Answer: A multithreaded system comprising of multiple user-level threads cannot make use of the differentprocessors in a multiprocessor system simultaneously. The operating system sees only a single process andwill not schedule the different threads of the process on separate processors. Consequently, there is no performance benefit associated with executing multiple user-level threads on a multiprocessor system.