Unit 2 Lecture 37 - Signals
Unit 2 Lecture 37 - Signals
Signals
Suresh Jamadagni
Department of Computer Science
OPERATING SYSTEMS
Slides Credits for all the PPTs of this course
Signals
Suresh Jamadagni
Department of Computer Science
OPERATING SYSTEMS
Signals
• A signal is used in UNIX systems to notify a process that a particular event has occurred.
• A signal may be received either synchronously or asynchronously depending on the source of
and the reason for the event being signaled
• All signals, whether synchronous or asynchronous, follow the same pattern:
1. A signal is generated by the occurrence of a particular event.
2. The signal is delivered to a process.
3. Once delivered, the signal must be handled.
OPERATING SYSTEMS
Signals – synchronous and asynchronous
• The method for delivering a signal depends on the type of signal generated.
• For example, synchronous signals need to be delivered to the thread causing the signal and not
to other threads in the process.
• However, the situation with asynchronous signals is not as clear. Some asynchronous signals—
such as a signal that terminates a process (<control><C>) should be sent to all threads.
• The standard UNIX function for delivering a signal is
kill(pid t pid, int signal)
• This function specifies the process (pid) to which a particular signal (signal) is to be delivered
OPERATING SYSTEMS
Signal handling
• Most multithreaded versions of UNIX allow a thread to specify which signals it will accept and
which it will block.
• An asynchronous signal may be delivered only to those threads that are not blocking it.
• Because signals need to be handled only once, a signal is typically delivered only to the first
thread found that is not blocking it.
• POSIX Pthreads provides the following function, which allows a signal to be delivered to a
specified thread (tid):
pthread kill(pthread t tid, int signal)
OPERATING SYSTEMS
Signals in windows
• Windows does not explicitly provide support for signals, it allows to emulate them using
asynchronous procedure calls (APCs).
• The APC facility enables a user thread to specify a function that is to be called when the user
thread receives notification of a particular event.
• An APC is roughly equivalent to an asynchronous signal in UNIX
• The APC facility is more straightforward, since an APC is delivered to a particular thread rather
than a process
OPERATING SYSTEMS
Signals in Linux
Suresh Jamadagni
Department of Computer Science and Engineering
[email protected]