Question: Please provide all the code. Donot miss anything Purpose In the previous project we created a utility that just launched user processes with various limits

Please provide all the code. Donot miss anything
Purpose
In the previous project we created a utility that just launched user processes with various limits. In this project we will be adding functionality that we will use in later on projects.
Task
As in the previous project, you will have two executables, oss and worker. The oss executable will be launching workers. However, we have a few more details.
Our main executable (oss) will now be maintaining a "simulated system clock" in shared memory. This system clock is not tied to the main clock of the system, but instead done separately. The clock consists of two separate integers (one storing seconds, the other nanoseconds) in shared memory, both of which are initialized to zero. This system clock must be accessible by the children, so it is required to be in shared memory. The children will not be modifying this clock for this assignment, but they will need to look at it.
In addition to this, oss will also 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; // either true or false
pid_t pid; // process id of this child
int startSeconds; // time when it was forked
int startNano; // time when it was forked
};
struct PCB processtable[20];
Note that your process table is limited in size and so should reuse old entries. That is, if the process occupying entry 0 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 0, 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:
./worker 5500000
The worker will then attach to shared memory and examine our simulated system clock. It will then figure out what time it should terminate by adding up the system clock time and the time passed to it (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 6 seconds and 100 nanoseconds and the worker was passed 5 and 500000 as above, the target time to terminate in the system would be 11 seconds and 500100 nanoseconds. The worker will then go into a loop, constantly checking the system clock to see if this time has passed. If it ever looks at the system clock and sees values over the ones when it should terminate, it should output some information and then terminate.
So what output should the worker send? Upon starting up, it should output the following information:
WORKER PID:6577 PPID:6576 SysClockS: 5 SysclockNano: 1000 TermTimeS: 11 TermTimeNano: 500100--Just Starting
The worker should then go into a loop, checking for its time to expire (IT SHOULD NOT DO A SLEEP). It should also do some periodic output. Everytime it notices that the seconds have changed, it should output a message like:
WORKER PID:6577 PPID:6576 SysclockS: 6 SysclockNano: 45000000 TermTimeS: 11 TermTimeNano: --1 seconds have passed since starting
and then one second later it would output:
WORKER PID:6577 PPID: 6576 SysClockS: 7 SysclockNano: 500000 TermTimes: 11 TermTimeNano: 5001--2 seconds have passed since starting
Once its time has elapsed, it would send out one final message:
WORKER PID:6577 PPID:6576 SysClockS: 11 SysclockNano: 700000 TermTimeS: 11 TermTimeNano: --Terminating
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 [-h][-n proc][-s simul][-t timelimitForChildren][-i intervalInMsToLaunchChildren]
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 7, then when calling worker processes, it should call them with a time interval randomly between 1 second and 7 seconds (with nanoseconds also random).
The -i parameter is new. This specifies how often you should launch a child (based on the system clock). For example, if -i 100 is passed, then your system would launch a child no more than once every 100 milliseconds. This is set to allow user processes to slowly go into the system, rather than flood
 Please provide all the code. Donot miss anything Purpose In the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!