EmbLogic's Blog

Article on Signals:

SIGNALS:
Signals were introduced by the first Unix systems to simplify interprocess communication.The kernel also uses them to notify processes of system events. In contrast to interrupts and exceptions, most signals are visible to User Mode processes. Also signals can be used as a mean of communication between two processes while interrupts can be used as a mean of communication between hardware and kernel(process). Signals serve two main purposes:

  1. To make a process aware that a specific event has occurred.
  2. To force a process to execute a signal handler function included in its code.

A number of system calls allow programmers to send signals and determine how their processes exploit the signals they receive.An important characteristic of signals is that they may be sent at any time to processes whose state is usually unpredictable. Signals sent to a non-running process must be saved by the kernel until that process resumes execution. Blocking signals (described later) require signals to be queued, which exacerbates the problem of signals being raised before they can be delivered.Therefore, the kernel distinguishes two different phases related to signal transmission:

  1. Signal sending:The kernel updates the descriptor of the destination process to represent that a new signal has been sent.
  2. Signal receiving: The kernel forces the destination process to react to the signal by changing its execution state or by starting the execution of a specified signal handler or both.

Each signal sent can be received no more than once. Signals are consumable resources: once they have been received, all process descriptor information that refers to their previous existence is cancelled.Signals that have been sent but not yet received are called pending signals . At any time, only one pending signal of a given type may exist for a process; additional pending signals of the same type to the same process are not queued but simply discarded. In general, a signal may remain pending for an unpredictable amount of time. Some important points about the signals are :

  • When a process executes a signal-handler function, it usually “masks” the corresponding signal, that is, it automatically blocks the signal until the handler terminates.
  • A signal handler therefore cannot be interrupted by another occurrence of the handled signal, and therefore the function doesn’t need to be re-entrant.
  • A masked signal is always blocked, but the converse does not hold.
  • The kernel must remember which signals are blocked by each process. When switching from Kernel Mode to User Mode, check whether a signal for any process has arrived.

The SIGKILL and SIGSTOP signals cannot be explicitly ignored or caught, and thus their default actions must always be executed. Therefore, SIGKILL and SIGSTOP allow a user with appropriate privileges to destroy and to stop, respectively, any process regardless of the defences taken by the program it is executing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>