Process Control: Signals and Alarms Havilland and Salama - PowerPoint PPT Presentation

About This Presentation
Title:

Process Control: Signals and Alarms Havilland and Salama

Description:

The error in the program results in a signal to kernel to stop and ... However each type of signal is given a mnemonic name; Ex: SIGINT. See signal.h for others ... – PowerPoint PPT presentation

Number of Views:69
Avg rating:3.0/5.0
Slides: 9
Provided by: binarama
Learn more at: https://cse.buffalo.edu
Category:

less

Transcript and Presenter's Notes

Title: Process Control: Signals and Alarms Havilland and Salama


1
Process ControlSignals and AlarmsHavilland and
Salamas Unix Systems Programming
  • B. Ramamurthy

2
Multi-processing
  • How to create multiple tasks?
  • How to control them?
  • How to synchronize them? How to communicate among
    them?
  • semaphores, send and receive messages
  • How to (software) interrupt a process? signals

3
Examples
  • Consider g myProg.c
  • You want to kill this process after you started
    the compilation..hit cntrl-C
  • Consider execution of a program called badprog
  • gtbadprog
  • It core dumps .. What happened? The error in the
    program results in a signal to kernel to stop and
    dump the offending code
  • Consider kill p ltpidgt
  • Kill issues a termination signal to the process
    identified by the pid

4
Signals
  • Signals provide a simple method for transmitting
    software interrupts to UNIX process
  • Signals cannot carry information directly, which
    limits their usefulness as an general
    inter-process communication mechanism
  • However each type of signal is given a mnemonic
    name Ex SIGINT
  • See signal.h for others
  • SIGSEGV, SIGBUS, SIGINT, SIGILL, SIGTRAP, SIGFPE,
    SIGKILL, SIGALRM (sent by kernel to a process
    after an alarm timer has expired)

5
Handling Signals
  • Look at the examples
  • Catching SIGALRM
  • Ignoring SIGALRM
  • sigtest.c

6
Signals and Alarms
  • include ltunistd.hgt
  • unsigned int alarm( unsigned int seconds )
  • alarm(a) will start a timer for a milliseconds
    and will interrupt the calling process after a
    milliseconds.
  • time(t) will get you current time in the
    variable t declared as time_t t
  • ctime(t) will convert time to ascii format

7
Sample program
  • Lets look at a sample program

8
Volatile
  • A variable should be declared volatile whenever
    its value could change unexpectedly. In practice,
    only three types of variables could change
  • Memory-mapped peripheral registers
  • Global variables modified by an interrupt service
    routine
  • Global variables within a multi-threaded
    application
Write a Comment
User Comments (0)
About PowerShow.com