1gwu cs 259 brad taylor spring 2004 systems programming meeting 5: signals, time, timers, and token...

29
U CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Meeting 5: Signals, Time, Timers, Signals, Time, Timers, and Token Rings and Token Rings

Upload: melvyn-moore

Post on 04-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

1GWU CS 259 Brad Taylor Spring 2004

Systems Programming

Meeting 5:Meeting 5:

Signals, Time, Timers, Signals, Time, Timers, and Token Ringsand Token Rings

Page 2: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

2GWU CS 259 Brad Taylor Spring 2004

Objectives

•SignalsSignals

•Systems Programming Project Status ReportSystems Programming Project Status Report

•Time & TimersTime & Timers

•Token Ring of Processes: IPC using PipesToken Ring of Processes: IPC using Pipes

•Final Scheduling: Monday, May 3, 2004 (Agreed)Final Scheduling: Monday, May 3, 2004 (Agreed)

•Last class week discussion/agreement “Rescheduled Last class week discussion/agreement “Rescheduled Mondays” & final study groupMondays” & final study group

Page 3: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

3GWU CS 259 Brad Taylor Spring 2004

Seeking Interested Students

• Middleware ++Middleware ++• HabitatsHabitats• Complex Systems ProposalsComplex Systems Proposals• Interested Masters & Interested Masters & Doctorate Students …Doctorate Students …• Weekly Wednesday evening Weekly Wednesday evening meeting ~ 6:10 to 8:30meeting ~ 6:10 to 8:30• Food Provided!!! (usually Food Provided!!! (usually snacks, but you never know)snacks, but you never know)• Many papers & degrees Many papers & degrees generatedgenerated• No ties required ;)No ties required ;)

Page 4: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

4GWU CS 259 Brad Taylor Spring 2004

Signals

• What are they? Why use them?What are they? Why use them? • Software Interrupts for asynchronous Software Interrupts for asynchronous

eventsevents• What is their terminology?What is their terminology?• How do they work?How do they work? • Provide no information beyond signal Provide no information beyond signal

name (an integer)name (an integer)• How to deal with multiple How to deal with multiple

processes, threads? Concurrency …processes, threads? Concurrency …

Page 5: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

5GWU CS 259 Brad Taylor Spring 2004

Signals Terminology

• Signal Signal generatedgenerated when event causing signal when event causing signal occursoccurs

• DeliveredDelivered when receiving process takes when receiving process takes signal-based actionsignal-based action

• Signal Signal lifetimelifetime is interval between generation is interval between generation and deliveryand delivery

• A A pendingpending signal has been generated but not signal has been generated but not yet deliveredyet delivered

• To To catchcatch a signal, the process executes a a signal, the process executes a signal handlersignal handler when the signal is delivered when the signal is delivered

• Alternatively, a process can Alternatively, a process can ignoreignore a signal as a signal as when delivered, taking no actionwhen delivered, taking no action

Page 6: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

6GWU CS 259 Brad Taylor Spring 2004

Signals Terminology (con’t)

• The The sigactionsigaction function specifies what function specifies what a process does with a signal when a process does with a signal when delivereddelivered• The receiving process’ The receiving process’ signal masksignal mask determines when action is taken for a determines when action is taken for a generated signal, composed of signals to generated signal, composed of signals to be be blockedblocked • BlockedBlocked signals are not delivered to a signals are not delivered to a process until unblockedprocess until unblocked• The The sigprocmasksigprocmask function modifies a function modifies a signal masksignal mask• Each signal has a Each signal has a default actiondefault action that that usually terminates a process unless usually terminates a process unless handledhandled

Page 7: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

7GWU CS 259 Brad Taylor Spring 2004

Signals Examples

• Control keys on terminal (CNTL-C, Control keys on terminal (CNTL-C, CNTL+SHIFT+2, etc.)CNTL+SHIFT+2, etc.)

• Hardware exceptions: divide by zero (Hardware exceptions: divide by zero (SIGFPESIGFPE), ), invalid memory reference (invalid memory reference (SIGSEGVSIGSEGV), ), unaligned access (unaligned access (SIGBUSSIGBUS))

• kill() or kill – communicationkill() or kill – communication• raise(sig)raise(sig) = = kill(getpid(),sig)kill(getpid(),sig) – note to – note to

selfself• Software conditions: child terminated Software conditions: child terminated

((SIGCHLDSIGCHLD), write on pipe w/o readers ), write on pipe w/o readers ((SIGPIPESIGPIPE), timer expired (), timer expired (SIGALMSIGALM), urgent data ), urgent data available at socket (available at socket (SIGURGSIGURG))

Page 8: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

8GWU CS 259 Brad Taylor Spring 2004

Required POSIX Signals

• SIGABRTSIGABRT: Abnormal termination signal caused by the abort() : Abnormal termination signal caused by the abort() function (portable programs should avoid catching SIGABRT)function (portable programs should avoid catching SIGABRT)

• SIGALRMSIGALRM: The timer set by the alarm() function has timed-out: The timer set by the alarm() function has timed-out• SIGFPESIGFPE: Arithmetic exception, such as overflow or division by zero: Arithmetic exception, such as overflow or division by zero• SIGHUPSIGHUP: Controlling terminal hangup or controlling process death : Controlling terminal hangup or controlling process death

detected detected • SIGILLSIGILL: Illegal instruction indicating program error; Applications : Illegal instruction indicating program error; Applications

may catch this signal and attempt to recover from bugsmay catch this signal and attempt to recover from bugs• SIGINTSIGINT: Interrupt special character typed on controlling keyboard: Interrupt special character typed on controlling keyboard• SIGKILLSIGKILL: Termination signal: cannot be caught or ignored: Termination signal: cannot be caught or ignored• SIGPIPESIGPIPE: Write to a pipe with no readers: Write to a pipe with no readers• SIGQUITSIGQUIT: Quit special character typed on controlling keyboard: Quit special character typed on controlling keyboard• SIGSEGVSIGSEGV: Invalid memory reference. Like SIGILL, portable : Invalid memory reference. Like SIGILL, portable

programs should not intentionally generate invalid memory programs should not intentionally generate invalid memory referencesreferences

• SIGTERMSIGTERM: Termination signal: Termination signal• SIGUSR1SIGUSR1, , SIGUSR2SIGUSR2: Application-defined signal 1 & 2: Application-defined signal 1 & 2

Page 9: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

9GWU CS 259 Brad Taylor Spring 2004

POSIX Job Control Signals

• SIGCHLDSIGCHLD: Child process terminated or stopped; by : Child process terminated or stopped; by default, this signal is ignoreddefault, this signal is ignored

• SIGCONTSIGCONT: Continue the process if it is currently : Continue the process if it is currently stopped; otherwise, ignore the signalstopped; otherwise, ignore the signal

• SIGSTOPSIGSTOP: Stop signal; cannot be caught or ignored: Stop signal; cannot be caught or ignored• SIGTSTPSIGTSTP: Stop special character typed on the : Stop special character typed on the

controlling keyboardcontrolling keyboard• SIGTTINSIGTTIN: Read from the controlling terminal : Read from the controlling terminal

attempted by a background process groupattempted by a background process group• SIGTTOUSIGTTOU: Write to controlling terminal attempted : Write to controlling terminal attempted

by a member of a background process groupby a member of a background process group

Page 10: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

10GWU CS 259 Brad Taylor Spring 2004

Sending Signals

• A signal can be sent to a process from the command A signal can be sent to a process from the command line using line using killkill– kill -lkill -l lists signals system understands lists signals system understands– kill [-signal] pidkill [-signal] pid sends a signal to a process (optional sends a signal to a process (optional

argument is a name or number; default SIGTERM)argument is a name or number; default SIGTERM)– To unconditionally kill a process, use:To unconditionally kill a process, use:kill -9 pidkill -9 pid which is which is kill -KILL pidkill -KILL pid

• From program the From program the killkill system call can be used: system call can be used: #include <sys/types.h> #include <sys/types.h> #include <signal.h> #include <signal.h> int kill(pid_t pid, int sig);int kill(pid_t pid, int sig);

Page 11: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

11GWU CS 259 Brad Taylor Spring 2004

Signal Mask and Signal Sets

• Dealing with collections of signals has evolvedDealing with collections of signals has evolved• Originally, an Originally, an intint held a collection of bits, one per signal; now, held a collection of bits, one per signal; now,

signal sets of type signal sets of type sigset_tsigset_t used used

#include <signal.h> #include <signal.h> int sigemptyset(sigset_t *set); int sigemptyset(sigset_t *set); initializes to contain no signalsinitializes to contain no signalsint sigfillset(sigset_t *set); int sigfillset(sigset_t *set); put all signals in the setput all signals in the setint sigaddset(sigset_t *set, int signo); int sigaddset(sigset_t *set, int signo); add one signal to setadd one signal to setint sigdelset(sigset_t *set, int signo); int sigdelset(sigset_t *set, int signo); removes one signal removes one signal int sigismember(const sigset_t *set, int signo); int sigismember(const sigset_t *set, int signo); tests to see tests to see

if a signal is in the set if a signal is in the set

Page 12: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

12GWU CS 259 Brad Taylor Spring 2004

Signal Mask and Sets (con’t)

• The process signal mask is a set of blocked signalsThe process signal mask is a set of blocked signals• A blocked signal remains pending after generation until A blocked signal remains pending after generation until

unblockedunblocked• This mask is modified with the This mask is modified with the sigprocmasksigprocmask system call: system call:

#include <signal.h> #include <signal.h> int sigprocmask(int how, const sigset_t *set, sigset_t int sigprocmask(int how, const sigset_t *set, sigset_t

*oset);*oset);

• The The howhow can be: can be: – SIG_BLOCKSIG_BLOCK – SIG_UNBLOCKSIG_UNBLOCK – SIG_SETMASKSIG_SETMASK

• Either Either setset (pointer to signal set to be modified) or (pointer to signal set to be modified) or osetoset (returned (returned original signal set before modification) may be original signal set before modification) may be NULLNULL

Page 13: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

13GWU CS 259 Brad Taylor Spring 2004

Catching and Ignoring Signals

#include <signal.h> #include <signal.h> int sigaction(int signo, const struct sigaction *act, struct int sigaction(int signo, const struct sigaction *act, struct

sigaction *oact); sigaction *oact); struct sigaction { struct sigaction { void (*sa_handler)(); void (*sa_handler)(); /* SIG_DFL, SIG_IGN, or /* SIG_DFL, SIG_IGN, or

pointer to function */ pointer to function */ sigset_t sa_mask; sigset_t sa_mask; /* additional signals to be blocked /* additional signals to be blocked

during execution of handler */ during execution of handler */ int sa_flags; int sa_flags; /* special flags and options */ /* special flags and options */ };};

• Either Either actact or or oactoact may be may be NULLNULL• To handle signal,To handle signal, process must be scheduled to runprocess must be scheduled to run• SIG_IGN SIG_IGN specifies receiving & disposing of signal; what specifies receiving & disposing of signal; what

about about SIG_DFLSIG_DFL??

Page 14: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

14GWU CS 259 Brad Taylor Spring 2004

Waiting for Signals

• pausepause, , sigsuspendsigsuspend and and sigwaitsigwait evolved as well to avoid “Busy Waiting” evolved as well to avoid “Busy Waiting” (What is “Busy Waiting”?) (What is “Busy Waiting”?)

#include <unistd.h> #include <unistd.h> int pause(void); int pause(void);

• If signal received between testing and the If signal received between testing and the pausepause, may block forever , may block forever • Solution:Solution: atomically unblock the signal and suspend the process atomically unblock the signal and suspend the process

#include <signal.h> #include <signal.h> int sigsuspend(const sigset_t *sigmask);int sigsuspend(const sigset_t *sigmask);

• Sets the signal mask to the one pointed to by Sets the signal mask to the one pointed to by sigmasksigmask and suspends the and suspends the process until a signal is receivedprocess until a signal is received

• Signal mask restored to what it was before being called when returningSignal mask restored to what it was before being called when returning• sigwaitsigwait blocks any specified signal, removes that signal when handled, blocks any specified signal, removes that signal when handled,

and returns that signal’s value when handledand returns that signal’s value when handled

Page 15: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

15GWU CS 259 Brad Taylor Spring 2004

System Calls and Signals

Problems: system call interruption & non-reentrant system calls Problems: system call interruption & non-reentrant system calls • System Call InterruptionSystem Call Interruption: : • Some system calls that can block indefinitely long:Some system calls that can block indefinitely long:• return return -1-1 when a signal is delivered and set errno to when a signal is delivered and set errno to

EINTREINTR • These system calls are identified on their man pages (return These system calls are identified on their man pages (return

values list)values list)• Two that require special attention: Two that require special attention: readread and and writewrite • How would you handle a program segment to restart a How would you handle a program segment to restart a readread if if

interrupted by a signal?interrupted by a signal?• The The writewrite system should be handled similarly system should be handled similarly• Recall that you also need to handle a write that does not write Recall that you also need to handle a write that does not write

as many bytes as requestedas many bytes as requested

Page 16: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

16GWU CS 259 Brad Taylor Spring 2004

System Calls and Signals (con’t)

• Non-reentrant system callsNon-reentrant system calls: : • A function that can be safely called from a signal handler is A function that can be safely called from a signal handler is

called called async-signal-safeasync-signal-safe • Recall that functions like strtok are not async-signal-safe Recall that functions like strtok are not async-signal-safe • See table in text for a complete list of function calls that must See table in text for a complete list of function calls that must

be async-signal-safe if the POSIX standard is followedbe async-signal-safe if the POSIX standard is followed• Note that the C I/O functions such as Note that the C I/O functions such as fprintffprintf are are notnot included included• These may be safe under some implementations but not under These may be safe under some implementations but not under

othersothers• Although under Solaris, almost everything is async-signal-safe Although under Solaris, almost everything is async-signal-safe

if it can be, for compatibility, don’t assume other calls are if it can be, for compatibility, don’t assume other calls are safe!safe!

Page 17: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

17GWU CS 259 Brad Taylor Spring 2004

Signal Handler as Alarm Clock

#include <signal.h> #include <signal.h> int i, j; int i, j; void alarm_handler(int dummy) void alarm_handler(int dummy) {{ printf("Three seconds just passed: j = %d. i = %d\n", j, i); printf("Three seconds just passed: j = %d. i = %d\n", j, i); signal(SIGALRM, alarm_handler); signal(SIGALRM, alarm_handler); } }

main() main() { { signal(SIGALRM, alarm_handler); signal(SIGALRM, alarm_handler); alarm(3); alarm(3); for (j = 0; j < 200; j++) { for (j = 0; j < 200; j++) { for (i = 0; i < 1000000; i++); for (i = 0; i < 1000000; i++); } } } }

Page 18: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

18GWU CS 259 Brad Taylor Spring 2004

Project Status Report

Group I: Dan, Ricardo & Kamal / Wire SocketGroup I: Dan, Ricardo & Kamal / Wire Socket

Group II: Clayton, Jason / Named PipesGroup II: Clayton, Jason / Named Pipes

Group IIIa: Brooke, Emry / Shared Memory & FutexsGroup IIIa: Brooke, Emry / Shared Memory & Futexs

Group IIIb: Nush, Ram / Shared Memory & SemaphoresGroup IIIb: Nush, Ram / Shared Memory & Semaphores

Issues to discuss:Issues to discuss:Error checkingError checkingRough draft code submission for integration reviewRough draft code submission for integration reviewFurther Guidance, QuestionsFurther Guidance, Questions

Page 19: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

19GWU CS 259 Brad Taylor Spring 2004

Handling Time

• Motivation: second fractions countMotivation: second fractions count– Original Patriot missed Scud intercept: 28 solders die, 100 Original Patriot missed Scud intercept: 28 solders die, 100

injuredinjured– Internal clock calibrated in tenth-seconds (tick = 1/10 sec)Internal clock calibrated in tenth-seconds (tick = 1/10 sec)– Multiplied by 1/10 => Time (seconds)Multiplied by 1/10 => Time (seconds)– 0.10.110 10 = 0.0001100110011…= 0.0001100110011…22

– 24-bit truncated calculations24-bit truncated calculations– error = 1.10011… x 2error = 1.10011… x 2-24-24 ≈ 9.5 x 10 ≈ 9.5 x 10-8-8 /tick /tick– Tracking system operating 100 hours w/o rebootTracking system operating 100 hours w/o reboot– TTee == (9.5 x 10(9.5 x 10-8 -8 e/tick)(100 hr)(60 min/hr )(60 sec/min)(10 ticks/sec) ≈ e/tick)(100 hr)(60 min/hr )(60 sec/min)(10 ticks/sec) ≈

0.34 sec0.34 sec– Scud speed 1676 m/sec => Scud speed 1676 m/sec => – > ½ km error, exceeding “range gate”> ½ km error, exceeding “range gate”

• Some code time calculations had been improved, others not, Some code time calculations had been improved, others not, actually aggravating problem as inaccuracies no longer actually aggravating problem as inaccuracies no longer cancelled!cancelled!

BOOM!BOOM!

Page 20: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

20GWU CS 259 Brad Taylor Spring 2004

Clocks and Timers

• Provide current time, elapsed time, timerProvide current time, elapsed time, timer

• If programmable interval time used for timings, If programmable interval time used for timings, periodic interruptsperiodic interrupts

• ioctlioctl (on UNIX) covers odd aspects of I/O such (on UNIX) covers odd aspects of I/O such as clocks and timersas clocks and timers

• User interest and operating system interest User interest and operating system interest (scheduler, for example)(scheduler, for example)

• How do we handle time for a distributed system?How do we handle time for a distributed system?

Page 21: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

21GWU CS 259 Brad Taylor Spring 2004

Unix time Command

• Accurately timing things on computers is essential for: Accurately timing things on computers is essential for: – performance analysisperformance analysis– identification of bottlenecks in programsidentification of bottlenecks in programs– experimental determination of computational efficiencyexperimental determination of computational efficiency

• For large scale problems it is also important to track down For large scale problems it is also important to track down memory activity such as memory activity such as page faultspage faults; in this case, the data ; in this case, the data read in from disk can require 10-1000 times as long to accessread in from disk can require 10-1000 times as long to access

• I/O activity such as periodic output of computation state: I/O activity such as periodic output of computation state: although not always avoidable, sometimes this can be made although not always avoidable, sometimes this can be made more efficient by writing output files in binary format, or by more efficient by writing output files in binary format, or by spawning a separate output “thread”spawning a separate output “thread”

• The simplest way to time a program on a UNIX machine is to The simplest way to time a program on a UNIX machine is to use the time command: enter your typical command line after use the time command: enter your typical command line after it: it:

time make -ktime make -k

Page 22: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

22GWU CS 259 Brad Taylor Spring 2004

Timing Programs

• What Do We Measure? What Do We Measure? – Wall clock time: All other programs running, Wall clock time: All other programs running,

taking CPU away from youtaking CPU away from you– Unix Unix timetime: the amount of time processor : the amount of time processor

actually spends running your program actually spends running your program • Dos and Don'ts Dos and Don'ts

– Machine should be relatively quiet Machine should be relatively quiet – No one cares about wall clock time No one cares about wall clock time – Time only your algorithm (avoid I/O, Time only your algorithm (avoid I/O,

extraneous)extraneous)– NeverNever time user input time user input – Repeat your computation several times Repeat your computation several times

• Timing Programs in Java (wall clock; else?)Timing Programs in Java (wall clock; else?)

Page 23: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

23GWU CS 259 Brad Taylor Spring 2004

Real-Time Systems

• Often used for control devices in Often used for control devices in dedicated applications such as dedicated applications such as controlling scientific experiments, controlling scientific experiments, medical imaging systems, industrial medical imaging systems, industrial control systems, and some display control systems, and some display systemssystems

• Well-defined fixed-time constraintsWell-defined fixed-time constraints• Real-Time systems may be either Real-Time systems may be either hard hard or or

softsoft real-time real-time

Page 24: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

24GWU CS 259 Brad Taylor Spring 2004

Real-Time Characteristics

• Real-time systems defined as: "Real-time systems defined as: "those systems in which those systems in which the correctness of the system depends not only on the the correctness of the system depends not only on the logical result of the computation, but also on the time logical result of the computation, but also on the time at which the results are producedat which the results are produced";";– J. Stankovic, "Misconceptions About Real-Time Computing," J. Stankovic, "Misconceptions About Real-Time Computing,"

IEEE Computer,IEEE Computer, 21(10), October 1988. 21(10), October 1988.• Real-time systems often comprised of a Real-time systems often comprised of a controlling controlling

systemsystem, , controlled systemcontrolled system and and environmentenvironment– Controlling systemControlling system: acquires information about environment : acquires information about environment

using using sensorssensors and controls the environment with and controls the environment with actuatorsactuators• Timing constraintsTiming constraints derived from derived from physicalphysical impact of impact of

controlling systems activities, hard and soft controlling systems activities, hard and soft constraintsconstraints– Periodic TasksPeriodic Tasks: Time-driven recurring at regular intervals: Time-driven recurring at regular intervals– AperiodicAperiodic: Event-driven: Event-driven

Page 25: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

25GWU CS 259 Brad Taylor Spring 2004

Hard & Soft Real-Time

Hard real-time Hard real-time failure to meet constraint is a fatal fault; validated failure to meet constraint is a fatal fault; validated system always meets timing constraintssystem always meets timing constraints::– Secondary storage limited or absent, data stored in short term Secondary storage limited or absent, data stored in short term

memory, or read-only memory (ROM)memory, or read-only memory (ROM)– Conflicts with time-sharing systems, not supported by general-purpose Conflicts with time-sharing systems, not supported by general-purpose

operating systemsoperating systems– Deterministic constraintsDeterministic constraints– Probabilistic constraintsProbabilistic constraints– Constraints in terms of some usefulness functionConstraints in terms of some usefulness function

Soft real-time Soft real-time late completion is undesirable but generally not fatal; late completion is undesirable but generally not fatal; no validation or only demonstration job meets some statistical no validation or only demonstration job meets some statistical constraint; occasional missed deadlines or aborted execution is constraint; occasional missed deadlines or aborted execution is usually considered tolerable; often specified in probabilistic termsusually considered tolerable; often specified in probabilistic terms – Limited utility in industrial control of roboticsLimited utility in industrial control of robotics– Useful in applications (multimedia, virtual reality) requiring advanced Useful in applications (multimedia, virtual reality) requiring advanced

operating-system featuresoperating-system features

Page 26: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

26GWU CS 259 Brad Taylor Spring 2004

Typical Real-Time System

Controlling System

Environment

sensorsensorsensorsensoractuatoractuatoractuatoractuator

Controlled System

ACTUATORDESIRED

RESPONSE

FEEDBACK ELEMENTS

{SENSOR(s)}

+

_Error

SOFTWARECONTROL {PID, MBC,

etc.} ENVIRONMENT{Temp, Pres,

D/P, Flow, etc.}

PLANT

CO

ND

I-T

ION

ING

Page 27: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

27GWU CS 259 Brad Taylor Spring 2004

Other Real-Time Concerns

DeterminismDeterminism - one measure: delay between - one measure: delay between interrupt assertion and executing the ISRinterrupt assertion and executing the ISR

ResponsivenessResponsiveness - time to service interrupt - time to service interrupt

User ControlUser Control

ReliabilityReliability

Fail-soft operationFail-soft operation

Page 28: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

28GWU CS 259 Brad Taylor Spring 2004

Developing a Reference Model

Modeling the system to focus on timing properties Modeling the system to focus on timing properties and resource requirements. Composed of three and resource requirements. Composed of three elements:elements:– workload model workload model - describes supported applications - describes supported applications

» Temporal parametersTemporal parameters» Precedence constraints and dependenciesPrecedence constraints and dependencies» Functional parametersFunctional parameters

– resource modelresource model - describes available system resources - describes available system resources» Modeling resources (Processors and Resources)Modeling resources (Processors and Resources)» Resource parametersResource parameters

– algorithmsalgorithms - how application uses resources at all times - how application uses resources at all times» Scheduling HierarchyScheduling Hierarchy

Page 29: 1GWU CS 259 Brad Taylor Spring 2004 Systems Programming Meeting 5: Signals, Time, Timers, and Token Rings

29GWU CS 259 Brad Taylor Spring 2004

Token Ring of Processes

Example of pipes supporting Inter-Example of pipes supporting Inter-Process CommunicationProcess Communication

Course web page link to text Course web page link to text author’s java applet …author’s java applet …