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

About This Presentation
Title:

Task Control: Signals and Alarms Havilland and Salama

Description:

Task Control: Signals and Alarms Havilland and Salama s Unix Systems Programming B. Ramamurthy Page * Page * Multi-tasking How to create multiple tasks? – PowerPoint PPT presentation

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

less

Transcript and Presenter's Notes

Title: Task Control: Signals and Alarms Havilland and Salama


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

2
Multi-tasking
  • How to create multiple tasks? Ex Xinu create()
  • How to control them?
  • ready()
  • resched()
  • How to synchronize them? How to communicate among
    them?
  • XINU 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
  • SIGHUP, SIGINT, SIGILL, SIGTRAP, SIGFPE, SIGKILL,
    SIGALRM (sent by kernel to a process after an
    alarm timer has expired)
  • SIGTERM

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 secsonds and
    will interrupt the calling process after a secs.
  • 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