SlideShare a Scribd company logo
1 of 50
Programming Assignment #2
CSci 430 Spring 2019
Dates:
Assigned: Monday February 4, 2019
Due: Wednesday February 20, 2019 (before Midnight)
Objectives:
ˆ Explore the Process state models from an implementation
point of
view.
ˆ Practice using basic queue data types and implementing in C.
ˆ Use C/C++ data structures to implement a process control
block and
round robin scheduling queues.
ˆ Learn about Process switching and multiprogramming
concepts.
Description:
In this assignment you will simulate a Three-State process
model (ready,
running and blocked) and a simple process control block
structure as dis-
cussed in Chapter 3. Your program will read input and
directives from a
�le. The input describes a time sequence of events that occur.
These are the
full set of events you will simulate:
1
Event Description
cpu The processor executes for 1 time step the currently running
process
new A new process is created and put at tail of the ready queue
done The currently running process has �nished
wait X The currently running process has done an I/O operation
and
is waiting on event X
event X Event X has occurred, the process waiting on that event
should
be made ready.
The input �le will simply be a list of events that occur in the
system, in
the order they are to occur. For example:
----- simulation-01.sim --------
new
cpu
cpu
cpu
new
cpu
cpu
cpu
cpu
wait 1
cpu
cpu
event 1
cpu
cpu
done
cpu
cpu
cpu
cpu
exit
----------------------------------
Your task is to read in the events, and simulate the creation and
execution
of processes in the system as they move through the various
three-states of
their process life cycle. You need to:
2
ˆ De�ne a simple process control block (PCB) to hold
information about
all processes currently running in your system. The PCB can be
a
simple C struct or a C++ class. At a minimum you need to have
a
�eld for the process identi�er and the process state (Ready,
Running or
Blocked). You need to also keep track of the time step that the
process
entered the system, and the number of steps the process has
been
running. Minimal credit will be given to programs that at least
handle
new events and create a process in a simulated PCB. You
probably
need a list or an array to hold the current processes that have
been
created and are being managed by your simulated system.
ˆ You will need a ready queue of some kind. You should use a
C++
Standard Template Library (STL) container to manage your
ready
queue.
ˆ You will need to implement a simple dispatcher function.
Whenever
a cpu event occurs, and no process is currently running, you
should
select the next Ready process from the head of your ready queue
and
start it running on the processor.
ˆ You need to also implement a simple time slicing mechanism.
The
time slice value to use will be passed into your program when it
is
started. At the end of a cpu cycle, you should check if the
currently
running process has executed for its full time quantum. In that
case,
the currently running process should timeout, and be returned to
the
end of the Ready queue.
ˆ new events should cause a new process to be created
(including creating
its PCB and �lling it in). New processes should be placed on
the tail
of the ready queue after being created. You should assign each
new
process a process identi�er. The process identi�er should be a
simple
integer value, and you should start numbering processes from 1.
ˆ For a done event, if a process is currently running it should
then be
released. It should be removed from the CPU, and not placed
back on
the ready or blocked queue. If a done occurs when the CPU is
idle,
then nothing will happen as a result of this event.
ˆ A wait event simulates the currently running process
performing some
I/O operation. If a wait occurs, the currently running process
should
become blocked and put on the blocked queue. You also need an
entry
in the PCB so you know what event the process is waiting for.
The
3
wait event is followed by an integer number, which is an
indication of
the type of event the process has requested.
ˆ Likewise the event directive simulates the �nishing of some
I/O oper-
ation. When an event occurs, you should scan your blocked
processes
and make any process ready that was waiting on that event. The
in-
teger value following an event indicates the type of event that
just
occurred.
You have been given some example event sequences
(simulation-01.sim,
simulation-02.sim, etc.) along with the expected output for
those sequence
of events (simulation-01.res, simulation-02.res, etc.). The
output of your
program should be sent to standard output. The correct output
for the
simulation-01.sim simulation is:
Time: 1
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 2
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 3
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=3,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 4
CPU (currently running):
4
pid=1, state=RUNNING, start=1, slice=4,
Ready Queue:
pid=2, state=READY, start=4, slice=0,
Blocked Queue:
EMPTY
Time: 5
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=5,
Ready Queue:
pid=2, state=READY, start=4, slice=0,
Blocked Queue:
EMPTY
Time: 6
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=1,
Ready Queue:
pid=1, state=READY, start=1, slice=5,
Blocked Queue:
EMPTY
Time: 7
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=2,
Ready Queue:
pid=1, state=READY, start=1, slice=5,
Blocked Queue:
EMPTY
Time: 8
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
pid=2, state=BLOCKED, start=4, slice=2, event=1
Time: 9
CPU (currently running):
5
pid=1, state=RUNNING, start=1, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
pid=2, state=BLOCKED, start=4, slice=2, event=1
Time: 10
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=3,
Ready Queue:
pid=2, state=READY, start=4, slice=2,
Blocked Queue:
EMPTY
Time: 11
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=4,
Ready Queue:
pid=2, state=READY, start=4, slice=2,
Blocked Queue:
EMPTY
Time: 12
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 13
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 14
CPU (currently running):
6
pid=2, state=RUNNING, start=4, slice=3,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 15
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=4,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Your output to standard out should look exactly the same as this
output
(i.e. if I do a di� and your program is generating the correct
output, then
there will be no di�erence between the output your program
generates and
the above output format). The output is generated by displaying
the system
state after each cpu cycle executes. Basically we print out the
system time.
Then we show which process (if any) is currently running on the
CPU (or
say it is IDLE if no process is running). Then we display the
queue of
processes currently on the Ready and Blocked queues. Note that
the queues
are displayed in order. The top of the output corresponds to the
head of the
queue. Thus when a new process is dispatched, the next one
selected should
be the �rst process listed from the ready queue in the previous
system cycle.
I have given you some template code (p2-start.cpp) to get you
started
The code is meant to be run from the command line, thus from a
shell or
dos prompt you would do something like:
$ p2-start simulation-01.sim 5
i.e. the program expects two parameters on the command line,
which
should be the name of a �le that holds the events to be
simulated, and the
value to be used for the time slice quantum. If you need to test
your program
and can't �gure out how to invoke running it from the command
line, you
can change the line in 'p2-start.cpp' to explicitly run a particular
simulation
�le, like this:
runSimulation("simulation-01.sim", time_slice_quantum)
7
However, you need to make sure that your program correctly
works using
the command line invocation, as shown in `p2-start.cpp`.
I have given some template code to get you started in the �le
called
p2-start.cpp. I have already provided you with the code needed
in order to
correctly parse the command line parameters for the program,
and to open
and read in the simulation �le events. Your job is to implement
the necessary
actions and data structures to handle the simulated events
described. The
runSimulation() in 'p2-start.cpp holds example code and
indicates locations
where you need to write your own functions to implement the
simulation.
You can use this as a starting point to implement your solution.
Assignment Submission and Requirements
All source �les you create for you solution (.c or .cpp/.c++ and
.h header
�les) should be uploaded to the MyLeo Online submission
folder created for
this assignment by the deadline. You should not attach any �les
besides the
source �les containing your C/C++ code. But you should make
sure you
attach all needed �les you create to your submission, so that I
can compile
and run your solution.
You are required to write the program in standard C/C++
programming
language. You should use a relatively recent version of the
C/C++ compiler
(C90 C++98 is �ne, or the more recent C99 C++11 will also be
acceptable),
and/or recent IDE that has an up to date compiler. You should
only use
standard C/C++ libraries, do not use Microsoft speci�c or other
third-party
developed external libraries. This page
http://en.cppreference.com/w/
provides a good up to date reference of the libraries in the
standard C++ and
C languages. You may use the C++ standard template library
containers
(like the list and queue items) to implement the ready queue you
need. We
will go over a simple implementation of a queue using pointers
and/or arrays
in class, if you would like an example implementation in plain
C that might
be simpler to use than learning the STL.
8
http://en.cppreference.com/w/
p2-start.cppp2-start.cpp/**
* @author Your Name Here
* @cwid 123 45 678
* @class CSci 430, Summer 2017
* @ide Visual Studio Express 2017
* @date June 11, 2017
* @assg Programming Assignment #2
*
* @description Implement a simulation of a basic 3 process sta
te system
* Ready, Running, Blocked. Simulation includes a round-
robin scheduler
* with time slice scheduling. Need to implement a basic Proc
ess
* Control Block (PCB) in order to implement the round robin
scheduler.
* Program will also have ready queues, and possible queues o
r other
* structures to keep track of blocked processes and the events
they
* are waiting on.
*
*/
#include<stdlib.h>
#include<iostream>
#include<fstream>
#include<string>
usingnamespace std;
/** The process simulator.
* The main loop for running a simulation. We read simulation
* events from a file
*
* @param simfilename The name of the file (e.g. simulaiton-
01.sim) to open
* and read simulated event sequence from.
* @param timeSliceQuantum The value to be used for system ti
me slicing preemption
* for this simulation.
*/
void runSimulation(char* simfilename,int timeSliceQuantum)
{
ifstream simeventsfile(simfilename);
string command;
int eventnum;
if(!simeventsfile.is_open())
{
cout <<"Error: could not open simulator events file: "<< simf
ilename << endl;
exit(1);
}
while(!simeventsfile.eof())
{
simeventsfile >> command;
// Handle the next simulated event we just read from the
// simulation event file
if(command =="cpu")
{
cout <<" cpu: simulate a cpu cycle here"<< endl;
}
elseif(command =="new")
{
cout <<" new: simulate creation of new process here"<< e
ndl;
}
elseif(command =="done")
{
cout <<" done: simulate termination of currently running p
rocess here"<< endl;
}
elseif(command =="wait")
{
simeventsfile >> eventnum;
cout <<" wait: eventnum: "<< eventnum <<
" simulate event blocked and waiting"<< endl;
}
elseif(command =="event")
{
simeventsfile >> eventnum;
cout <<" event: eventnum: "<< eventnum <<
" simulate event occurring possibly making some processes read
y"<< endl;
}
elseif(command =="exit")
{
// we use an explicit indicator to ensure simulation exits correctl
y
break;
}
else
{
cout <<" ERROR: unknown command: "<< command << e
ndl;
exit(0);
}
}
simeventsfile.close();
}
/** Main entry point of simulator
* The main entry point of the process simulator. We simply se
t up
* and initialize the environment, then call the appropriate func
tion
* to begin the simulation. We expect a single command line ar
gument
* which is the name of the simulation event file to process.
*
* @param argc The argument count
* @param argv The command line argument values. We expect
argv[1] to be the
* name of a file in the current directory holding proces
s events
* to simulate.
*/
int main(int argc,char** argv)
{
int timeSliceQuantum =0;
// validate command line arguments
if(argc !=3)
{
cout <<"Error: expecting event file as first command line par
ameter and time slice quantum as second"<< endl;
cout <<"Usage: "<< argv[0]<<" simeventfile.sim time_slice"
<< endl;
exit(1);
}
// Assume second command line argument is the time slice quan
tum and parse it
timeSliceQuantum = atoi(argv[2]);
if(timeSliceQuantum <=0)
{
cout <<"Error: invalid time slice quantum received: "<< time
SliceQuantum << endl;
exit(1);
}
// Invoke the function to actually run the simulation
runSimulation(argv[1], timeSliceQuantum);
// if don't want to use command line do following.
// need to recompile by hand since file
// name to get simulated events from is hard coded
//runSimulation("simulation-01.sim", 5);
return0;
}
p2-start.c
/**
* @author Your Name Here
* @cwid 123 45 678
* @class CSci 430, Summer 2017
* @ide Visual Studio Express 2017
* @date June 11, 2017
* @assg Programming Assignment #2
*
* @description Implement a simulation of a basic 3 process
state system
* Ready, Running, Blocked. Simulation includes a round-
robin scheduler
* with time slice scheduling. Need to implement a basic
Process
* Control Block (PCB) in order to implement the round robin
scheduler.
* Program will also have ready queues, and possible queues
or other
* structures to keep track of blocked processes and the events
they
* are waiting on.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/** The process simulator.
* The main loop for running a simulation. We read simulation
* events from a file
*
* @param simfilename The name of the file (e.g. simulaiton-
01.sim) to open
* and read simulated event sequence from.
* @param timeSliceQuantum The value to be used for system
time slicing preemption
* for this simulation.
*/
void runSimulation(char* simfilename, int timeSliceQuantum)
{
FILE* simeventsfile;
char line[256]; // temporary buffer to hold the whole line we
read in
char* command;
char* eventnumstr;
int eventnum;
// open the simulation file, and make sure we were successful
// before continuing
simeventsfile = fopen(simfilename, "r");
if (!simeventsfile)
{
fprintf(stderr, "Error: could not open simulator events file:
%sn", simfilename);
exit(1);
}
while (fgets(line, sizeof(line), simeventsfile))
{
// get first token from line, up to first whitespace character,
put into command
command = strtok(line, " tn"); // splits line on space, tab or
newline
// Handle the next simulated event we just read from the
// simulation event file
if (strcmp(command, "cpu") == 0)
{
printf(" cpu: simulate a cpu cycle heren");
}
else if (strcmp(command, "new") == 0)
{
printf(" new: simulate creation of a new process heren");
}
else if (strcmp(command, "done") == 0)
{
printf(" done: simulate termination of currently running
process heren");
}
else if (strcmp(command, "wait") == 0)
{
eventnumstr = strtok(NULL, " tn"); // get pointer to event
number string
sscanf(eventnumstr, "%d", &eventnum);
printf(" wait: eventnum: %d simulate event blocked and
waitingn", eventnum);
}
else if (strcmp(command, "event") == 0)
{
eventnumstr = strtok(NULL, " tn"); // get pointer to event
number string
sscanf(eventnumstr, "%d", &eventnum);
printf(" event: eventnum: %d simulate event occurring
possibly making some processes readyn", eventnum);
}
else if (strcmp(command, "exit") == 0)
{
// we use an explicit indicator to ensure simulation exits
correctly
break;
}
else
{
fprintf(stderr, "Error: unknown command: %sn",
command);
exit(0);
}
}
fclose(simeventsfile);
}
/** Main entry point of simulator
* The main entry point of the process simulator. We simply
set up
* and initialize the environment, then call the appropriate
function
* to begin the simulation. We expect a single command line
argument
* which is the name of the simulation event file to process.
*
* @param argc The argument count
* @param argv The command line argument values. We expect
argv[1] to be the
* name of a file in the current directory holding
process events
* to simulate.
*/
int main(int argc, char** argv)
{
int timeSliceQuantum = 0;
// validate command line arguments
if (argc != 3)
{
printf("Error: expecting event file as first command line
parameter and time slice quantum as secondn");
printf("Usage: %s simeventfile.sim time_slicen", argv[0]);
exit(1);
}
// Assume second command line argument is the time slice
quantum and parse it
timeSliceQuantum = atoi(argv[2]);
if (timeSliceQuantum <= 0)
{
printf("Error: invalid time slice quantum received: %dn",
timeSliceQuantum);
exit(1);
}
// Invoke the function to actually run the simulation
runSimulation(argv[1], timeSliceQuantum);
// if don't want to use command line do following.
// need to recompile by hand since file
// name to get simulated events from is hard coded
//runSimulation("simulation-01.sim", 5);
return 0;
}
prog-02.pdf
Programming Assignment #2
CSci 430 Spring 2019
Dates:
Assigned: Monday February 4, 2019
Due: Wednesday February 20, 2019 (before Midnight)
Objectives:
� Explore the Process state models from an implementation
point of
view.
� Practice using basic queue data types and implementing in C.
� Use C/C++ data structures to implement a process control
block and
round robin scheduling queues.
� Learn about Process switching and multiprogramming
concepts.
Description:
In this assignment you will simulate a Three-State process
model (ready,
running and blocked) and a simple process control block
structure as dis-
cussed in Chapter 3. Your program will read input and
directives from a
�le. The input describes a time sequence of events that occur.
These are the
full set of events you will simulate:
1
Event Description
cpu The processor executes for 1 time step the currently running
process
new A new process is created and put at tail of the ready queue
done The currently running process has �nished
wait X The currently running process has done an I/O operation
and
is waiting on event X
event X Event X has occurred, the process waiting on that event
should
be made ready.
The input �le will simply be a list of events that occur in the
system, in
the order they are to occur. For example:
----- simulation-01.sim --------
new
cpu
cpu
cpu
new
cpu
cpu
cpu
cpu
wait 1
cpu
cpu
event 1
cpu
cpu
done
cpu
cpu
cpu
cpu
exit
----------------------------------
Your task is to read in the events, and simulate the creation and
execution
of processes in the system as they move through the various
three-states of
their process life cycle. You need to:
2
� De�ne a simple process control block (PCB) to hold
information about
all processes currently running in your system. The PCB can be
a
simple C struct or a C++ class. At a minimum you need to have
a
�eld for the process identi�er and the process state (Ready,
Running or
Blocked). You need to also keep track of the time step that the
process
entered the system, and the number of steps the process has
been
running. Minimal credit will be given to programs that at least
handle
new events and create a process in a simulated PCB. You
probably
need a list or an array to hold the current processes that have
been
created and are being managed by your simulated system.
� You will need a ready queue of some kind. You should use a
C++
Standard Template Library (STL) container to manage your
ready
queue.
� You will need to implement a simple dispatcher function.
Whenever
a cpu event occurs, and no process is currently running, you
should
select the next Ready process from the head of your ready queue
and
start it running on the processor.
� You need to also implement a simple time slicing mechanism.
The
time slice value to use will be passed into your program when it
is
started. At the end of a cpu cycle, you should check if the
currently
running process has executed for its full time quantum. In that
case,
the currently running process should timeout, and be returned to
the
end of the Ready queue.
� new events should cause a new process to be created
(including creating
its PCB and �lling it in). New processes should be placed on
the tail
of the ready queue after being created. You should assign each
new
process a process identi�er. The process identi�er should be a
simple
integer value, and you should start numbering processes from 1.
� For a done event, if a process is currently running it should
then be
released. It should be removed from the CPU, and not placed
back on
the ready or blocked queue. If a done occurs when the CPU is
idle,
then nothing will happen as a result of this event.
� A wait event simulates the currently running process
performing some
I/O operation. If a wait occurs, the currently running process
should
become blocked and put on the blocked queue. You also need an
entry
in the PCB so you know what event the process is waiting for.
The
3
wait event is followed by an integer number, which is an
indication of
the type of event the process has requested.
� Likewise the event directive simulates the �nishing of some
I/O oper-
ation. When an event occurs, you should scan your blocked
processes
and make any process ready that was waiting on that event. The
in-
teger value following an event indicates the type of event that
just
occurred.
You have been given some example event sequences
(simulation-01.sim,
simulation-02.sim, etc.) along with the expected output for
those sequence
of events (simulation-01.res, simulation-02.res, etc.). The
output of your
program should be sent to standard output. The correct output
for the
simulation-01.sim simulation is:
Time: 1
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 2
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 3
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=3,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 4
CPU (currently running):
4
pid=1, state=RUNNING, start=1, slice=4,
Ready Queue:
pid=2, state=READY, start=4, slice=0,
Blocked Queue:
EMPTY
Time: 5
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=5,
Ready Queue:
pid=2, state=READY, start=4, slice=0,
Blocked Queue:
EMPTY
Time: 6
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=1,
Ready Queue:
pid=1, state=READY, start=1, slice=5,
Blocked Queue:
EMPTY
Time: 7
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=2,
Ready Queue:
pid=1, state=READY, start=1, slice=5,
Blocked Queue:
EMPTY
Time: 8
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
pid=2, state=BLOCKED, start=4, slice=2, event=1
Time: 9
CPU (currently running):
5
pid=1, state=RUNNING, start=1, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
pid=2, state=BLOCKED, start=4, slice=2, event=1
Time: 10
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=3,
Ready Queue:
pid=2, state=READY, start=4, slice=2,
Blocked Queue:
EMPTY
Time: 11
CPU (currently running):
pid=1, state=RUNNING, start=1, slice=4,
Ready Queue:
pid=2, state=READY, start=4, slice=2,
Blocked Queue:
EMPTY
Time: 12
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=1,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 13
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=2,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 14
CPU (currently running):
6
pid=2, state=RUNNING, start=4, slice=3,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Time: 15
CPU (currently running):
pid=2, state=RUNNING, start=4, slice=4,
Ready Queue:
EMPTY
Blocked Queue:
EMPTY
Your output to standard out should look exactly the same as this
output
(i.e. if I do a di� and your program is generating the correct
output, then
there will be no di�erence between the output your program
generates and
the above output format). The output is generated by displaying
the system
state after each cpu cycle executes. Basically we print out the
system time.
Then we show which process (if any) is currently running on the
CPU (or
say it is IDLE if no process is running). Then we display the
queue of
processes currently on the Ready and Blocked queues. Note that
the queues
are displayed in order. The top of the output corresponds to the
head of the
queue. Thus when a new process is dispatched, the next one
selected should
be the �rst process listed from the ready queue in the previous
system cycle.
I have given you some template code (p2-start.cpp) to get you
started
The code is meant to be run from the command line, thus from a
shell or
dos prompt you would do something like:
$ p2-start simulation-01.sim 5
i.e. the program expects two parameters on the command line,
which
should be the name of a �le that holds the events to be
simulated, and the
value to be used for the time slice quantum. If you need to test
your program
and can't �gure out how to invoke running it from the command
line, you
can change the line in 'p2-start.cpp' to explicitly run a particular
simulation
�le, like this:
runSimulation("simulation-01.sim", time_slice_quantum)
7
However, you need to make sure that your program correctly
works using
the command line invocation, as shown in `p2-start.cpp`.
I have given some template code to get you started in the �le
called
p2-start.cpp. I have already provided you with the code needed
in order to
correctly parse the command line parameters for the program,
and to open
and read in the simulation �le events. Your job is to implement
the necessary
actions and data structures to handle the simulated events
described. The
runSimulation() in 'p2-start.cpp holds example code and
indicates locations
where you need to write your own functions to implement the
simulation.
You can use this as a starting point to implement your solution.
Assignment Submission and Requirements
All source �les you create for you solution (.c or .cpp/.c++ and
.h header
�les) should be uploaded to the MyLeo Online submission
folder created for
this assignment by the deadline. You should not attach any �les
besides the
source �les containing your C/C++ code. But you should make
sure you
attach all needed �les you create to your submission, so that I
can compile
and run your solution.
You are required to write the program in standard C/C++
programming
language. You should use a relatively recent version of the
C/C++ compiler
(C90 C++98 is �ne, or the more recent C99 C++11 will also be
acceptable),
and/or recent IDE that has an up to date compiler. You should
only use
standard C/C++ libraries, do not use Microsoft speci�c or other
third-party
developed external libraries. This page
http://en.cppreference.com/w/
provides a good up to date reference of the libraries in the
standard C++ and
C languages. You may use the C++ standard template library
containers
(like the list and queue items) to implement the ready queue you
need. We
will go over a simple implementation of a queue using pointers
and/or arrays
in class, if you would like an example implementation in plain
C that might
be simpler to use than learning the STL.
8
http://en.cppreference.com/w/
simulation-01.sim
new
cpu
cpu
cpu
new
cpu
cpu
cpu
cpu
wait 1
cpu
cpu
event 1
cpu
cpu
done
cpu
cpu
cpu
cpu
exit
simulation-01.res
simulation-02.sim
new
cpu
new
cpu
new
cpu
cpu
cpu
cpu
cpu
wait 2
cpu
cpu
wait 1
cpu
event 2
event 1
cpu
cpu
cpu
cpu
cpu
cpu
cpu
done
cpu
cpu
cpu
done
cpu
cpu
done
exit
simulation-02.res
simulation-03.sim
new
cpu
cpu
cpu
new
new
new
cpu
cpu
cpu
cpu
wait 1
cpu
wait 1
cpu
cpu
wait 1
cpu
new
new
cpu
cpu
cpu
event 1
cpu
cpu
cpu
cpu
cpu
cpu
cpu
new
new
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
wait 1
cpu
cpu
wait 2
cpu
cpu
cpu
wait 3
cpu
cpu
event 2
cpu
cpu
cpu
cpu
wait 2
cpu
cpu
cpu
event 1
cpu
cpu
event 3
cpu
cpu
cpu
cpu
cpu
done
cpu
cpu
cpu
cpu
done
event 2
cpu
cpu
cpu
wait 1
cpu
cpu
cpu
cpu
cpu
done
cpu
done
event 1
cpu
cpu
done
cpu
cpu
exit
simulation-03.res
simulation-04.sim
new
new
cpu
cpu
cpu
cpu
done
new
cpu
cpu
cpu
cpu
wait 1
cpu
done
cpu
wait 1
cpu
cpu
new
new
cpu
cpu
event 1
done
cpu
cpu
cpu
cpu
done
cpu
cpu
done
cpu
cpu
new
new
cpu
cpu
wait 3
cpu
done
new
new
new
cpu
wait 4
cpu
event 3
cpu
done
new
cpu
cpu
cpu
event 4
cpu
cpu
cpu
done
cpu
cpu
cpu
cpu
cpu
cpu
done
cpu
cpu
done
cpu
exit
simulation-04.res
simulation-05.sim
new
new
new
new
new
new
cpu
cpu
done
cpu
cpu
done
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
wait 1
cpu
wait 1
cpu
wait 1
cpu
wait 1
cpu
wait 1
cpu
wait 1
cpu
wait 1
cpu
event 1
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
cpu
simulation-05-quantum5.res
simulation-05-quantum8.res

More Related Content

Similar to Programming Assignment #2CSci 430 Spring 2019Dates.docx

Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxSheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxbagotjesusa
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Controlahmad bassiouny
 
Operator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxOperator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxcherishwinsland
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104swena_gupta
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevelsJohn Ombagi
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communicationecomputernotes
 
parellel computing
parellel computingparellel computing
parellel computingkatakdound
 
Os2 2
Os2 2Os2 2
Os2 2issbp
 
Kernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easyKernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easyAnne Nicolas
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docxfelicidaddinwoodie
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2HectorFabianPintoOsp
 
Process management
Process managementProcess management
Process managementBirju Tank
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10duquoi
 
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docx
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docxprog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docx
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docxstilliegeorgiana
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++cpjcollege
 

Similar to Programming Assignment #2CSci 430 Spring 2019Dates.docx (20)

Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxSheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
 
Processes And Job Control
Processes And Job ControlProcesses And Job Control
Processes And Job Control
 
Operator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxOperator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docx
 
Os lab final
Os lab finalOs lab final
Os lab final
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Linux : Booting and runlevels
Linux : Booting and runlevelsLinux : Booting and runlevels
Linux : Booting and runlevels
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
computer notes - Inter process communication
computer notes - Inter process communicationcomputer notes - Inter process communication
computer notes - Inter process communication
 
parellel computing
parellel computingparellel computing
parellel computing
 
Os2 2
Os2 2Os2 2
Os2 2
 
Kernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easyKernel Recipes 2019 - Formal modeling made easy
Kernel Recipes 2019 - Formal modeling made easy
 
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docx
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
 
Process management
Process managementProcess management
Process management
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 
Process
ProcessProcess
Process
 
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docx
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docxprog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docx
prog-05.pdfProgramming Assignment #5CSci 430, Spring 2.docx
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 

More from denneymargareta

For this piece of the Humanities Project, submit your topic choice a.docx
For this piece of the Humanities Project, submit your topic choice a.docxFor this piece of the Humanities Project, submit your topic choice a.docx
For this piece of the Humanities Project, submit your topic choice a.docxdenneymargareta
 
For this weeks discussion, pick ONE of the following to answer in a.docx
For this weeks discussion, pick ONE of the following to answer in a.docxFor this weeks discussion, pick ONE of the following to answer in a.docx
For this weeks discussion, pick ONE of the following to answer in a.docxdenneymargareta
 
For this weeks discussion, review the normal profiles for childre.docx
For this weeks discussion, review the normal profiles for childre.docxFor this weeks discussion, review the normal profiles for childre.docx
For this weeks discussion, review the normal profiles for childre.docxdenneymargareta
 
For this project, you will be exploring the developments in material.docx
For this project, you will be exploring the developments in material.docxFor this project, you will be exploring the developments in material.docx
For this project, you will be exploring the developments in material.docxdenneymargareta
 
For this Discussion, you will explore the nature of globalization an.docx
For this Discussion, you will explore the nature of globalization an.docxFor this Discussion, you will explore the nature of globalization an.docx
For this Discussion, you will explore the nature of globalization an.docxdenneymargareta
 
For this Discussion, you will assess the roles of culture and divers.docx
For this Discussion, you will assess the roles of culture and divers.docxFor this Discussion, you will assess the roles of culture and divers.docx
For this Discussion, you will assess the roles of culture and divers.docxdenneymargareta
 
For this discussion, choose one of challenges to overcome in helping.docx
For this discussion, choose one of challenges to overcome in helping.docxFor this discussion, choose one of challenges to overcome in helping.docx
For this discussion, choose one of challenges to overcome in helping.docxdenneymargareta
 
For this Discussion imagine that you are speaking to a group of pare.docx
For this Discussion imagine that you are speaking to a group of pare.docxFor this Discussion imagine that you are speaking to a group of pare.docx
For this Discussion imagine that you are speaking to a group of pare.docxdenneymargareta
 
For this Discussion Board, write about some part of the videos that .docx
For this Discussion Board, write about some part of the videos that .docxFor this Discussion Board, write about some part of the videos that .docx
For this Discussion Board, write about some part of the videos that .docxdenneymargareta
 
For this Assignment,choose one sexual attitude (e.g., abstinence.docx
For this Assignment,choose one sexual attitude (e.g., abstinence.docxFor this Assignment,choose one sexual attitude (e.g., abstinence.docx
For this Assignment,choose one sexual attitude (e.g., abstinence.docxdenneymargareta
 
For this assignment, you will use your Intercultural Interview from .docx
For this assignment, you will use your Intercultural Interview from .docxFor this assignment, you will use your Intercultural Interview from .docx
For this assignment, you will use your Intercultural Interview from .docxdenneymargareta
 
For this assignment, you will research an issue related to informati.docx
For this assignment, you will research an issue related to informati.docxFor this assignment, you will research an issue related to informati.docx
For this assignment, you will research an issue related to informati.docxdenneymargareta
 
For this assignment, you will explore the official sources of crime .docx
For this assignment, you will explore the official sources of crime .docxFor this assignment, you will explore the official sources of crime .docx
For this assignment, you will explore the official sources of crime .docxdenneymargareta
 
For this assignment, prepare a paper to evaluate the following quest.docx
For this assignment, prepare a paper to evaluate the following quest.docxFor this assignment, prepare a paper to evaluate the following quest.docx
For this assignment, prepare a paper to evaluate the following quest.docxdenneymargareta
 
For this assignment, Conduct a thorough case study analysis of the c.docx
For this assignment, Conduct a thorough case study analysis of the c.docxFor this assignment, Conduct a thorough case study analysis of the c.docx
For this assignment, Conduct a thorough case study analysis of the c.docxdenneymargareta
 
For this Assignment, choose a discreet environmental policy issue th.docx
For this Assignment, choose a discreet environmental policy issue th.docxFor this Assignment, choose a discreet environmental policy issue th.docx
For this Assignment, choose a discreet environmental policy issue th.docxdenneymargareta
 
For this assignment, you are going to use your skills of research an.docx
For this assignment, you are going to use your skills of research an.docxFor this assignment, you are going to use your skills of research an.docx
For this assignment, you are going to use your skills of research an.docxdenneymargareta
 
For the Final Project, you will assume the role of a classroom teach.docx
For the Final Project, you will assume the role of a classroom teach.docxFor the Final Project, you will assume the role of a classroom teach.docx
For the Final Project, you will assume the role of a classroom teach.docxdenneymargareta
 
For the first part of your final project, the critical analysis  por.docx
For the first part of your final project, the critical analysis  por.docxFor the first part of your final project, the critical analysis  por.docx
For the first part of your final project, the critical analysis  por.docxdenneymargareta
 
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docx
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docxFOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docx
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docxdenneymargareta
 

More from denneymargareta (20)

For this piece of the Humanities Project, submit your topic choice a.docx
For this piece of the Humanities Project, submit your topic choice a.docxFor this piece of the Humanities Project, submit your topic choice a.docx
For this piece of the Humanities Project, submit your topic choice a.docx
 
For this weeks discussion, pick ONE of the following to answer in a.docx
For this weeks discussion, pick ONE of the following to answer in a.docxFor this weeks discussion, pick ONE of the following to answer in a.docx
For this weeks discussion, pick ONE of the following to answer in a.docx
 
For this weeks discussion, review the normal profiles for childre.docx
For this weeks discussion, review the normal profiles for childre.docxFor this weeks discussion, review the normal profiles for childre.docx
For this weeks discussion, review the normal profiles for childre.docx
 
For this project, you will be exploring the developments in material.docx
For this project, you will be exploring the developments in material.docxFor this project, you will be exploring the developments in material.docx
For this project, you will be exploring the developments in material.docx
 
For this Discussion, you will explore the nature of globalization an.docx
For this Discussion, you will explore the nature of globalization an.docxFor this Discussion, you will explore the nature of globalization an.docx
For this Discussion, you will explore the nature of globalization an.docx
 
For this Discussion, you will assess the roles of culture and divers.docx
For this Discussion, you will assess the roles of culture and divers.docxFor this Discussion, you will assess the roles of culture and divers.docx
For this Discussion, you will assess the roles of culture and divers.docx
 
For this discussion, choose one of challenges to overcome in helping.docx
For this discussion, choose one of challenges to overcome in helping.docxFor this discussion, choose one of challenges to overcome in helping.docx
For this discussion, choose one of challenges to overcome in helping.docx
 
For this Discussion imagine that you are speaking to a group of pare.docx
For this Discussion imagine that you are speaking to a group of pare.docxFor this Discussion imagine that you are speaking to a group of pare.docx
For this Discussion imagine that you are speaking to a group of pare.docx
 
For this Discussion Board, write about some part of the videos that .docx
For this Discussion Board, write about some part of the videos that .docxFor this Discussion Board, write about some part of the videos that .docx
For this Discussion Board, write about some part of the videos that .docx
 
For this Assignment,choose one sexual attitude (e.g., abstinence.docx
For this Assignment,choose one sexual attitude (e.g., abstinence.docxFor this Assignment,choose one sexual attitude (e.g., abstinence.docx
For this Assignment,choose one sexual attitude (e.g., abstinence.docx
 
For this assignment, you will use your Intercultural Interview from .docx
For this assignment, you will use your Intercultural Interview from .docxFor this assignment, you will use your Intercultural Interview from .docx
For this assignment, you will use your Intercultural Interview from .docx
 
For this assignment, you will research an issue related to informati.docx
For this assignment, you will research an issue related to informati.docxFor this assignment, you will research an issue related to informati.docx
For this assignment, you will research an issue related to informati.docx
 
For this assignment, you will explore the official sources of crime .docx
For this assignment, you will explore the official sources of crime .docxFor this assignment, you will explore the official sources of crime .docx
For this assignment, you will explore the official sources of crime .docx
 
For this assignment, prepare a paper to evaluate the following quest.docx
For this assignment, prepare a paper to evaluate the following quest.docxFor this assignment, prepare a paper to evaluate the following quest.docx
For this assignment, prepare a paper to evaluate the following quest.docx
 
For this assignment, Conduct a thorough case study analysis of the c.docx
For this assignment, Conduct a thorough case study analysis of the c.docxFor this assignment, Conduct a thorough case study analysis of the c.docx
For this assignment, Conduct a thorough case study analysis of the c.docx
 
For this Assignment, choose a discreet environmental policy issue th.docx
For this Assignment, choose a discreet environmental policy issue th.docxFor this Assignment, choose a discreet environmental policy issue th.docx
For this Assignment, choose a discreet environmental policy issue th.docx
 
For this assignment, you are going to use your skills of research an.docx
For this assignment, you are going to use your skills of research an.docxFor this assignment, you are going to use your skills of research an.docx
For this assignment, you are going to use your skills of research an.docx
 
For the Final Project, you will assume the role of a classroom teach.docx
For the Final Project, you will assume the role of a classroom teach.docxFor the Final Project, you will assume the role of a classroom teach.docx
For the Final Project, you will assume the role of a classroom teach.docx
 
For the first part of your final project, the critical analysis  por.docx
For the first part of your final project, the critical analysis  por.docxFor the first part of your final project, the critical analysis  por.docx
For the first part of your final project, the critical analysis  por.docx
 
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docx
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docxFOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docx
FOR THE CRIMINAL ( Name will be given when bid is accepted)  DO THE .docx
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

Programming Assignment #2CSci 430 Spring 2019Dates.docx

  • 1. Programming Assignment #2 CSci 430 Spring 2019 Dates: Assigned: Monday February 4, 2019 Due: Wednesday February 20, 2019 (before Midnight) Objectives: ˆ Explore the Process state models from an implementation point of view. ˆ Practice using basic queue data types and implementing in C. ˆ Use C/C++ data structures to implement a process control block and round robin scheduling queues. ˆ Learn about Process switching and multiprogramming concepts. Description: In this assignment you will simulate a Three-State process model (ready, running and blocked) and a simple process control block structure as dis- cussed in Chapter 3. Your program will read input and directives from a
  • 2. �le. The input describes a time sequence of events that occur. These are the full set of events you will simulate: 1 Event Description cpu The processor executes for 1 time step the currently running process new A new process is created and put at tail of the ready queue done The currently running process has �nished wait X The currently running process has done an I/O operation and is waiting on event X event X Event X has occurred, the process waiting on that event should be made ready. The input �le will simply be a list of events that occur in the system, in the order they are to occur. For example: ----- simulation-01.sim -------- new cpu cpu cpu
  • 4. Your task is to read in the events, and simulate the creation and execution of processes in the system as they move through the various three-states of their process life cycle. You need to: 2 ˆ De�ne a simple process control block (PCB) to hold information about all processes currently running in your system. The PCB can be a simple C struct or a C++ class. At a minimum you need to have a �eld for the process identi�er and the process state (Ready, Running or Blocked). You need to also keep track of the time step that the process entered the system, and the number of steps the process has been running. Minimal credit will be given to programs that at least handle new events and create a process in a simulated PCB. You probably need a list or an array to hold the current processes that have been created and are being managed by your simulated system. ˆ You will need a ready queue of some kind. You should use a C++ Standard Template Library (STL) container to manage your ready queue.
  • 5. ˆ You will need to implement a simple dispatcher function. Whenever a cpu event occurs, and no process is currently running, you should select the next Ready process from the head of your ready queue and start it running on the processor. ˆ You need to also implement a simple time slicing mechanism. The time slice value to use will be passed into your program when it is started. At the end of a cpu cycle, you should check if the currently running process has executed for its full time quantum. In that case, the currently running process should timeout, and be returned to the end of the Ready queue. ˆ new events should cause a new process to be created (including creating its PCB and �lling it in). New processes should be placed on the tail of the ready queue after being created. You should assign each new process a process identi�er. The process identi�er should be a simple integer value, and you should start numbering processes from 1. ˆ For a done event, if a process is currently running it should then be released. It should be removed from the CPU, and not placed back on the ready or blocked queue. If a done occurs when the CPU is
  • 6. idle, then nothing will happen as a result of this event. ˆ A wait event simulates the currently running process performing some I/O operation. If a wait occurs, the currently running process should become blocked and put on the blocked queue. You also need an entry in the PCB so you know what event the process is waiting for. The 3 wait event is followed by an integer number, which is an indication of the type of event the process has requested. ˆ Likewise the event directive simulates the �nishing of some I/O oper- ation. When an event occurs, you should scan your blocked processes and make any process ready that was waiting on that event. The in- teger value following an event indicates the type of event that just occurred. You have been given some example event sequences (simulation-01.sim, simulation-02.sim, etc.) along with the expected output for those sequence of events (simulation-01.res, simulation-02.res, etc.). The output of your
  • 7. program should be sent to standard output. The correct output for the simulation-01.sim simulation is: Time: 1 CPU (currently running): pid=1, state=RUNNING, start=1, slice=1, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 2 CPU (currently running): pid=1, state=RUNNING, start=1, slice=2, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 3 CPU (currently running):
  • 8. pid=1, state=RUNNING, start=1, slice=3, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 4 CPU (currently running): 4 pid=1, state=RUNNING, start=1, slice=4, Ready Queue: pid=2, state=READY, start=4, slice=0, Blocked Queue: EMPTY Time: 5 CPU (currently running): pid=1, state=RUNNING, start=1, slice=5, Ready Queue:
  • 9. pid=2, state=READY, start=4, slice=0, Blocked Queue: EMPTY Time: 6 CPU (currently running): pid=2, state=RUNNING, start=4, slice=1, Ready Queue: pid=1, state=READY, start=1, slice=5, Blocked Queue: EMPTY Time: 7 CPU (currently running): pid=2, state=RUNNING, start=4, slice=2, Ready Queue: pid=1, state=READY, start=1, slice=5, Blocked Queue: EMPTY Time: 8
  • 10. CPU (currently running): pid=1, state=RUNNING, start=1, slice=1, Ready Queue: EMPTY Blocked Queue: pid=2, state=BLOCKED, start=4, slice=2, event=1 Time: 9 CPU (currently running): 5 pid=1, state=RUNNING, start=1, slice=2, Ready Queue: EMPTY Blocked Queue: pid=2, state=BLOCKED, start=4, slice=2, event=1 Time: 10 CPU (currently running): pid=1, state=RUNNING, start=1, slice=3,
  • 11. Ready Queue: pid=2, state=READY, start=4, slice=2, Blocked Queue: EMPTY Time: 11 CPU (currently running): pid=1, state=RUNNING, start=1, slice=4, Ready Queue: pid=2, state=READY, start=4, slice=2, Blocked Queue: EMPTY Time: 12 CPU (currently running): pid=2, state=RUNNING, start=4, slice=1, Ready Queue: EMPTY Blocked Queue: EMPTY
  • 12. Time: 13 CPU (currently running): pid=2, state=RUNNING, start=4, slice=2, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 14 CPU (currently running): 6 pid=2, state=RUNNING, start=4, slice=3, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 15 CPU (currently running):
  • 13. pid=2, state=RUNNING, start=4, slice=4, Ready Queue: EMPTY Blocked Queue: EMPTY Your output to standard out should look exactly the same as this output (i.e. if I do a di� and your program is generating the correct output, then there will be no di�erence between the output your program generates and the above output format). The output is generated by displaying the system state after each cpu cycle executes. Basically we print out the system time. Then we show which process (if any) is currently running on the CPU (or say it is IDLE if no process is running). Then we display the queue of processes currently on the Ready and Blocked queues. Note that the queues are displayed in order. The top of the output corresponds to the head of the queue. Thus when a new process is dispatched, the next one selected should be the �rst process listed from the ready queue in the previous system cycle. I have given you some template code (p2-start.cpp) to get you started The code is meant to be run from the command line, thus from a
  • 14. shell or dos prompt you would do something like: $ p2-start simulation-01.sim 5 i.e. the program expects two parameters on the command line, which should be the name of a �le that holds the events to be simulated, and the value to be used for the time slice quantum. If you need to test your program and can't �gure out how to invoke running it from the command line, you can change the line in 'p2-start.cpp' to explicitly run a particular simulation �le, like this: runSimulation("simulation-01.sim", time_slice_quantum) 7 However, you need to make sure that your program correctly works using the command line invocation, as shown in `p2-start.cpp`. I have given some template code to get you started in the �le called p2-start.cpp. I have already provided you with the code needed in order to correctly parse the command line parameters for the program, and to open and read in the simulation �le events. Your job is to implement the necessary actions and data structures to handle the simulated events
  • 15. described. The runSimulation() in 'p2-start.cpp holds example code and indicates locations where you need to write your own functions to implement the simulation. You can use this as a starting point to implement your solution. Assignment Submission and Requirements All source �les you create for you solution (.c or .cpp/.c++ and .h header �les) should be uploaded to the MyLeo Online submission folder created for this assignment by the deadline. You should not attach any �les besides the source �les containing your C/C++ code. But you should make sure you attach all needed �les you create to your submission, so that I can compile and run your solution. You are required to write the program in standard C/C++ programming language. You should use a relatively recent version of the C/C++ compiler (C90 C++98 is �ne, or the more recent C99 C++11 will also be acceptable), and/or recent IDE that has an up to date compiler. You should only use standard C/C++ libraries, do not use Microsoft speci�c or other third-party developed external libraries. This page http://en.cppreference.com/w/ provides a good up to date reference of the libraries in the standard C++ and C languages. You may use the C++ standard template library
  • 16. containers (like the list and queue items) to implement the ready queue you need. We will go over a simple implementation of a queue using pointers and/or arrays in class, if you would like an example implementation in plain C that might be simpler to use than learning the STL. 8 http://en.cppreference.com/w/ p2-start.cppp2-start.cpp/** * @author Your Name Here * @cwid 123 45 678 * @class CSci 430, Summer 2017 * @ide Visual Studio Express 2017 * @date June 11, 2017 * @assg Programming Assignment #2 * * @description Implement a simulation of a basic 3 process sta te system * Ready, Running, Blocked. Simulation includes a round- robin scheduler * with time slice scheduling. Need to implement a basic Proc ess * Control Block (PCB) in order to implement the round robin scheduler. * Program will also have ready queues, and possible queues o r other * structures to keep track of blocked processes and the events they * are waiting on. *
  • 17. */ #include<stdlib.h> #include<iostream> #include<fstream> #include<string> usingnamespace std; /** The process simulator. * The main loop for running a simulation. We read simulation * events from a file * * @param simfilename The name of the file (e.g. simulaiton- 01.sim) to open * and read simulated event sequence from. * @param timeSliceQuantum The value to be used for system ti me slicing preemption * for this simulation. */ void runSimulation(char* simfilename,int timeSliceQuantum) { ifstream simeventsfile(simfilename); string command; int eventnum; if(!simeventsfile.is_open()) { cout <<"Error: could not open simulator events file: "<< simf ilename << endl; exit(1); } while(!simeventsfile.eof()) { simeventsfile >> command;
  • 18. // Handle the next simulated event we just read from the // simulation event file if(command =="cpu") { cout <<" cpu: simulate a cpu cycle here"<< endl; } elseif(command =="new") { cout <<" new: simulate creation of new process here"<< e ndl; } elseif(command =="done") { cout <<" done: simulate termination of currently running p rocess here"<< endl; } elseif(command =="wait") { simeventsfile >> eventnum; cout <<" wait: eventnum: "<< eventnum << " simulate event blocked and waiting"<< endl; } elseif(command =="event") { simeventsfile >> eventnum; cout <<" event: eventnum: "<< eventnum << " simulate event occurring possibly making some processes read y"<< endl; } elseif(command =="exit") { // we use an explicit indicator to ensure simulation exits correctl y break; }
  • 19. else { cout <<" ERROR: unknown command: "<< command << e ndl; exit(0); } } simeventsfile.close(); } /** Main entry point of simulator * The main entry point of the process simulator. We simply se t up * and initialize the environment, then call the appropriate func tion * to begin the simulation. We expect a single command line ar gument * which is the name of the simulation event file to process. * * @param argc The argument count * @param argv The command line argument values. We expect argv[1] to be the * name of a file in the current directory holding proces s events * to simulate. */ int main(int argc,char** argv) { int timeSliceQuantum =0; // validate command line arguments if(argc !=3) { cout <<"Error: expecting event file as first command line par
  • 20. ameter and time slice quantum as second"<< endl; cout <<"Usage: "<< argv[0]<<" simeventfile.sim time_slice" << endl; exit(1); } // Assume second command line argument is the time slice quan tum and parse it timeSliceQuantum = atoi(argv[2]); if(timeSliceQuantum <=0) { cout <<"Error: invalid time slice quantum received: "<< time SliceQuantum << endl; exit(1); } // Invoke the function to actually run the simulation runSimulation(argv[1], timeSliceQuantum); // if don't want to use command line do following. // need to recompile by hand since file // name to get simulated events from is hard coded //runSimulation("simulation-01.sim", 5); return0; } p2-start.c /** * @author Your Name Here * @cwid 123 45 678 * @class CSci 430, Summer 2017 * @ide Visual Studio Express 2017 * @date June 11, 2017 * @assg Programming Assignment #2
  • 21. * * @description Implement a simulation of a basic 3 process state system * Ready, Running, Blocked. Simulation includes a round- robin scheduler * with time slice scheduling. Need to implement a basic Process * Control Block (PCB) in order to implement the round robin scheduler. * Program will also have ready queues, and possible queues or other * structures to keep track of blocked processes and the events they * are waiting on. * */ #include <stdlib.h> #include <stdio.h> #include <string.h> /** The process simulator. * The main loop for running a simulation. We read simulation * events from a file * * @param simfilename The name of the file (e.g. simulaiton- 01.sim) to open * and read simulated event sequence from. * @param timeSliceQuantum The value to be used for system time slicing preemption * for this simulation. */ void runSimulation(char* simfilename, int timeSliceQuantum) { FILE* simeventsfile; char line[256]; // temporary buffer to hold the whole line we
  • 22. read in char* command; char* eventnumstr; int eventnum; // open the simulation file, and make sure we were successful // before continuing simeventsfile = fopen(simfilename, "r"); if (!simeventsfile) { fprintf(stderr, "Error: could not open simulator events file: %sn", simfilename); exit(1); } while (fgets(line, sizeof(line), simeventsfile)) { // get first token from line, up to first whitespace character, put into command command = strtok(line, " tn"); // splits line on space, tab or newline // Handle the next simulated event we just read from the // simulation event file if (strcmp(command, "cpu") == 0) { printf(" cpu: simulate a cpu cycle heren"); } else if (strcmp(command, "new") == 0) { printf(" new: simulate creation of a new process heren"); } else if (strcmp(command, "done") == 0) { printf(" done: simulate termination of currently running process heren");
  • 23. } else if (strcmp(command, "wait") == 0) { eventnumstr = strtok(NULL, " tn"); // get pointer to event number string sscanf(eventnumstr, "%d", &eventnum); printf(" wait: eventnum: %d simulate event blocked and waitingn", eventnum); } else if (strcmp(command, "event") == 0) { eventnumstr = strtok(NULL, " tn"); // get pointer to event number string sscanf(eventnumstr, "%d", &eventnum); printf(" event: eventnum: %d simulate event occurring possibly making some processes readyn", eventnum); } else if (strcmp(command, "exit") == 0) { // we use an explicit indicator to ensure simulation exits correctly break; } else { fprintf(stderr, "Error: unknown command: %sn", command); exit(0); } } fclose(simeventsfile); } /** Main entry point of simulator
  • 24. * The main entry point of the process simulator. We simply set up * and initialize the environment, then call the appropriate function * to begin the simulation. We expect a single command line argument * which is the name of the simulation event file to process. * * @param argc The argument count * @param argv The command line argument values. We expect argv[1] to be the * name of a file in the current directory holding process events * to simulate. */ int main(int argc, char** argv) { int timeSliceQuantum = 0; // validate command line arguments if (argc != 3) { printf("Error: expecting event file as first command line parameter and time slice quantum as secondn"); printf("Usage: %s simeventfile.sim time_slicen", argv[0]); exit(1); } // Assume second command line argument is the time slice quantum and parse it timeSliceQuantum = atoi(argv[2]); if (timeSliceQuantum <= 0) { printf("Error: invalid time slice quantum received: %dn", timeSliceQuantum); exit(1);
  • 25. } // Invoke the function to actually run the simulation runSimulation(argv[1], timeSliceQuantum); // if don't want to use command line do following. // need to recompile by hand since file // name to get simulated events from is hard coded //runSimulation("simulation-01.sim", 5); return 0; } prog-02.pdf Programming Assignment #2 CSci 430 Spring 2019 Dates: Assigned: Monday February 4, 2019 Due: Wednesday February 20, 2019 (before Midnight) Objectives: � Explore the Process state models from an implementation point of view. � Practice using basic queue data types and implementing in C. � Use C/C++ data structures to implement a process control block and
  • 26. round robin scheduling queues. � Learn about Process switching and multiprogramming concepts. Description: In this assignment you will simulate a Three-State process model (ready, running and blocked) and a simple process control block structure as dis- cussed in Chapter 3. Your program will read input and directives from a �le. The input describes a time sequence of events that occur. These are the full set of events you will simulate: 1 Event Description cpu The processor executes for 1 time step the currently running process new A new process is created and put at tail of the ready queue done The currently running process has �nished wait X The currently running process has done an I/O operation and is waiting on event X event X Event X has occurred, the process waiting on that event should be made ready.
  • 27. The input �le will simply be a list of events that occur in the system, in the order they are to occur. For example: ----- simulation-01.sim -------- new cpu cpu cpu new cpu cpu cpu cpu wait 1 cpu cpu event 1 cpu cpu
  • 28. done cpu cpu cpu cpu exit ---------------------------------- Your task is to read in the events, and simulate the creation and execution of processes in the system as they move through the various three-states of their process life cycle. You need to: 2 � De�ne a simple process control block (PCB) to hold information about all processes currently running in your system. The PCB can be a simple C struct or a C++ class. At a minimum you need to have a �eld for the process identi�er and the process state (Ready, Running or Blocked). You need to also keep track of the time step that the process entered the system, and the number of steps the process has been
  • 29. running. Minimal credit will be given to programs that at least handle new events and create a process in a simulated PCB. You probably need a list or an array to hold the current processes that have been created and are being managed by your simulated system. � You will need a ready queue of some kind. You should use a C++ Standard Template Library (STL) container to manage your ready queue. � You will need to implement a simple dispatcher function. Whenever a cpu event occurs, and no process is currently running, you should select the next Ready process from the head of your ready queue and start it running on the processor. � You need to also implement a simple time slicing mechanism. The time slice value to use will be passed into your program when it is started. At the end of a cpu cycle, you should check if the currently running process has executed for its full time quantum. In that case, the currently running process should timeout, and be returned to the end of the Ready queue. � new events should cause a new process to be created (including creating
  • 30. its PCB and �lling it in). New processes should be placed on the tail of the ready queue after being created. You should assign each new process a process identi�er. The process identi�er should be a simple integer value, and you should start numbering processes from 1. � For a done event, if a process is currently running it should then be released. It should be removed from the CPU, and not placed back on the ready or blocked queue. If a done occurs when the CPU is idle, then nothing will happen as a result of this event. � A wait event simulates the currently running process performing some I/O operation. If a wait occurs, the currently running process should become blocked and put on the blocked queue. You also need an entry in the PCB so you know what event the process is waiting for. The 3 wait event is followed by an integer number, which is an indication of the type of event the process has requested. � Likewise the event directive simulates the �nishing of some I/O oper- ation. When an event occurs, you should scan your blocked
  • 31. processes and make any process ready that was waiting on that event. The in- teger value following an event indicates the type of event that just occurred. You have been given some example event sequences (simulation-01.sim, simulation-02.sim, etc.) along with the expected output for those sequence of events (simulation-01.res, simulation-02.res, etc.). The output of your program should be sent to standard output. The correct output for the simulation-01.sim simulation is: Time: 1 CPU (currently running): pid=1, state=RUNNING, start=1, slice=1, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 2 CPU (currently running): pid=1, state=RUNNING, start=1, slice=2,
  • 32. Ready Queue: EMPTY Blocked Queue: EMPTY Time: 3 CPU (currently running): pid=1, state=RUNNING, start=1, slice=3, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 4 CPU (currently running): 4 pid=1, state=RUNNING, start=1, slice=4, Ready Queue: pid=2, state=READY, start=4, slice=0,
  • 33. Blocked Queue: EMPTY Time: 5 CPU (currently running): pid=1, state=RUNNING, start=1, slice=5, Ready Queue: pid=2, state=READY, start=4, slice=0, Blocked Queue: EMPTY Time: 6 CPU (currently running): pid=2, state=RUNNING, start=4, slice=1, Ready Queue: pid=1, state=READY, start=1, slice=5, Blocked Queue: EMPTY Time: 7 CPU (currently running):
  • 34. pid=2, state=RUNNING, start=4, slice=2, Ready Queue: pid=1, state=READY, start=1, slice=5, Blocked Queue: EMPTY Time: 8 CPU (currently running): pid=1, state=RUNNING, start=1, slice=1, Ready Queue: EMPTY Blocked Queue: pid=2, state=BLOCKED, start=4, slice=2, event=1 Time: 9 CPU (currently running): 5 pid=1, state=RUNNING, start=1, slice=2, Ready Queue:
  • 35. EMPTY Blocked Queue: pid=2, state=BLOCKED, start=4, slice=2, event=1 Time: 10 CPU (currently running): pid=1, state=RUNNING, start=1, slice=3, Ready Queue: pid=2, state=READY, start=4, slice=2, Blocked Queue: EMPTY Time: 11 CPU (currently running): pid=1, state=RUNNING, start=1, slice=4, Ready Queue: pid=2, state=READY, start=4, slice=2, Blocked Queue: EMPTY Time: 12
  • 36. CPU (currently running): pid=2, state=RUNNING, start=4, slice=1, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 13 CPU (currently running): pid=2, state=RUNNING, start=4, slice=2, Ready Queue: EMPTY Blocked Queue: EMPTY Time: 14 CPU (currently running): 6 pid=2, state=RUNNING, start=4, slice=3,
  • 37. Ready Queue: EMPTY Blocked Queue: EMPTY Time: 15 CPU (currently running): pid=2, state=RUNNING, start=4, slice=4, Ready Queue: EMPTY Blocked Queue: EMPTY Your output to standard out should look exactly the same as this output (i.e. if I do a di� and your program is generating the correct output, then there will be no di�erence between the output your program generates and the above output format). The output is generated by displaying the system state after each cpu cycle executes. Basically we print out the system time. Then we show which process (if any) is currently running on the CPU (or say it is IDLE if no process is running). Then we display the
  • 38. queue of processes currently on the Ready and Blocked queues. Note that the queues are displayed in order. The top of the output corresponds to the head of the queue. Thus when a new process is dispatched, the next one selected should be the �rst process listed from the ready queue in the previous system cycle. I have given you some template code (p2-start.cpp) to get you started The code is meant to be run from the command line, thus from a shell or dos prompt you would do something like: $ p2-start simulation-01.sim 5 i.e. the program expects two parameters on the command line, which should be the name of a �le that holds the events to be simulated, and the value to be used for the time slice quantum. If you need to test your program and can't �gure out how to invoke running it from the command line, you can change the line in 'p2-start.cpp' to explicitly run a particular simulation �le, like this: runSimulation("simulation-01.sim", time_slice_quantum) 7
  • 39. However, you need to make sure that your program correctly works using the command line invocation, as shown in `p2-start.cpp`. I have given some template code to get you started in the �le called p2-start.cpp. I have already provided you with the code needed in order to correctly parse the command line parameters for the program, and to open and read in the simulation �le events. Your job is to implement the necessary actions and data structures to handle the simulated events described. The runSimulation() in 'p2-start.cpp holds example code and indicates locations where you need to write your own functions to implement the simulation. You can use this as a starting point to implement your solution. Assignment Submission and Requirements All source �les you create for you solution (.c or .cpp/.c++ and .h header �les) should be uploaded to the MyLeo Online submission folder created for this assignment by the deadline. You should not attach any �les besides the source �les containing your C/C++ code. But you should make sure you attach all needed �les you create to your submission, so that I can compile and run your solution. You are required to write the program in standard C/C++ programming
  • 40. language. You should use a relatively recent version of the C/C++ compiler (C90 C++98 is �ne, or the more recent C99 C++11 will also be acceptable), and/or recent IDE that has an up to date compiler. You should only use standard C/C++ libraries, do not use Microsoft speci�c or other third-party developed external libraries. This page http://en.cppreference.com/w/ provides a good up to date reference of the libraries in the standard C++ and C languages. You may use the C++ standard template library containers (like the list and queue items) to implement the ready queue you need. We will go over a simple implementation of a queue using pointers and/or arrays in class, if you would like an example implementation in plain C that might be simpler to use than learning the STL. 8 http://en.cppreference.com/w/ simulation-01.sim new cpu cpu cpu new cpu cpu cpu cpu
  • 44. event 2 cpu cpu cpu cpu wait 2 cpu cpu cpu event 1 cpu cpu event 3 cpu cpu cpu cpu cpu done cpu cpu cpu cpu done event 2 cpu cpu cpu wait 1 cpu cpu cpu cpu cpu done cpu
  • 48. cpu cpu cpu cpu cpu cpu cpu cpu cpu wait 1 cpu wait 1 cpu wait 1 cpu wait 1 cpu wait 1 cpu wait 1 cpu wait 1 cpu event 1 cpu cpu cpu cpu cpu cpu cpu cpu cpu cpu cpu cpu