I need some help on figuring out a way to store my data that is efficient. I am writing a scheduling algorithm using priority queues which include not-yet-submitted, ready, running, blocked, and completed. All processes begin in the not-yet-submitted state. My information comes from the standard input.
Each line below explained (respectively):
first line = CPUs in the system (1 to 4), the number of processes (1 to 25), and the quantum size (1 or larger).
second/third = the process ID (1 to 999), the process priority (1 to 10),
the time of submission (non-negative),the total CPU time required (1 to 1000),
the compute time before input/output is needed (1 to 100),
and the input/output time for each compute-I/O cycle (1 to 1000).
Sample Input
1 2 10
1 1 0 10 5 10
2 2 3 10 5 10
The second and third lines are separated processes and there can be up to 25 processes. initially I was thinking just store each process into its own array so I could move that array from Queue to Queue with ease but creating 25 different arrays and then possibly not using them is very inefficient. Is there a more simple way store my “processes” so I can move them between the states (which is represented by the queues)?
I would make a Process class that contains the state expressed on the second/third lines above. Something like:
And store instances of the class in a queue. No reason not to make a queue for the waiting processes. Then move the instances to other queues as needed.