Description
On this date in 1818, two English boxers were the first to use
padded gloves. Nowadays, we use semaphores to settle such critical
section issues…
PART 1:
——-
Create a set of 4 stand-alone programs, as follows:
Program #0 – Will always be called first and must create a set of
semaphores. Program #0 must print the exact text “Executing process
#0.” when it runs. It must then terminate.
Program #1 – Will be started sometime after program #0 and must
adjust the semaphore(s) such that program #2 can run. Program #1
must print the exact text “Executing process #1.” when it runs. It
must then terminate. Program #1 doesn’t do anything else.
Program #2 – Will be started sometime after program #0 and must
adjust the semaphore(s) such that program #3 can run. Program #2
must print the exact text “Executing process #2.” when it runs.
It must then terminate. Program #2 doesn’t do anything else. However,
program #2 can only run AFTER program #1 runs! If program #2 runs
before program #1 it must simply terminate itself.
Program #3 – Will be started sometime after program #0 and should
remove the semaphores from the system. Program #3 must print the
exact text “Executing process #3.” when it runs. It must then
terminate. Program #3 doesn’t do anything else. However, program #3
can only run AFTER program #2 runs! If program #3 runs before program
#2 it must simply terminate itself.
PART 2:
——-
We will test your code using my program (a script) that will always
call program #0 first, but will call the remaining programs in all
possible permutations. Obviously, to get full credit only the correct
permutation should result in the following output:
Executing process #0.
Executing process #1.
Executing process #2.
Executing process #3.
SUGGESTIONS:
————
See man pages for semget, semop, and semctl.
See man pages for errno and include errno.h – this will make things
much easier! You can use errno to troubleshoot your code and to help
determine how to tell when a process is attempted out-of-turn.
REQUIREMENTS:
————
1. Your program must run on Mint.
2. Your full name must appear as a comment at the beginning of your
program.
3. Your source code must be named hw6-yourname.c or hw6-yourname.cpp
(AFTER CLASS ON WED, OCT 3, THE REQUIREMENTS CHANGED TO WHAT IS BELOW)
1. Your program must run on Mint.
2. Your full name must appear as a comment at the beginning of your
program.
3. Make a tarball of the 4 programs and name them program0, program1,
program2, and program3
4. Your tarball must be named hw6-yourname.tar