Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please provide all the code and files which this assignment requires Task In this project you will be writing a makefile to compile two source
please provide all the code and files which this assignment requires
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 makefile to compile multiple executables from the same makefile.
We will first discuss what the user executable does, but keep in mind that it 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
As it is being called with the number it would do 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 its parents PID is and it is the rd iteration of the loop, it would output:
USER PID: PPID: Iteration: before sleeping
After doing this output, it should do sleep to sleep for one second, and then output:
USER PID: PPID: Iteration: after sleeping
You should test this by itself, but it will not be called by itself normally.
Linux System Calls
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 hn procs simult 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 user processes, never allow more than to be running at the
same time, and then have each of the users do iterations, it would be called with:
oss n s t
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 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.
Suggested implementation steps
Set up your git repository, if you have not already done so You should periodically check your code into the git repository
once a day, or whenever you make and test substantial changesDay
Create your Makefile and barebones skeleton of oss and user. Make sure that if you change either one, the makefile will
compile both. Day
Write code to parse options and receive the command parameters. Study getopt if you do not know how to do it
The man page also has an example to guide you. Day
Implement the user taking in an option and doing its loop and output. Day
Implement oss to fork and then exec off one user to do its task and wait until it is done. Day
Get oss to fork off users up until the n parameter Day
Implement the simultaneous restriction Day
Testing and make sure your README file indicates how to run your project. Give a oneline example that would let me
know how to run it DO NOT SIMPLY COPYPASTE THIS DOCUMENT INTO THE README
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started