Inter-Process Communication Signals and Signal Handling

inter process communication signals n.w
1 / 12
Embed
Share

Explore the fundamentals of inter-process communication signals, including asynchronous notifications and common signal types like SIGINT and SIGKILL. Learn about signal receipt, handling, and default behaviors, along with examples illustrating signal processing in operating systems.

  • Communication Signals
  • Signal Handling
  • Operating Systems
  • Process Management
  • Signal Types

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Inter-Process Communication: Signals David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO 63130 1

  2. Signals Asynchronous notifications: Generated by hardware or requested by another process Delivered to a specific process Processes receivesignals and respond Allows for event based programming Conceptually is very similar to hardware interrupts and exceptions, but for processes CSE 522S Advanced Operating Systems 2

  3. Common Signals SIGINT keyboard interrupt (CTRL+C) SIGTERM terminate program SIGKILL kill program immediately SIGSEV segmentation fault SIGUSR1 & SIGUSR2 Allows for the delivery of a notifications, but not for delivery of data. (E.g. segmentation faults simply crash) CSE 522S Advanced Operating Systems 3

  4. Signal Receipt For each type of signal, a process can handle signal delivery by: 1. Ignoring it 2. Terminating 3. Invoking a signal handler Additionally, a process may block delivery of certain signals. Undelivered signals are said to be pending. CSE 522S Advanced Operating Systems 4

  5. Signal Handler Example #include <signal.h> void sigusr1_handler( int signum ){ //Handle signal } int main( int argc, char* argv[]){ //Normal program flow } CSE 522S Advanced Operating Systems 5

  6. Signal Example Process A: Process B: Executes code Event happens kill( B, SIGUSR1); context switch Kernel sends signal context switch context switch context switch sigusr1_handler(); CSE 522S Advanced Operating Systems 6

  7. Signal Default Behaviors All signals have a default action. E.g.: SIGTERM terminate program SIGCHLD ignore signal See man 7 signalfor details Special signals that cannot be caught or blocked: SIGKILL (force quit vs. orderly shutdown) SIGSTOP CSE 522S Advanced Operating Systems 7

  8. Signals as Hardware Events A hardware event triggers an interrupt or exception handler that raises a signal, e.g.: Divide by zero (SIGFPE) Segmentation fault (SIGSEV) These are synchronous with program flow! Note: Signals allow userspace programs to respond to and correct hardware-level faults. Compare to how page faults are handled entirely within the kernel. CSE 522S Advanced Operating Systems 8

  9. Signal Handler Concurrency A signal handler may be called at any point of execution! Creates a concurrent programming problem even in single threaded programs! Deadlock Races Many of the same risks/strategies of interrupt handlers apply here CSE 522S Advanced Operating Systems 9

  10. Concurrency Race Example char* buffer; void sig_handler( int signum ){ buffer = Handler called\n ; write( buffer ); } int main( int argc, char* argv[] ){ buffer = Main called\n ; write( buffer ); } CSE 522S Advanced Operating Systems 10

  11. More Subtle Race int temp; void swap( int *a, int *b){ temp = &a; &a = &b; &b = temp; } What race can happen if this function is called from a signal handler and from elsewhere? CSE 522S Advanced Operating Systems 11

  12. Midterm Exam Score distribution: 101 100 97, 97, 97, 97 96 95 94, 94 92, 92 89 78 68 54 Class generally did well Two automatic bonus points given for Q.6 CSE 522S Advanced Operating Systems 12

Related


More Related Content