


However, suspend and resume may cause a deadlock if a suspended thread holds a lock and a runnable thread tries to acquire this lock. In order to implement a rigid round-robin CPU scheduling, we could modify ThreadOS Scheduler to dequeue a front user thread from its circular list, to resume it with the resume method, and to suspend it with the suspend method after a execution quantum has been expired. No matter what operating systems you use, a target thread is suspended and resumed immediately. The suspend( ) method suspends a target thread, whereas the resume( ) method resumes a suspended thread. Note that, in general, you should avoid using Thread.suspend( ) and Thread.resume( ) in your future thread programs (of course including the assignment 3, 4, and 5. We use Thread.suspend( ) and Thread.resume( ) only for this assignment, in particular only inside Scheduler.java of our ThreadOS. (This is the reason why their use is deprecated in Java 2 Platform, API documentation.) 3. Then, how can we enforce a rigid scheduling in our ThreadOS Scheduler? One of the answers is using Thread.suspend( ) and Thread.resume( ) , both of which must be however used with the closest attention, otherwise will cause deadlocks. Therefore, Scheduler.java cannot strictly enforce a round-robin scheduling. However, there are no guarantees that a thread with the highest priority preempts the current thread immediately. This scheduler program is the same as you saw in the lecture slide. ThreadOS Scheduler.java implements a naive round-robin scheduler based on “Java Thread Scheduling”. The step-by-step procedure to complete this assignment is: (1) to observe the behavior of ThreadOS Scheduler that uses a Java-based round-robin scheduling algorithm and consider why Java thread priority is not working exactly as your expectation (2) to redesign ThreadOS Scheduler using Thread.suspend( ) and Thread.resume( ) so that it will rigidly work in a round-robin fashion (3) to revise your ThreadOS Scheduler as a multilevel feedback-queue scheduler and (4) to compare those two scheduling algorithm with test thread programs. This assignment implements and compares two CPU scheduling algorithms, the round-robin scheduling and the multilevel feedback-queue scheduling.
