Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: To increase your understanding of system calls; especially those involved with signal processing. Please write the program in C or C++ You will write

Purpose: To increase your understanding of system calls; especially those involved with signal processing.

Please write the program in C or C++

You will write a program that will maintain multiple alarms. Initially the program is to randomly generate n time values: t1 t2 t3 tn where each time value is the value of the current time (time((time_t *)NULL)) plus a randomly generated integer, m, such that 1 m

2. header file: Write and use a header (.h) file. Include in this header file your #define statements (for MAX_TIME, etc.) and other appropriate items. The program should be tested with MAX_TIME set to 60.

3. Makefile: Write a makefile to control the compilation of your program.

4. Number of alarms (n): The value of n must be specified via a command line parameter that is processed at run-time.

5. Processing of SIGUSR1 Signal: When a SIGUSR1 signal is received by the program, it is to generate a new alarm that is to go off at the current time plus a randomly generated integer similar to those generated during initialization. Notes:

The current time is the time when the signal is received. The resulting alarm time must cause an alarm at the correct time.

It is possible to generate a SIGUSR1 signal by issuing the kill command from an alternate window.

It must be possible for the program to handle multiple (sequential) SIGUSR1 signals.

7. Messages: Output messages must clearly show the following items:

The times at which the initial set of alarms are to occur.

The occurrence of each SIGALRM.

The occurrence of each SIGUSR1, the time at which it occurred, and the time of the resulting new alarm that was scheduled.

Messages that indicate when an alarm is being waited for.

Sample output appears below:

image text in transcribed

time = 1029067014: initial list = (1, 1029067048) (2, 1029067053) (3, 1029067073) time = 1029067014: Waiting for alarm 1, alarm time = 1029067048 time = 1029067024: SIGUSR1 caught time = 1029067024: alarm 4 added, alarm time = 1029067080 time = 1029067028: SIGUSR1 caught time = 1029067028: alarm 5 added, alarm time = 1029067060 time = 1029067048: Alarm occurred time = 1029067048: Waiting for alarm 2, alarm time = 1029067053 time = 1029067053: Alarm occurred time = 1029067053: Waiting for alarm 5, alarm time = 1029067060 time = 1029067060: Alarm occurred time = 1029067060: Waiting for alarm 3, alarm time = 1029067073 time = 1029067073: Alarm occurred time = 1029067073: Waiting for alarm 4, alarm time = 1029067080 time = 1029067080: Alarm occurred

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago