| CS 321 Spring 2012 > Lecture Notes for Friday, February 17, 2012 |
Recall synchronous, or blocking, operations vs. asynchronous, or non-blocking.
Simple message-passing mechanism. A traditional part of C library under *ix OSs. Very little information is sent—only the signal itself. By default, asynchronous, handler function executed using standard process stack.
Must include <signal.h>.
A handler function takes an int (the signal)
and returns void.
Set up a handler by calling system call signal,
passing the signal name and a pointer to the handler function.
Signals are sent by kill system call.
Also a program named kill can be used on the command line.
Here are some of the more common signals. There are many others, most of which are rarely used. The default response is what happens to the process receiving the signal if it has not set up a handler function.
| Signal | Sent By | Can Be Handled | Default Response |
|---|---|---|---|
SIGINT |
Ctrl-C | Yes | Exit |
SIGKILL |
No | Exit | |
SIGSTOP |
Ctrl-Z | No | Suspend |
SIGALRM |
System call alarm(time_in_secs) |
Yes | Exit |
The alarm signal (SIGALRM) is particularly interesting,
since it is most often used by a process to signal itself.
The signal is sent after some fixed amount of time has elapsed.
Message-Passing IPC will be continued next time.
ggchappell@alaska.edu