TWiki> CS385 Web>Homework7 (revision 2)EditAttach

Implementing signals

In this homework, we add support for standard Unix signals to xv6. As in past homeworks, start with the hw8 template from the class repository. Refer to lectures, the text book and Linux man pages, including: man sigreturn, as well as this linuxjournal article to learn more about signals.

alarm() - send SIGALRM to a process after a set interval

The template contains a default handler for all signals: kill the process. In this part, we implement a new system call (alarm(seconds)), which sends SIGALRM to the calling process after the specified time interval.

The program alarmtest.c calls alarm(), then enters an infinite loop. A correct implementation of alarm() kills the process after the specified number of seconds.

signal() step 1 - change the disposition of a signal

The signal() system call can be used to change the "disposition" of a signal, i.e. how the signal is handled when received. In this step, you need to support only SIG_DFL (default), and SIG_IGN (ignore). The template already has built-in handling for SIG_DFL (kill the process), so you need only support the configuration, and "handle" signals with a SIG_IGN disposition.

Test your implementation using alarmtest2.c.

signal() step 2 - user space signal handling functions

If the second argument is a function (i.e. a value that is not SIG_DFL or SIG_IGN), then the function passed in should be called when the signal is received. We will follow the Linux design for implementing this, which is described in the linuxjournal article above, and discussed in lecture.

VERY IMPORTANT: the signal handler must run in user mode only

Test your implementation using alarmtest3.c.

kill() - sending signals from other processes

Implement the kill() system call to send a signal to a different process. The binary kill uses this system call, and takes a pid and signal number= as arguments.

Test your program by running helloloop, then using the program kill to send SIGINT and SIGKILL to the helloloop process.

Ctrl-C sends SIGINT to the foreground program

Implement a system call setforeground() to set a given pid as the foreground process.

(to be continued)

Edit | Attach | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2015-04-02 - 20:22:06 - Main.jakob
 
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
WISEST
Helping Women Faculty Advance
Funded by NSF