Starting from:

$30

Operating Systems-Assignment 2 Solved

1 Exec family system call and basic IPC using signals AP

 

The first exercise tries to familiarize you with exec family system calls and signals API. In this program you are required to create a child process, lets call it S1. You need to save the PID of the process just created using a local variable. The body of process S1, should register a signal handler for SIGTERM which could be raised by any other process, using the kill() system call.

Thereafter, following the creation of process S1 the main (parent) program should fork two more child processes, ST and SR. Both ST and SR should register signal handler for the signal SIGALRM. Both should setup appropriate timers using the setitmerval() system call (that should invoke a timer for both the processes, individually) at every predecided interval (e.g. 1s, 2s, etc.).

Note 1: Functionality of SR: Corresponding to SR, the SIGLARM handler should read a random number from the CPU using the the RDRAND instruction (using inline assembly). Then, SR needs to enqueue the random number and the SIGTERM and deliver it to S1’s SIGTERM handler (using kill() system call). S1’s SIGTERM handler should print the said random number.

Note 2: Functionality of ST: We require a similar SIGALRM handler for ST. The ST process should read the CPU timestamp counter (using inline assembly to run RDTSC instruction), and coverts into a human readable string (i.e. representing the current date and time), at every interval. The interval can be set using the setitimer() system call, that raises then SIGALRM signal everytime the timeout elapses, that is trapped by an appropriate signal handler. The random number should be obtained (using the inline RDTSC instruction), in the SIGALRM handler function. Much like SR, the ST’s SIGALRM handler should enqueue the string along with the SIGTERM signal and deliver it to S1’s SIGTERM handler (using kill()), that should print it.

Note 3: Using exec family system calls to launch the two programs

SR and ST: Also, it must be noted that the entire functionality of ST and SR

1should be embodied in two individual programs. In other words, there should be two executable programs E1 and E2 corresponding to SR and ST respectively, that should accept the PID of S1 as an argument. These programs, i.e. E1 and E2, must be launched from SR and ST respectively using the exec family of system calls, especially those that allow launching programs with arguments.

More products