Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C for Linux that will maintain multiple alarms. Initially the program is to randomly generate n time values: t 1 t

Write a program in C for Linux that will maintain multiple alarms. Initially the program is to randomly generate n time values: t 1 t 2 t 3 ... t n 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 k for all k).

- The program also needs to intake the number of alarms specified via command line parameter,

- 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.

- The required behavior must be maintained through the use of signals under the Virtual Machine

Example output:

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 = 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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions