Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider a multithreaded program using UNIX signal. The program creates multiple

ID: 3594728 • Letter: C

Question

Consider a multithreaded program using UNIX signal. The program creates multiple threads. It also installs custom signal handlers for various signals. A subtlety arises because there are many threads in the process, but only one thread will be interrupted and delivered the signal.
(a) Imagine the program sets a timer using alarm(). The SIGALRM is expected to be delivered to the process. Question: To which thread should SIGALRM be delivered? Explain why.
(b) Imagine the program also catches SIGSEGV signal. A SIGSEGV signal is raised when the program incurs a memory access violation, likely caused by a memory pointer bug. (SEGV stands for segmentation violation – ‘segmentation’ is the name for a type of memory protection. Catching SIGSEGV gives a program a chance to look at the source of the bug – many runtime debuggers catches SIGSEGV) Question: To which thread should SIGSEGV be delivered? Explain why.
Consider a multithreaded program using UNIX signal. The program creates multiple threads. It also installs custom signal handlers for various signals. A subtlety arises because there are many threads in the process, but only one thread will be interrupted and delivered the signal.
(a) Imagine the program sets a timer using alarm(). The SIGALRM is expected to be delivered to the process. Question: To which thread should SIGALRM be delivered? Explain why.
(b) Imagine the program also catches SIGSEGV signal. A SIGSEGV signal is raised when the program incurs a memory access violation, likely caused by a memory pointer bug. (SEGV stands for segmentation violation – ‘segmentation’ is the name for a type of memory protection. Catching SIGSEGV gives a program a chance to look at the source of the bug – many runtime debuggers catches SIGSEGV) Question: To which thread should SIGSEGV be delivered? Explain why.
Consider a multithreaded program using UNIX signal. The program creates multiple threads. It also installs custom signal handlers for various signals. A subtlety arises because there are many threads in the process, but only one thread will be interrupted and delivered the signal.
(a) Imagine the program sets a timer using alarm(). The SIGALRM is expected to be delivered to the process. Question: To which thread should SIGALRM be delivered? Explain why.
(b) Imagine the program also catches SIGSEGV signal. A SIGSEGV signal is raised when the program incurs a memory access violation, likely caused by a memory pointer bug. (SEGV stands for segmentation violation – ‘segmentation’ is the name for a type of memory protection. Catching SIGSEGV gives a program a chance to look at the source of the bug – many runtime debuggers catches SIGSEGV) Question: To which thread should SIGSEGV be delivered? Explain why.

Explanation / Answer

Answer) SIGALRM will be delivered to the thread that called the "alarm" subroutine. As we have called the alarm subroutine, so that process only will got SIGALRM.

Answer) The thread that causes the segmentation fault or access to the corrupt memory, for that thread only we got the SIGSEGV

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote