Thursday, 14 May 2015

Q57,paper 3, J 12. A user level process in Unix traps the signal sent on a Ctrl + C input and has a signal handling routine that saves appropriate files before terminating the process. When a Ctrl + C input is given to this process, what is the mode in which the signal handling routine executes ?


Options (A) User mode
(B) Kernel mode
(C) Superuser mode
(D) Privileged mode.
Answer (B) Kernel mode.
Explanation.
• Hardware interrupts (also called external/asynchronous interrupts), are ones in which the notification originates from a hardware device such as a keyboard, mouse or system clock.
• Software interrupts include exceptions and traps Exceptions: trigerred by an action of the process without its knowledge (division by zero, access to paged memory, etc.) Traps: trigerred by the process using system calls
Signals are notifications sent to a process in order to notify it of various "important" events. Signals cause the process to stop whatever it is doing at the moment, and force the process to handle them immediately. The process may configure how it handles a signal.(Except for some signals that it cannot configure) Difference between signals and interrupts.
• Signals are generated by the OS,
and received and handled by a process.
• Interrupts are generated by the hardware,
and received and handled by the OS.
• Signals and interrupts are both asynchronous
• Signals in unix have names and numbers.
• Use ‘man kill’ to see the types of signals
Some examples for signal triggers: 1.Asynchronous input from the user such as ^C (SIGINT), or typing ‘kill pid’ at the shell.
2.The system or another process, for instance if an alarm set by the process has timed out (SIGALRM).
The most common way of sending signals to processes is using the keyboard:
• Ctrl-C: Causes the system to send an INT signal (SIGINT) to the running process.
• Ctrl-Z: causes the system to send a TSTP signal (SIGTSTP) to the running process.
Ctrl-\:causes the system to send a ABRT signal (SIGABRT) to the running process.
The kernel handles signals in the context of the process that receives them, so
a process must run to handle signals.

There are three types of handling for signals:
• The process exits. (default for some signals)
• The process ignores. (default for some other signals)
• The process executes a signal handler:

No comments:

Post a Comment

Note: only a member of this blog may post a comment.