Question: Please provide all the code. provide all the files that's require. make sure to provide Makefile as well. As in the previous project, you will
Please provide all the code. provide all the files that's require. make sure to provide Makefile as well.
As in the previous project, you will have two executables, oss and worker. The oss executable will be launching workers and
oss will be maintaining a system clock. However, we have a few more details.
In particular, oss will now alternate sending messages to the users that it launches. That is suppose we had three user processes
running. oss would first second a message to p then after receiving a message back, would send a message to p then after
getting a message back, send a message to p and so on repeating the sequence as needed.
To keep track of necessary information, oss will maintain a process table consisting of Process Control Blocks, one for each
process This process table does not need to be in shared memory. The first thing it should keep track of is the PID of the
child process, as well as the time right before oss does a fork to launch that child process based on our own simulated clock
It should also contain an entry for if this entry in the process table is empty ie: not being used I suggest making your process
table an array of structs of PCBs for example:
struct PCB
int occupied;
pidt pid;
int startSeconds;
int startNano;
;
struct PCB processTable;
Note that your process table is limited in size and so should reuse old entries. That is if the process occupying entry finishes,
then the next time you go to launch a process, it should go in that spot. When oss detects that a process has terminated, it can
clear out that entry and set its occupied to indicating that it is now a free slot.
worker, the children
The worker takes in two command line arguments, this time corresponding to how many seconds and nanoseconds it should
decide to stay around in the system. For example, if you were running it directly you might call it like note that oss launches
this when you are actually running the project:
worker
The worker will start by attaching to shared memory. However, it will not examine it It will then go into a loop.
do
msgrcvfrom oss;
check the clock
determine if it is time to terminate
msgsndto oss, saying if we are done or not
while not done;
It determines the termination time by adding up the system clock time and the time passed to it in the initial call through
command line arguments in our simulated system clock, not actual time This is when the process should decide to leave the
system and terminate.
For example, if the system clock was showing seconds and nanoseconds and the worker was passed and as
above, the target time to terminate in the system would be seconds and nanoseconds. The worker would check this
termination time to see if it has passed each iteration of the loop. If it ever looks at the system clock and sees values over the
ones when it should terminate, it should output some information, send a message to oss and then terminate.
So what output should the worker send? Upon starting up it should output the following information:
WORKER PID: PPID: SysClockS: SysclockNano: TermTimeS: TermTimeNano:
Just Starting
The worker should then go into a loop, waiting for a message from oss, checking the clcok and then sending a message back. It
should also do some periodic output.
In this project, unlike previous projects, you should output a message every iteration of the loop. Something like the following:
WORKER PID: PPID: SysClockS: SysclockNano: TermTimeS: TermTimeNano:
iteration has passed since it started
and then the next iteration it would output:
WORKER PID: PPID: SysClockS: SysclockNano: TermTimeS: TermTimeNano:
iterations have passed since starting
Once its time has elapsed, supposing it ran for iterations, it would send out one final message:
WORKER PID: PPID: SysClockS: SysclockNano: TermTimeS: TermTimeNano:
Terminating after sending message back to oss after iterations.
oss, the parent
The task of oss is to launch a certain number of worker processes with particular parameters. These numbers are determined
by its own command line arguments.
Your solution will be invoked using the following command:
oss hn procs simult timelimitForChildren
i intervalInMsToLaunchChildrenf logfile
Linux System Calls
While the first two parameters are similar to the previous project, the t parameter is different. It now stands for the bound of
time that a child process will be launched for. So for example, if it is called with t then when calling worker processes, it
should call them with a time interval randomly between second and seconds.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
