Due Tuesday, December 3rd at 10:00 P.M.
Please submit a directory named by your two first names by the deadline on royal
/Shared/cs322/submit/proj5
It must contain your ThreadCB.java, TimerInterrupHandler.java
and a readme with
- your names at the top,
- instructions for compiling and running your code: either an Eclipse src
folder with a description of the your project setup or a Makefile or Unix commands,
- several log files corresponding to the provided paramsN.osp files or others
you have created (If you created files please submit them.),
- a paragraph that compares and contrasts two results of a same .osp file for basic scheduling
versus multi-level queue scheduling, and
- known issues if there are any problems with your results (Include a log if possible to highlight
the known issue.).
You may work in groups of two. Collaboration within a group is, of course, unrestricted.
You may discuss the program with members of other groups, but what you turn in must be your own group's
work.
It is a violation to the Honor Code not to acknowledge others' work fully and openly.
You should cite any online resources you consulted to help you solve this project.
You may NOT directly copy any code or any text from anywhere.
Setup
The project files are in the Thread directory on royal
/Shared/cs322/public/proj5
Follow the instructions in the readme file to
- run the demo simulator (observe the results for different parameter files, with and
without the GUI), and
- compile and run the template file TaskCB.java of the OSP2 Task project.
You must create default return values for the project to compile.
If you are using Eclipse:
- create a src folder in your Thread project,
- create a package whose name is osp.Threads inside the src folder,
- place the ThreadCB.java and TimerInterrupHandler.java templates inside that package and
- configure the build path (Configure Build Path...) so that OSP.jar (the External JAR) is added as one of
the Libraries.
This setup is needed as the simulator classes expect a TaskCB object of type osp.Threads.ThreadCB.
Fourth Hour
Read Chapter 4 the OSP2 manual.
Implement the Thread module of the OSP2 simulator to increase your understanding of CPU scheduling.
Choose a basic scheduling algorithm: FIFO with or without preemption.
To get pre-emptiion set a time quantum in TimerInterrupHandler.java.
Project
The goal is now to add to the Thread module a multi-level queue that uses the round-robin
scheduling algorithm on each level.
To do so, create a multi-level queue that consists of two separate queues:
- a high priority queue, which uses round-robin scheduling with a quantum value of 30 and
- a lower priority queue, use round-robin scheduling with a quantum value of 100.
When a thread is inserted into the multi-level ready queue,
it is placed in the high priority queue if its last CPU burst was smaller or equal to the quantum value of 30,
otherwise it is placed in the low priority queue.
To make this work it is necessary to keep track of the last CPU burst for the thread, and to use HClock.get().
Notes
- When the CPU burst is checked for a new process, the process has no history and its
last CPU burst is undefined.
The new thread is simply placed in the high priority queue.
- When do_dispatch() is invoked, first check whether there was a process running,
then check the higher priority round-robin queue, and finally the lower priority one.
If both queues are empty then set the page table register to null.
- Make sure not to leave a thread in the ready queue when it is dispatched.
If you do, and then re-insert it after a timer-runout or block, the queue may become disconnected,
making some ready threads inaccessible.
These stranded threads can never be re-scheduled, so threads may starve in the ready queue.