Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CIS 390 Program Set 3: Kernel Timers and Signals, Assignments of Operating Systems

Information about program set 3 for cis 390, which focuses on kernel timers and signals. Students are required to complete two tasks: running a signal handling program and completing the kernel timer program. The tasks involve creating, compiling, and running programs, as well as setting up timers using setittimer instruction. Sample outputs for different input values.

Typology: Assignments

Pre 2010

Uploaded on 08/19/2009

koofers-user-mi3-1
koofers-user-mi3-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CIS 390 Program Set 3
Spring 2007
5 April 2007
Kernel Timers and Signals
ASSIGNED: 5 April 2007
DUE: 17 April 2007 (by the end of class - 15:20)
VALUE: 15 points
Overview: In this program set you will run an example program from the textbook and
then complete the program outline for the textbook’s Lab 6.1 Kernel Timers.
Tasks:
1. (5 points) Create, compile and run the signal handling program listed on page 236
of the class text. (Note that a complete copy of a modified version of this program is
also contained on page 2 of this assignment, so you only need to type it in, compile
and run.)
2. (10 points) Complete the kernel timer program (which uses the Fibonacci number
calculation) outlined on pages 237 - 239 of the textbook. (A sample run for three
different input values is shown on the third page of this assignment.)
Here, in this program, the signals are not raised by sending a kill instruction as it is
done in the example program of Task 1, but rather the signals are raised by various
countdown timers (that are set using a setittimer instruction).
NOTE: the SIGALRM is used in conjunction with ITIMER REAL; SIGVTALRM in
conjunction with ITIMER VIRTUAL; and SIGPROF with ITIMER PROF.
Submit the following:
1. A printout of each of your programs for Task 1 and Task 2. You should also send me
an email copy of each program with the Subject Line: CIS390 Program Set 3.
1
pf3

Partial preview of the text

Download CIS 390 Program Set 3: Kernel Timers and Signals and more Assignments Operating Systems in PDF only on Docsity!

CIS 390 Program Set 3

Spring 2007

5 April 2007

Kernel Timers and Signals

ASSIGNED: 5 April 2007

DUE: 17 April 2007 (by the end of class - 15:20)

VALUE: 15 points

Overview: In this program set you will run an example program from the textbook and

then complete the program outline for the textbook’s Lab 6.1 Kernel Timers.

Tasks:

1. (5 points) Create, compile and run the signal handling program listed on page 236

of the class text. (Note that a complete copy of a modified version of this program is

also contained on page 2 of this assignment, so you only need to type it in, compile

and run.)

2. (10 points) Complete the kernel timer program (which uses the Fibonacci number

calculation) outlined on pages 237 - 239 of the textbook. (A sample run for three

different input values is shown on the third page of this assignment.)

Here, in this program, the signals are not raised by sending a kill instruction as it is

done in the example program of Task 1, but rather the signals are raised by various

countdown timers (that are set using a setittimer instruction).

NOTE: the SIGALRM is used in conjunction with ITIMER REAL; SIGVTALRM in

conjunction with ITIMER VIRTUAL; and SIGPROF with ITIMER PROF.

Submit the following:

1. A printout of each of your programs for Task 1 and Task 2. You should also send me

an email copy of each program with the Subject Line: CIS390 Program Set 3.

#include <signal.h>

void sig_handler(int);

int main(void) { int i, parent_pid, child_pid, status;

signal(SIGUSR1, sig_handler); signal(SIGUSR2, sig_handler);

parent_pid = getpid();

if ((child_pid = fork()) == 0) { printf("Child signaling parent\n"); kill(parent_pid, SIGUSR1); for(;;) pause(); } else { printf("Parent signaling child\n"); kill(child_pid, SIGUSR2); sleep(4); printf("Parent terminating child\n"); kill(child_pid, SIGTERM); wait(&status); printf("Done\n"); } }

void sig_handler(int signo) { switch(signo) { case SIGUSR1: printf("Parent recieved SIGUSR1\n"); break; case SIGUSR2: printf("Child recieved SIGUSR2\n"); break; } return; }

/*

Child signaling parent Parent recieved SIGUSR Parent signaling child Child recieved SIGUSR Parent terminating child Done

*/