Answered step by step
Verified Expert Solution
Link Copied!

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 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.
Suggested implementation steps
1. 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 changes).[Day 1]
2. Create your Makefile and barebones skeleton of oss and user. Make sure that if you change either one, the makefile will
compile both. [Day 2]
3. Write code to parse options and receive the command parameters. Study getopt(3), if you do not know how to do it.
The man page also has an example to guide you. [Day 3]
4. Implement the user taking in an option and doing its loop and output. [Day 4]
5. Implement oss to fork() and then exec() off one user to do its task and wait() until it is done. [Day 5]
6. Get oss to fork off users up until the -n parameter [Day 6-7]
7. Implement the simultaneous restriction [Day 8-9]
8. Testing and make sure your README file indicates how to run your project. Give a one-line example that would let me
know how to run it. DO NOT SIMPLY COPY/PASTE THIS DOCUMENT INTO THE README

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions