I need to develop the
awake() functions of the OS.
I have runningJobs queue, and sleepingJobs queue. The sleep method should receive a Job and insert it in the sleeping queue in the right place, and the
awake() method should move the sleeping jobs that are ready to run, to the runningJobs queue.
- In not sure how to implement my queues – should I use PriorityQueue / LinkedList queue?
- What is the most efficient way to order my list / find the right job in my queue?
- How the
awake()method would know the time without having access to the current time
- Either option (linked list/priority queue) is fine. The decision depends on what result you want.
Linked list is a “first in first out” queue. The first job to sleep is the one that has been running the longest. The first job to awake is the one that has been asleep the longest.
Priority queue will let you have different execution priorities: the lowest priority process will sleep first, the highest priority process will awake first.
Don’t reorder the queues externally, trust the data structure to do it itself.
Presumably your os simulator has a clock of its own, which you can use instead of the real world clock time.