Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please provide the right / perfect code. Do mention all the information required Task In this project you will be writing a makefile to compile

Please provide the right/perfect code. Do mention all the information required
Task
In this project you will be writing a makefile to compile two source files into two separate executables. One of the executables will be called oss, generated at least partially from the source file oss.c. The other executable will be called user, generated at least partially from the source file called user.c.
The user executable is never executed directly. Instead, oss will be launching that executable at various times.
Note you MUST have a makefile that compiles and creates these executables at the same time. This will require the use of the
all command in your makefile to compile multiple executables from the same makefile.
keep in mind that executables will never be called by itself directly (though you
can do so to test).
User process (the children) The user takes in one command line argument. For example, if you were running it directly you would call it like:
./user 5
As it is being called with the number 5, it would do 5 iterations over a loop.
So what does it do in that loop? Each iteration it will output its PID, its parents PID, and what iteration of the loop it is in. For example, suppose its PID is 6577, its parents PID is 6576 and it is the 3rd iteration of the loop, it would output:
USER PID:6577 PPID:6576 Iteration:3 before sleeping
After doing this output, it should do sleep(1), to sleep for one second, and then output:
USER PID:6577 PPID:6576 Iteration:3 after sleeping
You should test this by itself, but it will not be called by itself normally.
Linux System Calls 2 oss (the parent)
The task of oss is to launch a certain number of user 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 iter]
The proc parameter stands for number of total children to launch, iter is the number to pass to the user process and the simul
parameter indicates how many children to allow to run simultaneously.
For example, if I wanted to launch oss such that it would launch 5 user processes, never allow more than 3 to be running at the
same time, and then have each of the users do 7 iterations, it would be called with:
oss -n 5-s 3-t 7
If called with the -h parameter, it should simply output a help message (indicating how it is supposed to be run) and then
terminating.
So now that I know what parameters it should run with, what should it do? oss when launched should go into a loop and start
doing a fork() and then an exec() call to launch user processes. However, it should only do this up to simul number of times. In
our above example, we would launch no more than 3 initially. The oss would then wait() until one of the children had finished
before launching another.
Implementation details
It is required for this project that you use version control (git), a Makefile, and a README. Your README file should consist,
at a minimum, of a description of how to compile and run your project, any outstanding problems that it still has, and any
problems you encountered.
Your makefile should also compile BOTH executables every time. This requires the use of the all prefix.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions