158k views
5 votes
A Signal Is A Small Message That Notifies A Process That An Event Of Some Type Has Occurred. Each Signal Type Corresponds To Some Kind Of System Event. Signals Provide A Mechanism For Exposing Tese Low-Level Events To User Processes.

a. What does it mean for a process to ""catch"" a signal? How is this accomplished?
b. What does it mean for a signal to be ""pending""? How many signals of the same type can be queued?
c. How does the kernel block pending signals? What are the conditions need to do this?
d. How does an application block and unblock signals? What commands does it use? Why would it need to do this?

1 Answer

7 votes

Final answer:

In operating systems, catching a signal refers to a process having a specific function to handle that signal. A signal is pending when it has been sent but not handled. Applications can block and unblock signals to protect critical code sections.

Step-by-step explanation:

Understanding Process Signals in Operating Systems

When we discuss signals in the context of operating systems and processes, we're looking at the mechanism through which a process can be notified about a system event.

a. Catching a Signal

For a process to "catch" a signal means that the process has a specific handler function to execute when that signal is received. This is typically accomplished through system calls like signal() or sigaction() in UNIX-like operating systems, where the developer can specify which function to execute upon receiving the signal.

b. Pending Signals

A signal is considered "pending" when it has been delivered to a process but has not yet been handled. Only one instance of a non-queueable signal can be pending for a process at any one time. However, POSIX.1b real-time signals can be queued, increasing the count of the same signal type that can be pending.

c. Blocking Pending Signals

The kernel can block signals from being delivered using signal masks. Conditions for this include situations where certain operations need to be performed atomically without interruption, or while waiting for a specific event to happen before the signal can be handled.

d. Blocking/Unblocking Signals

An application can block and unblock signals using the sigprocmask() command or equivalent. The main reason for doing this is to protect critical sections of code from being interrupted by signal handlers, hence maintaining the integrity of data and sequential flow of operations.

User Andrei Kulik
by
8.7k points