$29
Design and implement an event management program (emp).
You shall create a program that uses signals to coordinate work among sibling threads. You will
build one thread to be the signal handle and worker threads to perform the following (note, you will
alsoouse semaphores as needed):
o
Your program shall read the arguments provided by the user. If arguments are not provided
use default values as stated below.
o
Your program shall create worker threads from the main, initial thread which busy-waits
until all worker threads have completed, then, perform a clean exit.
One of the worker threads shall manage/monitor the countdown timer, upon reaching the
o
specified number of seconds it shall signal all threads to terminate and then terminate itself.
Note, the thread shall use signal() to do this.
o
Another worker thread shall manage/monitor the “countdown timer” and generates/signals
that this time has elapsed.
Another process shall implement a “wall clock” which prints the hour, minute, and second of
the time of day to the user terminal once every second (in human readable form, hint, use
localtime). When the hour, minute, and second matches the user-provided countdown time,
o
an Alarm would be printed in addition to the time let the user know the program is
terminating.
Once all child threads have terminated, the parent thread (and the process) shall print a
friendly message to the user (using stdout), then perform a clean exit.
User provided inputs/defaults (e.g. % emp: 45 1 15) – note, 45 is 1
parameter, 1 is 2
parameter, and 15 is 3
d
parameter
st
nd
o
The first parameter will be time (in seconds) the program will run before it exits. If no value
is provided, the default value of 25 seconds shall be used for this countdown timer.
o
The second parameter will be 1 or 60, it it’s 1 then print out time every second, if 60 then
o
print out time every minute, all other values will be an error and your program shall
gracefully exit
The third parameter will be used as a countdown timer, the value is the time (in seconds)
o
when one of the worker threads shall schedule a signal to occur (in seconds) that the
countdown “reached zero” (i.e., that many seconds have just elapsed).
If just emp is entered, use the following default values: 32, 1, 17
Your project shall include a README file using the same conventions/requirements specified in the course README instructions file.
Your program will be tested by compiling and executing on edoras. Your program shall be written such that it compiles and executes cleanly when using gcc/g++. Note - you must use a Makefile. You shall create a sub-directory named "a3" in your home directory. In it, you shall place all of your project files, including your Makefile. Your source files shall contain sufficient comments for making the source easy to read. Points will be taken off for poorly (or non) commented source. Name the executable "emp". Also, create an archive file (tarball, zip) and upload to Blackboard (one student per project).
o Create ~/a3 by hand.
o
Create all necessary project files. Put them into ~/a3.
o
The Makefile shall create an executable named "emp" in this same directory (~/a3).
o
The system call "system()" will NOT be allowed
o
o
You may use gcc, or g++ compiler on this assignment
ust work individually or in pairs (individually or a team of 2 students)
TURNING
IN YOUR WORK:
Follow the turn-in procedures on class Blackboard.