I have an assignment in Operating System where I am suppose to simulate a process scheduler. The process are inputs through command line. A sample list of input would look something like:
START 10
DISK 12
SEND
START 5
The 'START' indicates arrival of a different process and each numerical value is the arrival time.
My approach:
Going 1 step at a time, I was first able to get input from command line, using i/o redirection.
Next I tried taking the user input from the command line and put in a queue,
And every time user in put is a 'START' create a new queue and put the rest in the new queue until another 'START' is found and so on.
But I am stuck on how do I make this new dynamic queue?
if you want a queue each time "START" you need another container like vector that harbors the queue:
1 2 3 4 5 6 7 8 9 10 11 12
vector<queue<string> > process;
...
if(first_word == "START")
{
process.push_back(queue<string>());
...
}
elseif(!process.empty()) // vector must not be empty / there must have been "START" before this
{
process.back().push(line);
...
}