Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++/C) Here is a link to all my stuff, https://gist.github.com/VictorAmaro/33236b7b54d45774293126e3843a37ba *************************************************************************************************** Here are direct instructions, We have a main loop. It starts with Timer =

(C++/C) Here is a link to all my stuff, https://gist.github.com/VictorAmaro/33236b7b54d45774293126e3843a37ba

***************************************************************************************************

Here are direct instructions, We have a main loop. It starts with Timer = 0. Timer is incremented at the bottom of the loop, and the loop ends when Timer reaches MAX_TIME or there are no processes left (all queues empty, Active, IActive and OActive all = 0). At this point, various things may happen in the loop: If we do not have an Active process, we need to look for one in the Ready queue. If we still do not have an Active process, there is little for the CPU do on this iteration of the loop: idle time. If we do have an Active process, what could happen to it? --- It could come to the end of a CPU burst. Look in the History array; you should find an Input or Output burst. It moves to the Input queue or Output queue. --- It could come to the end of a CPU burst which is followed by termination of the process. Look in the History array; you should find a terminator ("N" and 0). If we do not have an IActive process, we need to look for one in the Input queue. (It might be empty: no IActive process for a while.) If we have an IActive process, it may come to the end of its Input burst, in which case it is moved to the Ready queue. If we do not have an OActive process, we need to look for one in the Output queue. (It might be empty: no OActive process for a while.) If we do have an OActive process, it may come to the end of its Output burst, in which case it is moved to the Ready queue.

***************************************************************************************************

Process.h/cc:

Contains my struct called Process, hope it's well documented enough.

Main thing, historyAr array is filled with data from data4.txt. Example, in the txt file, the seocnd line where it's a character followed by an int are made into pairs and stored into this array. (C stands for CPU burst, I stands for Input Burst, and O stands for Output burst. And the number next to it states how long that burst takes). And N stands for the end of that Process.

PROGRAMA <-(This is process name) 5 <-(this is process priority) 0 <-(this is process arrival time).

***************************************************************************************************

Now, in Assign4.h/cc is where I need the help.

Line 91 in Assign4.cc, my while loop is running until MAX_TIME (int 500) is reached by the var timer, I still need help on how to implement this step, "or there are no processes left (all queues empty (there are 4 of them) = empty and Active, IActive and OActive = NULL)".

From there, the second while loop on line 92 is responsible for making sure there is always 5 Process objects in the readyQueue. So long as a time requirment is met. (Everything in this should be fine)

Next, is the big If block, everything in this should also be fine.

(Adding one to the var time represents a tick.)

After the If block is where all the new code should be going.

I don't get how to move a Process into active from readyQueue, and then from there move it into the other queues based off its historyAR. In that array "C" means CPU burst, so its meant to stay into active for a desired amount of time (a time also in array), and this is the same for "I" meaning input burst and "O" meaning output burst. Depending on which burst the process currenly has, it needs to be moved into the appropriate queue (inputQueue and others) and then into a active process ptr (oActive and others) and once all its bursts are done, it needs to be terminated. (removed from all queues and such. and have info displayed, i have a function for this in Assign4.h/cc)

While the Process is either in active, oActive, or iActive some stats need to be kept. For that Process, the number of ticks it spent in either one need to be reflected in the Process (cpuTotal, oTotal, iTotal). As well as the total count of each CPU, Output, Input burst for that Process.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions