lec16 - CS240: Programming in C Lecture 16: Signals...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS240: Programming in C Lecture 16: Signals Tuesday, April 12, 2011 Synchronous vs. Asynchronous Synchronous action: A procedure call: the caller calls the callee and waits until the callee returns with a result A phone call: both parties must be available for the call to go through. An asynchronous action: A response from the environment: user types Ctrl-C while the program runs Email or text messages can be sent without the other party ready to receive 2 Tuesday, April 12, 2011 Dealing with an Asynchronous Action 3 1. Poll: ask the kernel or the OS: did event E take place since the last time I checked? 2. Handle: inform the kernel that when event E takes place, do the following ... Tuesday, April 12, 2011 Kinds of Signals 4 Interrupts . Environment-triggered (SIGINT, Ctrl-C) Hardware . (SIGSEGV); divide by 0, invalid memory reference Software . (SIGPIPE, SIGALRM). Timeout on network connection, a broken pipe, ... Tuesday, April 12, 2011 Handling a Signal Ignore it. Doesnt always work though (e.g., not a good idea to ignore a hardware exception...) Catch the signal setup a signal handler that gets invoked whenever the signal occurs. All signals have a default action Most of the time, the default is to kill the process....
View Full Document

This note was uploaded on 02/23/2012 for the course CS 240 taught by Professor Rego during the Spring '08 term at Purdue University-West Lafayette.

Page1 / 13

lec16 - CS240: Programming in C Lecture 16: Signals...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online