Asynchronism. Asynchronism. Asynchronism. Interrupts. Asynchronism. Interrupts. Asynchronism close to hardware

Size: px
Start display at page:

Download "Asynchronism. Asynchronism. Asynchronism. Interrupts. Asynchronism. Interrupts. Asynchronism close to hardware"

Transcription

1 474 Real-Time & Embedded 5 Systems 2015 Uwe R. Zimmer - The Australian National University 476 close to hardware Interrupts Required mechanisms for interrupt driven programming: Interrupt control: Grouping, encoding, prioritising, and en-/disabling interrupt sources switching: Mechanisms for cpu-state saving and restoring + task-switching Interrupt identification: Interrupt vectors, interrupt states Hardware supported Implemented in software 2015 Uwe R. Zimmer, The Australian National University page 476 of 962 (chapter 5: up to page 620) 475 References [ Barnes2006 ] Barnes, John Programming in Ada 2005 Addison-Wesley, Pearson education, ISBN , Harlow, England 2006 [ Burns2007 ] Burns, A & Wellings, A Concurrent and Real-Time Programming in Ada, edition Cambridge University Press 2007 [ Dibble2009 ] Dibble, Peter RTSJ JSR-282 Early Draft Review version pp [ NN2004 ] The Real-Time Java Platform A Technical White Paper June pp [AdaRM2012] Ada Reference Manual - Language and Standard Libraries; ISO/IEC 8652:201x (E) 2015 Uwe R. Zimmer, The Australian National University page 475 of 962 (chapter 5: up to page 620) 477 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level 2015 Uwe R. Zimmer, The Australian National University page 477 of 962 (chapter 5: up to page 620)

2 478 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level 2015 Uwe R. Zimmer, The Australian National University page 478 of 962 (chapter 5: up to page 620) 480 LM12L458 Register bank A4 A3 A2 A1 Purpose Type D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D Instruction RAM R/W Acquisition Watch- 0 to (RAM Pointer = 00) Time dog 8/12 Timer Sync V VIN+ Pause Loop Instruction RAM R/W 0 to (RAM Pointer = 0 1) Don t Car e >/< S ign Limit # Instruction RAM R/W 0 to (RAM Pointer = 1 0) Don t Car e >/< S ign Limit # Configuration R/W Test RAM I/O Auto Chan Stand- Full Auto- Reset Start Don t Care DIAG Register = 0 Pointer Sel Zero ec Mask by CAL Zero Interrupt Enable R/W Number of Conversions Sequencer INT7 Don t INT5 INT4 INT3 INT2 INT1 INT Register in Conversion FIFO Address to Care to Generate INT2 Generate INT1 Address R Actual Number of of INST7 0 INST5 INST4 INST3 INST2 INST1 INST Interrupt Status Conversion Results Sequencer Register in Conversion FIFO Instruction being Executed Timer R/W Timer Preset High Byte Timer Preset Low Byte Register Conversion R Address Sign Conversion Conversion Data: LSBs FIFO or Sign Data: MSBs Limit Status R Limit # 2 Status Limit #1: Status Register 2015 Uwe R. Zimmer, The Australian National University page 480 of 962 (chapter 5: up to page 620) 479 A/D, D/A & Interfaces: Examples LM12L458 (National Semiconductors) 2015 Uwe R. Zimmer, The Australian National University page 479 of 962 (chapter 5: up to page 620) 481 LM12L458 Data transfer options A4 A3 A2 A1 Purpose Type D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 Interrupt Enable R/W Number of Conversions Sequencer INT7 Don t INT5 INT4 INT3 INT2 INT1 INT Register in Conversion FIFO Address to Care to Generate INT2 Generate INT1 Address R Actual Number of of INST7 0 INST5 INST4 INST3 INST2 INST1 INST Interrupt Status Conversion Results Sequencer Register in Conversion FIFO Instruction being Executed Select interrupt source (interrupt enable register, 15 bits): Watchdog (INT0): limit conditions are fulfilled. Instruction (INT1): the instruction pointer equals a pre-programmed value (bits 8-10). Conversions (INT2): a specified number of conversions (bits 11-15) have been performed. Auto-Zero (INT3): short calibration has been performed. Full-Calibration (INT4): long calibration has been performed. Pause (INT5): Sequencer arrived at a pause state. Active (INT7): Controller returned from power-down to active mode Uwe R. Zimmer, The Australian National University page 481 of 962 (chapter 5: up to page 620) :

3 482 LM12L458 Data transfer options A4 A3 A2 A1 Purpose Type D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 Interrupt Enable R/W Number of Conversions Sequencer INT7 Don t INT5 INT4 INT3 INT2 INT1 INT Register in Conversion FIFO Address to Care to Generate INT2 Generate INT1 Address R Actual Number of of INST7 0 INST5 INST4 INST3 INST2 INST1 INST Interrupt Status Conversion Results Sequencer Register in Conversion FIFO Instruction being Executed Read interrupt status (interrupt status register, 15 bits): Indicates the currently active interrupts Shows the actual number of conversions and the currently processed instruction. Reading this register resets all status bits (bits 0-5, 7) Uwe R. Zimmer, The Australian National University page 482 of 962 (chapter 5: up to page 620) 484 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level 2015 Uwe R. Zimmer, The Australian National University page 484 of 962 (chapter 5: up to page 620) 483 A/D, D/A & Interfaces: Examples LM12L458 (National Semiconductors) Single interrupt line Identifying the actual source requires an additional read cycle 2015 Uwe R. Zimmer, The Australian National University page 483 of 962 (chapter 5: up to page 620) 485 close to hardware Interrupts System interrupt controller: Collects the interrupt signal lines from all managed devices. [Identifies the device status], if not given already as an interrupt vector index. Encodes all interrupt signals into a common interrupt vector or status scheme. Orders and masks all interrupts according to priority levels. Triggers an actual CPU interrupt. Three common forms: Embedded interrupt controller as an intrinsic part of a complex micro-controller. Dedicated interrupt controller for a set of similar or identical devices (e.g. a hard disk array). Universal interrupt controller (usually unable to fetch interrupt status information) Uwe R. Zimmer, The Australian National University page 485 of 962 (chapter 5: up to page 620)

4 486 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level Come on three levels: Interrupt service routines: Does not involve processes. Communicating interrupts to processes: Synchronize to events or data structures. Transforming interrupts to signals: Notify the scheduler that a process is to be activated Uwe R. Zimmer, The Australian National University page 486 of 962 (chapter 5: up to page 620) 488 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level Come on three levels: Interrupt service routines: Does not involve processes. Communicating interrupts to processes: Synchronize to events or data structures. Transforming interrupts to signals: Notify the scheduler that a process is to be activated Uwe R. Zimmer, The Australian National University page 488 of 962 (chapter 5: up to page 620) 487 close to hardware Interrupts (at the operating system level) Come on three levels: Interrupt service routines: Does not involve processes. All activities under strict real-time constraints will be addressed here. Communicating interrupts to processes: Synchronize to events or data structures. After the reactive part of the response has been addressed, processes might need to be notified about the current state. Transforming interrupts to signals: Notify a process via the scheduler. For activities which are not under real-time constraints, the interrupt can be translated into a signal (scheduler-level event) Uwe R. Zimmer, The Australian National University page 487 of 962 (chapter 5: up to page 620) 489 close to hardware Interrupt service routines (available in real-time operating systems and languages only) Purpose: Allow full access to the interrupt controller (interrupt vectors, priorities) and device. Activate a routine in a predictable amount of time. Cannot operate on the level of threads or tasks! Limitations regarding the accessibility of some OS-facilities (task level system calls) Uwe R. Zimmer, The Australian National University page 489 of 962 (chapter 5: up to page 620)

5 490 close to hardware Interrupt service routines (available in real-time operating systems and languages only) Some VxWorks OS entries: intconnect Connect a routine to an interrupt vector intlevelset Set the interrupt mask level IntLock Disable interrupts (besides NMI) intunlock Enable interrupts intvecset Set the interrupt vector base address intvecget Get the interrupt vector base address intvecset Set an interrupt vector intvecget Get an interrupt vector 2015 Uwe R. Zimmer, The Australian National University page 490 of 962 (chapter 5: up to page 620) 492 close to hardware Interrupt service routines (available in real-time operating systems and languages only) Initial response to interrupt (executed by CPU without any software involved): save (push) essential CPU registers (IP, condition flags, ()) jump to the (vectorized) interrupt service routine Further detail: Interrupt masks are typically raised to the current level by hardware, yet can be readjusted inside the wrapper code or service routine. Optional/common software wrapper (added by the os / runtime environment): save (push) remaining/needed CPU registers save (push) stack-frame Execute interrupt service routine code Reentrant interrupt service routines. restore (pop) stack-frame restore (pop) all remaining/touched CPU registers Special CPU instruction (also added by the os / runtime environment): restore (RTE/IRET) IP, condition flags, () 2015 Uwe R. Zimmer, The Australian National University page 492 of 962 (chapter 5: up to page 620) 491 close to hardware Interrupt service routines (available in real-time operating systems and languages only) Initial response to interrupt (executed by CPU without any software involved): save (push) essential CPU registers (IP, condition flags, ()) jump to the (vectorized) interrupt service routine Optional/common software wrapper (added by the os / runtime environment): save (push) remaining/needed CPU registers save (push) stack-frame Execute interrupt service routine code restore (pop) stack-frame restore (pop) all remaining/touched CPU registers Special CPU instruction (also added by the os / runtime environment): restore (RTE/IRET) IP, condition flags, () 2015 Uwe R. Zimmer, The Australian National University page 491 of 962 (chapter 5: up to page 620) 493 Code management Processor Architectures Interrupts Int. IP Decoder Sequencer One or multiple lines wired directly into the sequencer Required for: Pre-emptive scheduling, Timer driven actions, Transient hardware interactions, Usually preceded by an external logic ( interrupt controller ) which accumulates and encodes all external requests. Memory ALU Data management On interrupt (if unmasked): CPU stops normal sequencer flow. Lookup of interrupt handler s address Current IP and state pushed onto stack. IP set to interrupt handler Uwe R. Zimmer, The Australian National University page 493 of 705 (chapter 5: up to page 620)

6 494 Program Interrupt processing Interrupt handler Stack Code FP 2015 Uwe R. Zimmer, The Australian National University page 494 of 962 (chapter 5: up to page 620) 496 Program Stack Interrupt processing Interrupt handler Push registers Declare local variables Code Local variables 2015 Uwe R. Zimmer, The Australian National University page 496 of 962 (chapter 5: up to page 620) 495 Interrupt handler Program Interrupt processing Stack Code FP 2015 Uwe R. Zimmer, The Australian National University page 495 of 962 (chapter 5: up to page 620) 497 Program Code Stack Local variables Interrupt processing Interrupt handler Push registers Declare local variables Run handler code.. do some I/O.... or run some time critical code Uwe R. Zimmer, The Australian National University page 497 of 962 (chapter 5: up to page 620)

7 498 Program Code Stack Interrupt processing Interrupt handler Push registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables 2015 Uwe R. Zimmer, The Australian National University page 498 of 962 (chapter 5: up to page 620) 500 Program Code Stack FP Interrupt processing Interrupt handler Push registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables Pop registers Return from interrupt 2015 Uwe R. Zimmer, The Australian National University page 500 of 962 (chapter 5: up to page 620) 499 Program Code Stack FP Interrupt processing Interrupt handler Push registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables Pop registers 2015 Uwe R. Zimmer, The Australian National University page 499 of 962 (chapter 5: up to page 620) 501 Program Interrupt processing Interrupt handler Stack Code FP 2015 Uwe R. Zimmer, The Australian National University page 501 of 962 (chapter 5: up to page 620)

8 502 Interrupt handler Program Interrupt processing Stack Code FP Scratch registers LR is loaded with a special value 2015 Uwe R. Zimmer, The Australian National University page 502 of 962 (chapter 5: up to page 620) 504 Program Code Stack Local variables Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Push other registers Declare local variables Scratch registers 2015 Uwe R. Zimmer, The Australian National University page 504 of 962 (chapter 5: up to page 620) 503 Program Stack Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Code FP Scratch registers 2015 Uwe R. Zimmer, The Australian National University page 503 of 962 (chapter 5: up to page 620) 505 Program Code Stack Local variables Scratch registers Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Push other registers Declare local variables Run handler code.. do some I/O.... or run some time critical code Uwe R. Zimmer, The Australian National University page 505 of 962 (chapter 5: up to page 620)

9 506 Program Code Stack Scratch registers Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Push other registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables Pop other registers 2015 Uwe R. Zimmer, The Australian National University page 506 of 962 (chapter 5: up to page 620) 508 Program Code Stack FP Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Push other registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables Pop other registers Return ("bx lr") 2015 Uwe R. Zimmer, The Australian National University page 508 of 962 (chapter 5: up to page 620) 507 Program Code Stack Scratch registers Interrupt processing Interrupt handler Clear interrupt flag (Adjust priorities) (Re-enable interrupt) Push other registers Declare local variables Run handler code.. do some I/O.... or run some time critical code.. Remove local variables Pop other registers Return ("bx lr") 2015 Uwe R. Zimmer, The Australian National University page 507 of 962 (chapter 5: up to page 620) 509 Interrupt handler Things to consider Interrupt handler code can be interrupted as well. Are you allowing to interrupt an interrupt handler with an interrupt on the same priority level (e.g. the same interrupt)? Can you overrun a stack with interrupt handlers? 2015 Uwe R. Zimmer, The Australian National University page 509 of 962 (chapter 5: up to page 620)

10 510 Multiple programs If we can execute interrupt handler code concurrently to our main program: Can we then also have multiple main programs? 2015 Uwe R. Zimmer, The Australian National University page 510 of 962 (chapter 5: up to page 620) 512 Process 1 B PID switch Dispatcher Process 2 B PID Code Stack Code Stack FP switchvariables 2015 Uwe R. Zimmer, The Australian National University page 512 of 962 (chapter 5: up to page 620) 511 switch Dispatcher Process 1 Process 2 B PID B PID Code Stack Code Stack FP switchvariables switchvariables 2015 Uwe R. Zimmer, The Australian National University page 511 of 962 (chapter 5: up to page 620) 513 Process 1 B PID switch Dispatcher Push registers Declare local variables Process 2 B PID Code Stack Code Stack switchvariables 2015 Uwe R. Zimmer, The Australian National University page 513 of 962 (chapter 5: up to page 620)

11 514 Process 1 B PID switch Dispatcher Push registers Declare local variables Store to B 1 Process 2 B PID Code Stack Code Stack switchvariables switchvariables switchvariables 2015 Uwe R. Zimmer, The Australian National University page 514 of 962 (chapter 5: up to page 620) 516 Process 1 B PID switch Code Stack Code Stack switchvariables Dispatcher Push registers Declare local variables Store to B 1 Scheduler Load from B 2 Process 2 B PID 2015 Uwe R. Zimmer, The Australian National University page 516 of 962 (chapter 5: up to page 620) 515 Process 1 B PID switch Code Stack Code Stack switchvariables switchvariables Dispatcher Push registers Declare local variables Store to B 1 Scheduler Process 2 B PID switchvariables 2015 Uwe R. Zimmer, The Australian National University page 515 of 962 (chapter 5: up to page 620) 517 Process 1 B PID switch Code Stack Code Stack Dispatcher Push registers Declare local variables Store to B 1 Scheduler Load from B 2 Remove local variables Process 2 B PID 2015 Uwe R. Zimmer, The Australian National University page 517 of 962 (chapter 5: up to page 620)

12 518 Process 1 B PID switch Code Stack Code Stack switchvariables Dispatcher Push registers Declare local variables Store to B 1 Scheduler Load from B 2 Remove local variables Pop registers Process 2 B PID FP 2015 Uwe R. Zimmer, The Australian National University page 518 of 962 (chapter 5: up to page 620) 520 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level Come on three levels: Interrupt service routines: Does not involve processes. Communicating interrupts to processes: Synchronize to events or data structures. Transforming interrupts to signals: Notify the scheduler that a process is to be activated Uwe R. Zimmer, The Australian National University page 520 of 962 (chapter 5: up to page 620) 519 Process 1 B PID switch Code Stack Code Stack switchvariables Dispatcher Push registers Declare local variables Store to B 1 Scheduler Load from B 2 Remove local variables Pop registers Return from interrupt Process 2 B PID FP 2015 Uwe R. Zimmer, The Australian National University page 519 of 962 (chapter 5: up to page 620) 521 close to hardware Communicating interrupts to processes Interrupt service routine to task communication methods: Shared memory and ring buffers: most low level communication scheme. Semaphore: trigger a semaphore, where a task has been blocked before. Monitors: free a task, which is blocked at a monitor entry (standard Ada-method: protected object). Message queues: Send asynchronous messages to a task (if queue is not full). Pipes: Write to a pipe (if pipe is not full). Signals: indicate an asynchronous task switch to the scheduler. In all cases: The interrupt service routine cannot block! 2015 Uwe R. Zimmer, The Australian National University page 521 of 962 (chapter 5: up to page 620)

13 522 close to hardware Interrupts Interrupt control at the individual device level at the system interrupt controller level at the operating system level Come on three levels: Interrupt service routines: Does not involve processes. Communicating interrupts to processes: Synchronize to events or data structures. Transforming interrupts to signals: Notify the scheduler that a process is to be activated Uwe R. Zimmer, The Australian National University page 522 of 962 (chapter 5: up to page 620) 524 close to hardware Interrupts Signals Signals are originally a process-level synchronization / termination method ( kill ) yet are currently been used for everything from hardware-interrupts and timers to asynchronous task messaging. Signals are passed through the system wide scheduler. Signals carry little information as to what happened. Unpredictable work-around for missing direct hardware interrupt propagation. Make sure that you understand the attached strings, before employing any signals Uwe R. Zimmer, The Australian National University page 524 of 962 (chapter 5: up to page 620) 523 close to hardware Interrupts Signals POSIX b BSD-UNIX signal signal Specify the handler associated with a signal sigaction sigvec Examine or set the signal handler for a signal kill kill Send a signal (overwrite all other pending signals) sigqueue Send a queued signal sigsuspend pause Wait for a signal sigwaitinfo, sigtimedwait Wait for a signal, but do not invoke the handler sigemptyset sigsetmask Manipulate and set the mask of blocked signals sigprocmask sigblock Add to a set of blocked signals 2015 Uwe R. Zimmer, The Australian National University page 523 of 962 (chapter 5: up to page 620) 525 in general program flows Exceptions Wish list for exception handling in real-time programming languages: 1. Exception facilities should not obscure the understanding of the normal, exception-free control flow. 2. Exception facilities should produce no or minimal runtime overhead, until an exception actually occurs. 3. Exceptions should produce predictable run-time overhead when an exception occurs. 4. Exceptions indicated by the run-time environment and by the program itself should be treated uniformly. 5. The exception mechanism should be applicable to asynchronous and synchronous exceptions ( might be hard to achieve with respect to wish 3). 6. The exception mechanism should allow for appropriate recoveries (supply sufficient information and appropriate re-entry possibilities) Uwe R. Zimmer, The Australian National University page 525 of 962 (chapter 5: up to page 620)

14 526 in general program flows Exceptions (Historic exception handling methods) Use an unusual return value and a global variable convention: if (function_call (parameters) < NORMAL_RETURN_VALUE) { if errno == SOME_KNOWN_ERROR { /* react to the known error condition */ else { /* try to improvise something */ else { normal control flow ; Inflexible (exceptions from the environment cannot be detected). Error-prone (lots of chances to forget checking or to use the wrong constants). Obstructive (all fragments are commingled) Uwe R. Zimmer, The Australian National University page 526 of 962 (chapter 5: up to page 620) 528 in general program flows Exceptions (Assembler level) Provide a jump table and manipulate the return address on the stack: jsr pc, PRINT_CHAR jmp IO_ERROR jmp DEVICE_NOT_ENABLED # normal processing Caller: Subroutine: % indicate an exception: % increment the return address on the stack % by the exception number to employ the caller-provided exception handling % indicate normal operation: % increment the return address on the stack by the max. exception number Uwe R. Zimmer, The Australian National University page 528 of 962 (chapter 5: up to page 620) 527 in general program flows Exceptions (Historic exception handling methods) Use an unusual return value and a global variable convention: if (function_call (parameters) < NORMAL_RETURN_VALUE) UE { if errno == SOME_KNOWN_ERROR OR { /* react to the known error ror condition */ else { /* try to improvise something */ ; else { normal control ol flow Inflexible (exceptions from the environment cannot be detected). Error-prone (lots of chances to forget checking or to use the wrong constants). Obstructive (all fragments are commingled) Uwe R. Zimmer, The Australian National University page 527 of 962 (chapter 5: up to page 620) 529 in general program flows Exceptions (Historic languages) Emulate exception handling methods by returning a: Jump label for unrecoverable exceptions. Procedure variable for recoverable exceptions. Outdated as all current real-time programming languages provide some intrinsic means of exception handling. All exception handling methods up to here operate on subroutine level, while all current day exception handling methods operate on block level Uwe R. Zimmer, The Australian National University page 529 of 962 (chapter 5: up to page 620)

15 530 in general program flows Exceptions (Early high level constructs in not-fully-scoped languages) PL/I (IBM, 1960 s): Exception handling routines are registered globally by running over an On code section: On <exception-name> ; ( statements ) [<long jump to continuation code>] end; Exception handling routines are replaced by running over a new On code section for the same exception-name. Exception handling is concluded by either: Running over the end statement and resume execution with the statement which follows immediately after the one which raised the exception. Executing a long-jump to anywhere. Continuing in the code-scope of/after the exception handler was not considered Uwe R. Zimmer, The Australian National University page 530 of 962 (chapter 5: up to page 620) 532 in general program flows Exception forms raised: from: Run-time environment Application Synchronously Asynchronously 2015 Uwe R. Zimmer, The Australian National University page 532 of 962 (chapter 5: up to page 620) 531 in general program flows Exceptions (Early high level constructs in not-fully-scoped languages) PL/I (IBM, 1960 s): Exception handling routines are registered globally by running over an On code section: On <exception-name> ; ( statements ) [<long jump to continuation code>] end; Exception handling routines are replaced by running over a new On code section for the same exception-name. Exception handling is concluded by either: Running over the end statement and resume execution with the statement which follows immediately after the one which raised the exception. Executing a long-jump to anywhere. Continuing in the code-scope of/after the exception handler was not considered Uwe R. Zimmer, The Australian National University page 531 of 962 (chapter 5: up to page 620) 533 in general program flows Exception forms Ada raised: from: Run-time environment Application Synchronously Exceptions Asynchronously Interrupt handler Asynchronous transfer of control 2015 Uwe R. Zimmer, The Australian National University page 533 of 962 (chapter 5: up to page 620). Exception handling is messy/hard/impossible in: Weakly/not scoped languages Macro-assembler level languages Strict functional languages

16 534 in general program flows Exception forms Real-time Java raised: from: Run-time environment Application Synchronously Exceptions Asynchronously Asynchronous exceptions 2015 Uwe R. Zimmer, The Australian National University page 534 of 962 (chapter 5: up to page 620) 536 in general program flows Exception granularity (block level) Ada: -- do something dangerous exception when E: Constraint_Error => Deal with it; Handle a specific exception at the end of a defined code block end; or in Real-time Java try { // do something dangerous catch (ExceptionType e) { // handle exception e 2015 Uwe R. Zimmer, The Australian National University page 536 of 962 (chapter 5: up to page 620) 535 in general program flows Exception forms POSIX raised: from: Run-time environment Application Synchronously N/A () Asynchronously (Signals) 2015 Uwe R. Zimmer, The Australian National University page 535 of 962 (chapter 5: up to page 620) 537 in general program flows Exception granularity (block level) Ada: -- do something dangerous exception when E: others => Deal with it; Handle any exception at the end of a defined code block end; Can be combined: handle some specific exceptions first yet also provide code for other exceptions. or in Real-time Java try { // do something dangerous catch (Exception e) { // handle exception e 2015 Uwe R. Zimmer, The Australian National University page 537 of 962 (chapter 5: up to page 620)

17 538 in general program flows Exception granularity (block size large) declare subtype Temperature is Integer range ; subtype Pressure is Integer range ; subtype Flow is Integer range ; -- read temperature sensor and calculate its value -- read pressure sensor and calculate its value -- read flow sensor and calculate its value -- adjust temperature, pressure and flow -- according to requirements exception -- handler for Constraint_Error end; Might be too unspecific? 2015 Uwe R. Zimmer, The Australian National University page 538 of 962 (chapter 5: up to page 620) 540 in general program flows Exception granularity (statement level) e.g. supported in CHILL All exceptions in CHILL need to be handled A : temperature; B, C : integer; A := B + C on Exceptions are not propagated end; (overflow ): ; (rangefail): ; else ; end; Handlers are determined at compile time 2015 Uwe R. Zimmer, The Australian National University page 540 of 962 (chapter 5: up to page 620) 539 in general program flows Exception granularity (block size small) -- read temperature sensor and calculate its value exception -- handler for Constraint_Error end; -- read pressure sensor and calculate its value exception -- handler for Constraint_Error end; Might become too cluttered? exception -- handler for Constraint_Error end; 2015 Uwe R. Zimmer, The Australian National University page 539 of 962 (chapter 5: up to page 620) 541 in general program flows Exception attributes Instead of catching exceptions after each statement: Exceptions can carry further attributes about their source. Thus exception handlers can be further away from the source (and fewer in numbers) yet still be able to identify the fault. Real-time Java: Exception can carry any number of user defined parameters. Ada: The environment automatically attaches additional information to exceptions, which are indicating the position of the exception-occurrence and other observed conditions (implementation dependent, inflexible, useful for debugging) Uwe R. Zimmer, The Australian National University page 541 of 962 (chapter 5: up to page 620)

18 542 in general program flows Exception scope and propagation 1. All procedures and functions declare every potentially raised exception (requested in CHILL, requested in Real-time Java for user defined exceptions) If an appropriate exception handler can not be determined at compile-time: Either treat it as a programmer error and stop compilation ( CHILL) or propagate the exception at run-time outside its static scope ( Real-time Java) 2. Exceptions are declared for whole modules not specifically per method (Ada): The handler is determined at run-time in any case (either by propagation or in the static scope) Uwe R. Zimmer, The Australian National University page 542 of 962 (chapter 5: up to page 620) 544 in general program flows Exception recovery Resumption-model (offered in: Pearl, Mesa): 1. Find an exception handler. 2. Execute the exception handler (and potentially raise another exception). 3. After completion of the exception handler (and possibly other handlers): return to the invoker and try resume processing as if nothing happened. Feature: In case of an asynchronous exception, there is little impact on the current control flow. Problems: Some errors cannot be repaired (especially all timing related errors) infinite recursion. Exceptions can be raised in the middle of evaluations, which will be hard to restore Uwe R. Zimmer, The Australian National University page 544 of 962 (chapter 5: up to page 620) 543 in general program flows (Uncaught) exception propagation If the handler can neither be found by propagation nor in the static context of a task: or Stop the specific task exceptions are not propagated to the parent-process (Ada). Propagate the exception to the parent-task (and potentially stall the whole system). Common safety-line for each process: Use a catch all -handler (possible in Ada and Real-time Java) at the highest task level. common reaction: PANIC! 2015 Uwe R. Zimmer, The Australian National University page 543 of 962 (chapter 5: up to page 620) 545 in general program flows Exception recovery Block-Resumption-model (offered in: Eiffel): 1. Find an exception handler. 2. Execute the exception handler (and potentially raise another exception). 3. After completion of the exception handler (and possibly other handlers): return to the ning of the code block in which the exception occurred. Feature: Contracts are enforced. Problems: must not be re-initialized (potentially confusing state of the system). The code needs to be aware of all combinations of half-evaluated processing states. Trying the same method again (and again) is usually not a suitable way for real-time systems Uwe R. Zimmer, The Australian National University page 545 of 962 (chapter 5: up to page 620)

19 546 in general program flows Exception recovery Termination-model (only model in: Ada, Real-time Java; offered in: Pearl, Mesa): 1. Find an exception handler. 2. Execute the exception handler (and potentially raise another exception). 3. After completion of the exception handler (and possibly other handlers): return to the scope around the final exception handler. Feature: The method of choice, if exceptions imply that the operation was not successful and something else need to be done now real-time systems. Problems: There is no way to continue execution as if nothing happened (might be useful in case that the exception could be identified as of minor impact) Uwe R. Zimmer, The Australian National University page 546 of 962 (chapter 5: up to page 620) 548 in general program flows Multi-stage exception handling Assuming a block is holding a number of local resources, yet occurring exceptions need to be handled at the caller level: procedure Allocate (Number : Devices) is -- request each device be allocated in turn -- noting which requests are granted exception when others => -- e.g. deallocate those devices allocated raise; -- re-raise the exception end Allocate; Helpful to keep a consistent system-state and to avoid dead-locks (all-or-nothing allocation). in Real-time Java: the finally clause takes care of block consistent finalization Uwe R. Zimmer, The Australian National University page 548 of 962 (chapter 5: up to page 620) 547 in general program flows Exception recovery Hybrid-model (offered in: Mesa): 1. Find an exception handler. 2. Execute the exception handler (and potentially raise another exception). 3. After completion of the exception handler (and possibly other handlers): the exception handler can decide whether to terminate or to resume Uwe R. Zimmer, The Australian National University page 547 of 962 (chapter 5: up to page 620) 549 in general program flows Exception handling issues (Ada & Real-time Java) (Ada) Exceptions are declared at package level, i.e. it is unclear, which functions may raise which exceptions! (Ada) Exceptions may be propagated outside the scope of their declaration, i.e. only when others can handle them. (Ada, Real-time Java) Exception in task bodies are not propagated to the parent task i.e. if there could not be any handler identified in the task, the task will die silently. (Ada, Real-time Java) Exception in task declarations are always propagated to the parent task. (Ada) Exceptions in task rendezvous, which are not handled in the accept statement, are propagated to both involved tasks. Most expensive uncaught exception up to now: Half a billion dollars (maiden crash of Ariane 5, 96) 2015 Uwe R. Zimmer, The Australian National University page 549 of 962 (chapter 5: up to page 620)

20 550 in general program flows Exception handling in Real-time Java Errors ThreadDeath AssertionError VirtualMachineError Unchecked Checked to be declared per method LinkageError Throwable RunTimeException Exception User defined User defined User defined InterruptedException User defined Asynchronously- InterruptedException User defined User defined 2015 Uwe R. Zimmer, The Australian National University page 550 of 962 (chapter 5: up to page 620) 552 in general program flows Exception handling in C / POSIX There is none Possible workarounds by using POSIX long jumps or signals. see also macro-assembler or old language exception handling methods Uwe R. Zimmer, The Australian National University page 552 of 962 (chapter 5: up to page 620) 551 in general program flows Exception handling in Real-time Java Exceptions are objects in Real-time Java (Exceptions have a hierarchical relation). Exceptions handlers can catch: One individual exception. Exceptions out of a finite list of exceptions. Exceptions of a class (missing in Ada). All exceptions. The kinds of exceptions which are to be handled can be denoted precisely, completely and safely Uwe R. Zimmer, The Australian National University page 551 of 962 (chapter 5: up to page 620) 553 in general program flows Exception handling overview Real-Time Java Termination Recovery Handler Declared per: Declare as: Scope Ada Termination Dynamical / Propagating Dynamical / Propagating CHILL Termination Static Via handler Mesa Pearl Resumption or termination Resumption or termination Eiffel Class retry Dynamical / Propagating Method Class Block Package Static name Block Procedure Static handler Static procedure Statement / Block / Task Block Static Process Static name Task Dynamical / Propagating C / POSIX None Contract violation Static name Contract

21 554 Atomic actions (Definitions) An action is atomic if the processes performing it are not aware of the existence of any other active process, and no other active process is aware of the activity of the processes during the time the processes are performing the action. do not communicate with other processes while the action is being performed. cannot detect any outside state change and do not reveal their own state changes until the action is complete. can be considered to be indivisible and instantaneous Uwe R. Zimmer, The Australian National University page 554 of 962 (chapter 5: up to page 620) 556 Atomic actions Atomic Actions Atomic Indivisible phases Flow of tasks Task 4 Task 3 Task 2 Task time Commitment times 2015 Uwe R. Zimmer, The Australian National University page 556 of 962 (chapter 5: up to page 620) 555 Atomic actions (Implications) An atomic action is either performed fully, or not at all. is declared as failed, if any part of the action fails. Thus all parts of an atomic action need to be prepared: to be interrupted (due to the failure of one of them). to reset to their initial state at any Uwe R. Zimmer, The Australian National University page 555 of 962 (chapter 5: up to page 620) 557 Nested atomic actions Action actions can be nested, iff all processes involved in the nested atomic actions are a true subset of the processes involved in the enclosing atomic action Uwe R. Zimmer, The Australian National University page 557 of 962 (chapter 5: up to page 620)

22 558 Nested atomic actions Nested Atomic Actions Atomic Task 4 Task 3 Task 2 Task time 2015 Uwe R. Zimmer, The Australian National University page 558 of 962 (chapter 5: up to page 620) 560 Atomic actions failure Failure in one of the tasks Cleaning up in all tasks Action declared failed Atomic Task 4 Task 3 Task 2 Task time 2015 Uwe R. Zimmer, The Australian National University page 560 of 962 (chapter 5: up to page 620) 559 Atomic actions (Requirements for real-time environments) Well-defined boundaries A start, end and a side boundary: Define clear entry and exit points for all processes involved in the atomic action. Processes can enter at different time, but need to be released at once. Separate the involved processes from the rest of the system ( side boundary ). Indivisibility (Isolation) Prohibit or restrict communications to outside processes and resources. Employing results from one atomic action in another one implies strict serialisation. Nesting Atomic actions may be nested, if they form a true enclosing relation. Concurrency Independent atomic actions may be executed in any order and concurrently Uwe R. Zimmer, The Australian National University page 559 of 962 (chapter 5: up to page 620) 561 Failure in outer atomic action. Preserve full atomicity. Atomic Atomic actions failure Failure in outer action Inner action ready to commit Action declared failed Task 4 Task 3 Task 2 Task time Outer action rolling back Inner action rolling back 2015 Uwe R. Zimmer, The Australian National University page 561 of 962 (chapter 5: up to page 620)

23 562 Atomic actions failure Failure in outer atomic action. Action declared failed Break atomicity and propagate failure immediately. Atomic Task 4 Task 3 Task 2 Task time Failure in outer action All parts rolling back 2015 Uwe R. Zimmer, The Australian National University page 562 of 962 (chapter 5: up to page 620) 564 Atomic actions Failure in inner atomic action. Break atomicity and propagate failure immediately. Atomic Task 4 Task 3 Task 2 Task time All parts rolling back immediately 2015 Uwe R. Zimmer, The Australian National University page 564 of 962 (chapter 5: up to page 620) 563 Atomic actions failure Failure in inner atomic action. Preserve full atomicity. Atomic Task 4 Task 3 Task 2 Task time Outer action only notified after inner action rolled back and committed to failure 2015 Uwe R. Zimmer, The Australian National University page 563 of 962 (chapter 5: up to page 620) 565 Atomic actions Construct does not exist in any mainstream language action A with (P2, P3, ) do -- communication is restricted to P2, P3, -- exceptions and timing constraints violations i are propagated -- to all involved processes exception when exception_a => -- recover locally when exception_b => -- recover locally when others => raise atomic_action_failure; -- and fail the action end A; 2015 Uwe R. Zimmer, The Australian National University page 565 of 962 (chapter 5: up to page 620)

24 566 Atomic actions implementations Implemented by dedicated tasks. Client task is blocked during the atomic action. Atomic Task 4 Task 3 Task 2 Task time 2015 Uwe R. Zimmer, The Australian National University page 566 of 962 (chapter 5: up to page 620) 568 Atomic actions in Ada (specification) type Action_Part_Time_Scope is record Start_Delay_Min : Time_Span := Time_Span_Zero; Start_Delay_Max : Time_Span := Time_Span_Last; Max_Elapse : Time_Span := Time_Span_Last; Deadline : Time := Time_Last; end record; type Action_Part_Proc is access procedure; type Action_Part_Procs is record Action, Cleanup : Action_Part_Proc; Scope : Action_Part_Time_Scope; end record; type Action_Parts is array (Positive range <>) of Action_Part_Procs; The Cleanup procedure is meant to restore the initial state! ( undoing all effects of Action) 2015 Uwe R. Zimmer, The Australian National University page 568 of 962 (chapter 5: up to page 620) 567 Atomic actions in Ada with Atomic_Action_Types; use Atomic_Action_Types; generic Actions : in Action_Parts; package Generic_Atomic_Action is procedure Perform; Failure_State, Time_Out_State, Late_Activation_State : exception; end Generic_Atomic_Action; Scope mechanism is employed to limit communication possibilities of atomic action parts. The perform-call is atomic for the caller and invisible for others. Failures in one part are automatically propagated in the whole atomic action Uwe R. Zimmer, The Australian National University page 567 of 962 (chapter 5: up to page 620) 569 Atomic actions in Ada (usage) Actions : Action_Parts (Tasks_Index) := (1 => (Action => Action_Task_1 Access, Cleanup => Cleanup_Task_1 Access, Scope => (Start_Delay_Min => Milliseconds (33), Start_Delay_Max => Milliseconds (133), Max_Elapse => Time_Span_Last, Deadline => Time_Last) ), 2 => package Atomic_Action is new Generic_Atomic_Action (Actions); procedure Perform is Atomic_Action.Perform; exception when end Perform; 2015 Uwe R. Zimmer, The Australian National University page 569 of 962 (chapter 5: up to page 620)

25 570 Atomic actions in Ada (implementation) task body Action_Task is Monitor.Check_In (Task_Id); Monitor.Failed (Task_Id); Actions (Task_Id).Cleanup.all; Atomic_Action.Monitor.Check_Out (Task_Id); delay To_Duration (Actions (Task_Id).Scope.Start_Delay_Max); raise Late_Activation_State; delay To_Duration (Actions (Task_Id).Scope.Start_Delay_Min); end ; 2015 Uwe R. Zimmer, The Australian National University page 570 of 962 (chapter 5: up to page 620) 572 Atomic actions in Ada (implementation) protected Monitor is entry Check_In (Task_Id : in Task_Ids); entry Fail (Condition : in Atomic_Condition); entry Failed (Task_Id : in Task_Ids); -- blocking until Fail is called entry Check_Out (Task_Id : in Task_Ids); -- blocking until all parts are completed or all are cleaned up entry Action_Result (Condition : out Atomic_Condition); private Check_List : Task_List := Check_List_Out; State : Atomic_State := Checking_In; Final_Condition : Atomic_Condition := Succeeded; end Monitor; Check the course page for the complete sources Uwe R. Zimmer, The Australian National University page 572 of 962 (chapter 5: up to page 620) 571 Atomic actions in Ada (implementation) delay until Real_Deadline; -- based on Max_Elapse & Deadline raise Time_Out_State; Actions (Task_Id).Action.all; end ; Atomic_Action.Monitor.Check_Out (Task_Id); exception when Time_Out_State => Monitor.Fail (Time_Out); when Late_Activation_State => Monitor.Fail (Late_Activation); when others => Monitor.Fail (Other_Exception); end; end ; end Action_Task; 2015 Uwe R. Zimmer, The Australian National University page 571 of 962 (chapter 5: up to page 620) 573 Atomic actions implementations Implemented allows for tasks to dedicate themselves. Nested actions are possible, client task not blocked. Atomic Task 4 Task 3 Task 2 Task time Laboratories Uwe R. Zimmer, The Australian National University page 573 of 962 (chapter 5: up to page 620)

26 574 Atomic actions failure recovery Backward error recovery in real-time environments Since once some parts of the action might have failed: Some action-parts might re-execute the same method again, Or execute alternative methods, even if the original method was locally valid. In real-time environments, failed atomic actions often imply irreversible failures: Tracking back and re-trying the same atomic action with modified parameters or methods is rarely useful, considering timing constraints. Backtracking is often physically impossible Uwe R. Zimmer, The Australian National University page 574 of 962 (chapter 5: up to page 620) 576 Asynchronous events and transfer of control Interrupts vs. From interrupts (sub-process level) employed in: communication with slow / asynchronous / sporadic devices. sampling / control loops. closely coupled reflective systems. To asynchronous transfer of control (process level) used in: Error recovery supporting atomic actions and forward recovery. Mode changes sudden changes from normal operations to emergency measures. Partial / imprecise computations whenever timeliness is more important than precision. Operator intervention User triggered mode changes Uwe R. Zimmer, The Australian National University page 576 of 962 (chapter 5: up to page 620) 575 Atomic actions failure recovery Forward error recovery in real-time environments A mode change and a different set of (atomic) actions (and goals!) will be more useful in many cases. Forward error recovery is more common in real-time systems. (more on forward error recovery in chapter 9 ) 2015 Uwe R. Zimmer, The Australian National University page 575 of 962 (chapter 5: up to page 620) 577 Asynchronous events and transfer of control Real-time Java Supplies three basic features: 1. Binding of handlers to internal and external asynchronous events. 1a. Specifying asynchronous events 1b. Specifying adequate handlers 2. Asynchronous transfer of control. 3. Asynchronous termination of threads Uwe R. Zimmer, The Australian National University page 577 of 962 (chapter 5: up to page 620)

27 578 Asynchronous events Real-time Java: Asynchronous events Whenever an instance of AsyncEvent occurs: all.run() methods of all instances of AsyncEventHandler, which are bound to this AsyncEvent are scheduled for execution. Multiple AsyncEvents may have different impacts on the scheduling. An event counter (FireCount) is supplied. AsyncEvents and AsyncEventHandlers may be created and used by any program logic. More than one handler can be attached to one event. More than one event can be attached to one handler. Flexible, but handled as a schedulable object 2015 Uwe R. Zimmer, The Australian National University page 578 of 962 (chapter 5: up to page 620) 580 Asynchronous events Real-time Java: Asynchronous events public abstract class AsyncEventHandler implements Schedulable { public AsyncEventHandler (Scheduling scheduling, Release release, Memory memory, MemoryArea area, ProcessingGroup group); public void addtofeasibility (); public void removefromfeasibility (); protected int getandclearpendingfirecount (); public abstract void handleasyncevent (); // called by run while FireCount /= 0 public final void run (); 2015 Uwe R. Zimmer, The Australian National University page 580 of 962 (chapter 5: up to page 620) 579 Asynchronous events Real-time Java: Asynchronous events public class AsyncEvent { public AsyncEvent (); public synchronized void addhandler (AsyncEventHandler handler); public synchronized void removehandler (AsyncEventHandler handler); public void sethandler (AsyncEventHandler handler); public void bindto (java.lang.string happening); public Release createrelease (); public void fire (); 2015 Uwe R. Zimmer, The Australian National University page 579 of 962 (chapter 5: up to page 620) 581 Asynchronous events Real-time Java: Asynchronous events public class BoundAsyncEventHandler extends AsyncEventHandler { public BoundAsyncEventHandler (); // inherit modes from the current thread public BoundAsyncEventHandler (Scheduling scheduling, Release release, Memory memory, MemoryArea area, ProcessingGroup group, boolean nonheap, java.lang.runnable logic); bind the current thread to an AsyncEventHandler (otherwise the AsyncEventHandler will execute in a thread of its own) Uwe R. Zimmer, The Australian National University page 581 of 962 (chapter 5: up to page 620)

28 582 Asynchronous events Java: Interrupting exception While an AsyncEvent just schedules a handler for execution, other event classes are needed to alter the control flow more directly: Standard Java: The InterruptedException indicates the wish to interrupt a thread, which itself need to poll the isinterrupted method to find out, whether it is supposed to be interrupted. If the thread is currently executing and ignoring the flag: No effect on the actual controlflow! If the thread, which is to be interrupted is currently blocking: It is activated and receives an InterruptedException. Too weak to be employed in an asynchronous transfer of control! 2015 Uwe R. Zimmer, The Australian National University page 582 of 962 (chapter 5: up to page 620) 584 Asynchronous events Real-time Java: Asynchronously interrupting exception Cases of operations if a AsynchronouslyInterruptedException (AIE) occurs: 1. If control is in a synchronized section (within an interruptible section): AIE is put into a pending state. 2. If control is in an interruptible section: Control is transferred to the nearest dynamically enclosing catch clause, which is in a non-interruptible section. 3. If control is in wait, sleep, or join: Thread is activated and 1. or 2. is followed. 4. If control is in a non-interruptible section: Nothing happens until an interruptible section is reached. 5. If an interruptible section is reached while propagating an exception: Original exception is discarded (!) and replaced by the AIE Uwe R. Zimmer, The Australian National University page 584 of 962 (chapter 5: up to page 620) 583 Asynchronous events Real-time Java: Asynchronously interrupting exception While an AsyncEvent just schedules a handler for execution, other event classes are needed to alter the control flow more directly: Real-time Java: the AsynchronouslyInterruptedException might intercept a control flow directly, while: The code regions, which are interruptible need to be indicated. Synchronized blocks, task creations and finalizations are not interruptible. The response time of a thread must be within a bounded number of bytecodes (which itself need to be documented). If the interruptible thread is currently blocked (in a java.io.* operation) then the thread is either released or kept in the block (definition of a reasonable blocking time or situation is implementation dependent) Uwe R. Zimmer, The Australian National University page 583 of 962 (chapter 5: up to page 620) 585 Asynchronous events Real-time Java: Asynchronously interrupting exception Need to be part of a RealtimeThread public class AsynchronouslyInterruptedException extends java.lang.interruptedexception { public synchronized void disable(); public synchronized boolean enable(); public synchronized boolean fire(); Will propagate any other exception immediately public boolean dointerruptible (Interruptible logic); public boolean happened (boolean propagate); public static AsynchronouslyInterruptedException n getgeneric(); // returns the AsynchronouslyInterruptedException ption which // is generated when RealtimeThread.interrupt t () is invoked public void propagate(); 2015 Uwe R. Zimmer, The Australian National University page 585 of 962 (chapter 5: up to page 620)

29 586 Asynchronous events Real-time Java: Asynchronously interrupting exception import NonInterruptibleServices.*; public class InterruptibleService Interruptible code section { public AIE stopnow = AIE.getGeneric(); public boolean Service() throws AIE { try { // code interdispersed with calls to NonInterruptibleServices catch AIE AI { if (stopnow.happened (true)) { // handle the ATC Handle the stopnow propagate anything else 2015 Uwe R. Zimmer, The Australian National University page 586 of 962 (chapter 5: up to page 620) 588 Asynchronous events Real-time Java: Asynchronously interrupting exception While asynchronously interrupting event handling is part of the standard exception handling mechanism, there are nevertheless differences in exception propagation: A standard exception is not propagated by default when caught by any catch statement (an explicit re-raising of the exception is necessary to pass it on). A AsynchronouslyInterruptedException is propagated by default, even if caught (an explicit propagation stop is necessary to avoid its further propagation). realized in the AIE.happened method Rationale: Local catch-all clauses might not be aware of a potential asynchronous interrupting exception. Practical compromise, but destroying some integrity of the Java-exception concept Uwe R. Zimmer, The Australian National University page 588 of 962 (chapter 5: up to page 620) 587 Asynchronous events Real-time Java: Asynchronously interrupting exception import NonInterruptibleServices.*; public class InterruptibleService Interruptible code section { public AIE stopnow = AIE.getGeneric(); public boolean Service() throws AIE { try { // code interdispersed with calls to NonInterruptibleServices catch AIE AI { if (stopnow.happened (false)) { // handle the ATC else { // cleanup AI.propagate Handle the stopnow otherwise: clean up and propagate anything else 2015 Uwe R. Zimmer, The Australian National University page 587 of 962 (chapter 5: up to page 620) 589 Asynchronous events Real-time Java: Interruptible interface public interface Interruptible { public void interruptaction (AsynchronouslyInterruptedException exception); public void run (AsynchronouslyInterruptedException exception) throws AsynchronouslyInterruptedException; An object may declare an interruptible method explicitly by implementing the above interface. Sole purpose: pass this implementation to a dointerruptible method of a AIE class. The AIE.doInterruptible can only be called by one thread at a time! 2015 Uwe R. Zimmer, The Australian National University page 589 of 962 (chapter 5: up to page 620)

30 590 Asynchronous events Real-time Java: Timeout on actions public class Timed extends AsynchronouslyInterruptedException implements java.io.serializable { public Timed (HighResolutionTime time) throws IllegalArgumentException; public boolean dointerruptible (Interruptible logic); public void resettime (HighResolutionTime time); The timer is started sometime between the invocation of the dointerruptible itself and the.run method of the interruptible interface. A generic interrupt() is thrown at the expiration of the timer. time can be absolute or relative Uwe R. Zimmer, The Australian National University page 590 of 962 (chapter 5: up to page 620) 592 Interrupts Ada: Interrupt handlers package Ada.Interrupts is type Interrupt_ID is implementation-defined; type Parameterless_Handler is access protected procedure; function Is_Reserved (Interrupt : Interrupt_ID) return Boolean; function Is_Attached (Interrupt : Interrupt_ID) return Boolean; function Current_Handler (Interrupt : Interrupt_ID) return Parameterless_Handler; procedure Attach_Handler (New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID); procedure Exchange_Handler (Old_Handler : out Parameterless_Handler; New_Handler : in Parameterless_Handler; Interrupt : in Interrupt_ID); procedure Detach_Handler (Interrupt : in Interrupt_ID); function Reference (Interrupt : Interrupt_ID) return System.Address; end Ada.Interrupts; 2015 Uwe R. Zimmer, The Australian National University page 592 of 962 (chapter 5: up to page 620) 591 Forms of asynchronism Ada Provides: Exception handling (synchronous only). Asynchronous transfer of control. Task aborts. Interrupt handling (close to hardware). Set of different methods to handle different kinds of events! 2015 Uwe R. Zimmer, The Australian National University page 591 of 962 (chapter 5: up to page 620) 593 Interrupts Ada: Interrupt handlers package Ada.Interrupts is type Interrupt_ID is implementation-defined; type Parameterless_Handler is access protected procedure; function Is_Reserved (Interrupt rupt : Interrupt_ID) return Boolean; function Is_Attached (Interrupt rupt : Interrupt_ID) ID) return Boolean; function Current_Handler (Interrupt : Interrupt_ID) return Parameterless_Handler; procedure Attach_Handler (New_Handler er : in Parameterless_Handler; Interrupt : in Interrupt_ID); procedure Exchange_Handler (Old_Handler : out Parameterless_Handler; rless_handler; New_Handler er : in Parameterless_Handler; Protected procedures need to qualify as an interrupt handler: use pragma Interrupt_Handler let the compiler evaluate the suitability. Interrupt : in Interrupt_ID); procedure Detach_Handler (Interrupt : in Interrupt_ID); function Reference (Interrupt : Interrupt_ID) return System.Address; end Ada.Interrupts; 2015 Uwe R. Zimmer, The Australian National University page 593 of 962 (chapter 5: up to page 620)

Real-Time Software. Exceptions and Low-level Programming. René Rydhof Hansen. 2 November 2010

Real-Time Software. Exceptions and Low-level Programming. René Rydhof Hansen. 2 November 2010 Real-Time Software Exceptions and Low-level Programming René Rydhof Hansen 2 November 2010 TSW (2010e) (Lecture 13) Real-Time Software 2 November 2010 1 / 35 Today s Goals Exceptions and Exception Handling

More information

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture Last 2 Classes: Introduction to Operating Systems & C++ tutorial User apps OS Virtual machine interface hardware physical machine interface An operating system is the interface between the user and the

More information

Safety & Liveness Towards synchronization. Safety & Liveness. where X Q means that Q does always hold. Revisiting

Safety & Liveness Towards synchronization. Safety & Liveness. where X Q means that Q does always hold. Revisiting 459 Concurrent & Distributed 7 Systems 2017 Uwe R. Zimmer - The Australian National University 462 Repetition Correctness concepts in concurrent systems Liveness properties: ( P ( I )/ Processes ( I, S

More information

Concurrent & Distributed 7Systems Safety & Liveness. Uwe R. Zimmer - The Australian National University

Concurrent & Distributed 7Systems Safety & Liveness. Uwe R. Zimmer - The Australian National University Concurrent & Distributed 7Systems 2017 Safety & Liveness Uwe R. Zimmer - The Australian National University References for this chapter [ Ben2006 ] Ben-Ari, M Principles of Concurrent and Distributed Programming

More information

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst

Operating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Last Class: Intro to OS An operating system is the interface between the user and the architecture. User-level Applications

More information

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?)

Process Context & Interrupts. New process can mess up information in old process. (i.e. what if they both use the same register?) 1 Process Context 1.1 What is context? A process is sometimes called a task, subroutine or program. Process context is all the information that the process needs to keep track of its state. Registers Temporary

More information

Shell Execution of Programs. Process Groups, Session and Signals 1

Shell Execution of Programs. Process Groups, Session and Signals 1 Shell Execution of Programs Process Groups, Session and Signals 1 Signal Concepts Signals are a way for a process to be notified of asynchronous events (software interrupts). Some examples: a timer you

More information

Lecture 11: Interrupt and Exception. James C. Hoe Department of ECE Carnegie Mellon University

Lecture 11: Interrupt and Exception. James C. Hoe Department of ECE Carnegie Mellon University 18 447 Lecture 11: Interrupt and Exception James C. Hoe Department of ECE Carnegie Mellon University 18 447 S18 L11 S1, James C. Hoe, CMU/ECE/CALCM, 2018 Your goal today Housekeeping first peek outside

More information

Overview. Administrative. * HW 1 grades. * HW 2 Due. Topics. * 5.1 What is a Signal? * Dealing with Signals - masks, handlers

Overview. Administrative. * HW 1 grades. * HW 2 Due. Topics. * 5.1 What is a Signal? * Dealing with Signals - masks, handlers Overview Administrative * HW 1 grades * HW 2 Due Topics * 5.1 What is a Signal? * 5.2-3 Dealing with Signals - masks, handlers * 5.4 Synchronization: pause(), sigsuspend() * 5.6 Interaction with other

More information

real-time kernel documentation

real-time kernel documentation version 1.1 real-time kernel documentation Introduction This document explains the inner workings of the Helium real-time kernel. It is not meant to be a user s guide. Instead, this document explains overall

More information

Real-Time Programming

Real-Time Programming Real-Time Programming Week 7: Real-Time Operating Systems Instructors Tony Montiel & Ken Arnold rtp@hte.com 4/1/2003 Co Montiel 1 Objectives o Introduction to RTOS o Event Driven Systems o Synchronization

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 153 Design of Operating Systems Winter 19 Lecture 3: OS model and Architectural Support Last time/today Historic evolution of Operating Systems (and computing!) Today: We start our journey in exploring

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Resource management. Real-Time Systems. Resource management. Resource management

Resource management. Real-Time Systems. Resource management. Resource management Real-Time Systems Specification Implementation Verification Mutual exclusion is a general problem that exists at several levels in a real-time system. Shared resources internal to the the run-time system:

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Control Abstraction. Hwansoo Han

Control Abstraction. Hwansoo Han Control Abstraction Hwansoo Han Review of Static Allocation Static allocation strategies Code Global variables Own variables (live within an encapsulation - static in C) Explicit constants (including strings,

More information

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss Grundlagen Microcontroller Interrupts Günther Gridling Bettina Weiss 1 Interrupts Lecture Overview Definition Sources ISR Priorities & Nesting 2 Definition Interrupt: reaction to (asynchronous) external

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

The Real-time Specification for Java

The Real-time Specification for Java The Real-time Specification for Java Roadmap Overview of the RTSJ Memory Management Clocks and Time Scheduling and Schedulable Objects Asynchronous Events and Handlers Real-Time Threads Asynchronous Transfer

More information

Research on the Novel and Efficient Mechanism of Exception Handling Techniques for Java. Xiaoqing Lv 1 1 huihua College Of Hebei Normal University,

Research on the Novel and Efficient Mechanism of Exception Handling Techniques for Java. Xiaoqing Lv 1 1 huihua College Of Hebei Normal University, International Conference on Informatization in Education, Management and Business (IEMB 2015) Research on the Novel and Efficient Mechanism of Exception Handling Techniques for Java Xiaoqing Lv 1 1 huihua

More information

CSE 153 Design of Operating Systems Fall 18

CSE 153 Design of Operating Systems Fall 18 CSE 153 Design of Operating Systems Fall 18 Lecture 2: OS model and Architectural Support Last time/today l Historic evolution of Operating Systems (and computing!) l Today: We start our journey in exploring

More information

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an

More information

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved.

Processes Prof. James L. Frankel Harvard University. Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Processes Prof. James L. Frankel Harvard University Version of 6:16 PM 10-Feb-2017 Copyright 2017, 2015 James L. Frankel. All rights reserved. Process Model Each process consists of a sequential program

More information

Processes. Johan Montelius KTH

Processes. Johan Montelius KTH Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other

More information

Deviations are things that modify a thread s normal flow of control. Unix has long had signals, and these must be dealt with in multithreaded

Deviations are things that modify a thread s normal flow of control. Unix has long had signals, and these must be dealt with in multithreaded Deviations are things that modify a thread s normal flow of control. Unix has long had signals, and these must be dealt with in multithreaded improvements to Unix. There are actually two fairly different

More information

Unix System Programming - Chapter 8

Unix System Programming - Chapter 8 Unix System Programming - Chapter 8 Neal Nelson The Evergreen State College Apr 2010 USP Chapter 8 - Signals Section 8.1 - Basic Signal Concepts Section 8.2 - Generating Signals Section 8.3 - Signal Masks

More information

In examining performance Interested in several things Exact times if computable Bounded times if exact not computable Can be measured

In examining performance Interested in several things Exact times if computable Bounded times if exact not computable Can be measured System Performance Analysis Introduction Performance Means many things to many people Important in any design Critical in real time systems 1 ns can mean the difference between system Doing job expected

More information

Unit 2 : Computer and Operating System Structure

Unit 2 : Computer and Operating System Structure Unit 2 : Computer and Operating System Structure Lesson 1 : Interrupts and I/O Structure 1.1. Learning Objectives On completion of this lesson you will know : what interrupt is the causes of occurring

More information

A process. the stack

A process. the stack A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes

More information

CS 3 Introduction to Software Engineering. 3: Exceptions

CS 3 Introduction to Software Engineering. 3: Exceptions CS 3 Introduction to Software Engineering 3: Exceptions Questions? 2 Objectives Last Time: Procedural Abstraction This Time: Procedural Abstraction II Focus on Exceptions. Starting Next Time: Data Abstraction

More information

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh and a Fabulous Course Staff

More information

Lecture 2: Architectural Support for OSes

Lecture 2: Architectural Support for OSes Lecture 2: Architectural Support for OSes CSE 120: Principles of Operating Systems Alex C. Snoeren HW 1 Due Tuesday 10/03 Why Architecture? Operating systems mediate between applications and the physical

More information

Q.1 Explain Computer s Basic Elements

Q.1 Explain Computer s Basic Elements Q.1 Explain Computer s Basic Elements Ans. At a top level, a computer consists of processor, memory, and I/O components, with one or more modules of each type. These components are interconnected in some

More information

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle Operating Systems Operating System Structure Lecture 2 Michael O Boyle 1 Overview Architecture impact User operating interaction User vs kernel Syscall Operating System structure Layers Examples 2 Lower-level

More information

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Lecture #4 Professor Jan Jonsson Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Specification Resource management Mutual exclusion

More information

Process Time. Steven M. Bellovin January 25,

Process Time. Steven M. Bellovin January 25, Multiprogramming Computers don t really run multiple programs simultaneously; it just appears that way Each process runs to completion, but intermixed with other processes Process 1 6 ticks Process 2 Process

More information

Chapter 12. CPU Structure and Function. Yonsei University

Chapter 12. CPU Structure and Function. Yonsei University Chapter 12 CPU Structure and Function Contents Processor organization Register organization Instruction cycle Instruction pipelining The Pentium processor The PowerPC processor 12-2 CPU Structures Processor

More information

Asynchronism. Interrupt Enable R/W Number of Conversions Sequencer INT7 Don t INT5 INT4 INT3 INT2 INT1 INT0

Asynchronism. Interrupt Enable R/W Number of Conversions Sequencer INT7 Don t INT5 INT4 INT3 INT2 INT1 INT0 474 Real-Time & Embedded 5 Systems 25 Uwe R. Zimmer - The Australian National University 478 close to hardware Interrupt control at the dividual device level at the system terrupt controller level at the

More information

Hardware OS & OS- Application interface

Hardware OS & OS- Application interface CS 4410 Operating Systems Hardware OS & OS- Application interface Summer 2013 Cornell University 1 Today How my device becomes useful for the user? HW-OS interface Device controller Device driver Interrupts

More information

Green Hills Software, Inc.

Green Hills Software, Inc. Green Hills Software, Inc. A Safe Tasking Approach to Ada95 Jim Gleason Engineering Manager Ada Products 5.0-1 Overview Multiple approaches to safe tasking with Ada95 No Tasking - SPARK Ada95 Restricted

More information

CS 5460/6460 Operating Systems

CS 5460/6460 Operating Systems CS 5460/6460 Operating Systems Fall 2009 Instructor: Matthew Flatt Lecturer: Kevin Tew TAs: Bigyan Mukherjee, Amrish Kapoor 1 Join the Mailing List! Reminders Make sure you can log into the CADE machines

More information

Newbie s Guide to AVR Interrupts

Newbie s Guide to AVR Interrupts Newbie s Guide to AVR Interrupts Dean Camera March 15, 2015 ********** Text Dean Camera, 2013. All rights reserved. This document may be freely distributed without payment to the author, provided that

More information

Silberschatz and Galvin Chapter 12

Silberschatz and Galvin Chapter 12 Silberschatz and Galvin Chapter 12 I/O Systems CPSC 410--Richard Furuta 3/19/99 1 Topic overview I/O Hardware Application I/O Interface Kernel I/O Subsystem Transforming I/O requests to hardware operations

More information

The Procedure Abstraction

The Procedure Abstraction The Procedure Abstraction Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures

More information

This section covers the MIPS instruction set.

This section covers the MIPS instruction set. This section covers the MIPS instruction set. 1 + I am going to break down the instructions into two types. + a machine instruction which is directly defined in the MIPS architecture and has a one to one

More information

CSE 153 Design of Operating Systems Fall 2018

CSE 153 Design of Operating Systems Fall 2018 CSE 153 Design of Operating Systems Fall 2018 Lecture 5: Threads/Synchronization Implementing threads l Kernel Level Threads l u u All thread operations are implemented in the kernel The OS schedules all

More information

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks

CS 537 Lecture 2 Computer Architecture and Operating Systems. OS Tasks CS 537 Lecture 2 Computer Architecture and Operating Systems Michael Swift OS Tasks What is the role of the OS regarding hardware? What does the OS need from hardware to perform this role? 1 Computer Hardware

More information

Embedded Systems Programming

Embedded Systems Programming Embedded Systems Programming Overrun Management (Module 23) Yann-Hang Lee Arizona State University yhlee@asu.edu (480) 727-7507 Summer 2014 Imprecise computation Overrun Management trades off precision

More information

The control of I/O devices is a major concern for OS designers

The control of I/O devices is a major concern for OS designers Lecture Overview I/O devices I/O hardware Interrupts Direct memory access Device dimensions Device drivers Kernel I/O subsystem Operating Systems - June 26, 2001 I/O Device Issues The control of I/O devices

More information

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009 CSC 4103 - Operating Systems Fall 2009 Lecture - III Processes Tevfik Ko!ar Louisiana State University September 1 st, 2009 1 Roadmap Processes Basic Concepts Process Creation Process Termination Context

More information

COP4020 Programming Languages. Exception Handling Prof. Robert van Engelen

COP4020 Programming Languages. Exception Handling Prof. Robert van Engelen COP4020 Programming Languages Exception Handling Prof. Robert van Engelen Overview What is defensive programming? Ways to catch and handle run-time errors: In programming languages that do not support

More information

Embedded Software Programming

Embedded Software Programming Embedded Software Programming Computer Science & Engineering Department Arizona State University Tempe, AZ 85287 Dr. Yann-Hang Lee yhlee@asu.edu (480) 727-7507 Event and Time-Driven Threads taskspawn (name,

More information

INTERRUPTS in microprocessor systems

INTERRUPTS in microprocessor systems INTERRUPTS in microprocessor systems Microcontroller Power Supply clock fx (Central Proccesor Unit) CPU Reset Hardware Interrupts system IRQ Internal address bus Internal data bus Internal control bus

More information

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated? Processes Process Management Chapter 3 1 A process is a program in a state of execution (created but not terminated) Program is a passive entity one on your disk (survivor.class, kelly.out, ) Process is

More information

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory Embedded Systems 5. Operating Systems Lothar Thiele Computer Engineering and Networks Laboratory Embedded Operating Systems 5 2 Embedded Operating System (OS) Why an operating system (OS) at all? Same

More information

A read or write being atomic means that its effect is as if it happens instantaneously.

A read or write being atomic means that its effect is as if it happens instantaneously. A read or write being atomic means that its effect is as if it happens instantaneously. Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There

More information

PROCESS STATES AND TRANSITIONS:

PROCESS STATES AND TRANSITIONS: The kernel contains a process table with an entry that describes the state of every active process in the system. The u area contains additional information that controls the operation of a process. The

More information

Xinu on the Transputer

Xinu on the Transputer Purdue University Purdue e-pubs Department of Computer Science Technical Reports Department of Computer Science 1990 Xinu on the Transputer Douglas E. Comer Purdue University, comer@cs.purdue.edu Victor

More information

Tasks. Task Implementation and management

Tasks. Task Implementation and management Tasks Task Implementation and management Tasks Vocab Absolute time - real world time Relative time - time referenced to some event Interval - any slice of time characterized by start & end times Duration

More information

Chapter 5 - Input / Output

Chapter 5 - Input / Output Chapter 5 - Input / Output Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 5 - Input / Output 1 / 90 1 Motivation 2 Principle of I/O Hardware I/O Devices Device Controllers Memory-Mapped

More information

System Call. Preview. System Call. System Call. System Call 9/7/2018

System Call. Preview. System Call. System Call. System Call 9/7/2018 Preview Operating System Structure Monolithic Layered System Microkernel Virtual Machine Process Management Process Models Process Creation Process Termination Process State Process Implementation Operating

More information

Digital System Design Using Verilog. - Processing Unit Design

Digital System Design Using Verilog. - Processing Unit Design Digital System Design Using Verilog - Processing Unit Design 1.1 CPU BASICS A typical CPU has three major components: (1) Register set, (2) Arithmetic logic unit (ALU), and (3) Control unit (CU) The register

More information

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack

Part 7. Stacks. Stack. Stack. Examples of Stacks. Stack Operation: Push. Piles of Data. The Stack Part 7 Stacks The Stack Piles of Data Stack Stack A stack is an abstract data structure that stores objects Based on the concept of a stack of items like a stack of dishes Data can only be added to or

More information

Exceptions and assertions

Exceptions and assertions Exceptions and assertions CSE 331 University of Washington Michael Ernst Failure causes Partial failure is inevitable Goal: prevent complete failure Structure your code to be reliable and understandable

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Dr. Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Spring 2016 Course Goals: Look under the hood Help you learn what happens under the hood of computer systems

More information

Project 2: Signals. Consult the submit server for deadline date and time

Project 2: Signals. Consult the submit server for deadline date and time Project 2: Signals Consult the submit server for deadline date and time You will implement the Signal() and Kill() system calls, preserving basic functions of pipe (to permit SIGPIPE) and fork (to permit

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Fall 2016 Lecture 2: Architectural Support for Operating Systems Geoffrey M. Voelker Administrivia Project 0 Due 10/4, done individually Homework #1 Due 10/6 Project

More information

Real-time Support in Operating Systems

Real-time Support in Operating Systems Real-time Support in Operating Systems Colin Perkins teaching/2003-2004/rtes4/lecture11.pdf Lecture Outline Overview of the rest of the module Real-time support in operating systems Overview of concepts

More information

Exception handling. Exceptions can be created by the hardware or by software: Examples. Printer out of paper End of page Divide by 0

Exception handling. Exceptions can be created by the hardware or by software: Examples. Printer out of paper End of page Divide by 0 Exception handling Events in a program sometimes occur at unpredictable times, I.e., apparently randomly. That is, the occurrence is an exception to the normal sequencing of events. Such events are called

More information

The Procedure Abstraction Part I Basics

The Procedure Abstraction Part I Basics The Procedure Abstraction Part I Basics Procedure Abstraction The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures Procedures

More information

ELEC 377 Operating Systems. Week 1 Class 2

ELEC 377 Operating Systems. Week 1 Class 2 Operating Systems Week 1 Class 2 Labs vs. Assignments The only work to turn in are the labs. In some of the handouts I refer to the labs as assignments. There are no assignments separate from the labs.

More information

CS 201. Exceptions and Processes. Gerson Robboy Portland State University

CS 201. Exceptions and Processes. Gerson Robboy Portland State University CS 201 Exceptions and Processes Gerson Robboy Portland State University Control Flow Computers Do One Thing From startup to shutdown, a CPU reads and executes (interprets) a sequence of instructions, one

More information

Concurrent and Real-Time Programming in Java

Concurrent and Real-Time Programming in Java 064202 Degree Examinations 2003 DEPARTMENT OF COMPUTER SCIENCE Concurrent and Real-Time Programming in Java Time allowed: One and one half (1.5) hours Candidates should answer not more than two questions.

More information

Operating System Architecture. CS3026 Operating Systems Lecture 03

Operating System Architecture. CS3026 Operating Systems Lecture 03 Operating System Architecture CS3026 Operating Systems Lecture 03 The Role of an Operating System Service provider Provide a set of services to system users Resource allocator Exploit the hardware resources

More information

The Procedure Abstraction Part I: Basics

The Procedure Abstraction Part I: Basics The Procedure Abstraction Part I: Basics Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

Lecture 2 Process Management

Lecture 2 Process Management Lecture 2 Process Management Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks The terms job and process may be interchangeable

More information

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Chapter 3: Processes. Operating System Concepts 8 th Edition, Chapter 3: Processes, Silberschatz, Galvin and Gagne 2009 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2 Silberschatz, Galvin and Gagne 2009

More information

Threads Chapter 5 1 Chapter 5

Threads Chapter 5 1 Chapter 5 Threads Chapter 5 1 Chapter 5 Process Characteristics Concept of Process has two facets. A Process is: A Unit of resource ownership: a virtual address space for the process image control of some resources

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Process Coordination and Shared Data

Process Coordination and Shared Data Process Coordination and Shared Data Lecture 19 In These Notes... Sharing data safely When multiple threads/processes interact in a system, new species of bugs arise 1. Compiler tries to save time by not

More information

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1 EEL 4744C: Microprocessor Applications Lecture 7 Part 1 Interrupt Dr. Tao Li 1 M&M: Chapter 8 Or Reading Assignment Software and Hardware Engineering (new version): Chapter 12 Dr. Tao Li 2 Interrupt An

More information

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1 Reading Assignment EEL 4744C: Microprocessor Applications Lecture 7 M&M: Chapter 8 Or Software and Hardware Engineering (new version): Chapter 12 Part 1 Interrupt Dr. Tao Li 1 Dr. Tao Li 2 Interrupt An

More information

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU BCA-3 rd Semester 030010304-Fundamentals Of Operating Systems Unit: 1 Introduction Short Answer Questions : 1. State two ways of process communication. 2. State any two uses of operating system according

More information

The Kernel Abstraction

The Kernel Abstraction The Kernel Abstraction Debugging as Engineering Much of your time in this course will be spent debugging In industry, 50% of software dev is debugging Even more for kernel development How do you reduce

More information

Chapter 7 Central Processor Unit (S08CPUV2)

Chapter 7 Central Processor Unit (S08CPUV2) Chapter 7 Central Processor Unit (S08CPUV2) 7.1 Introduction This section provides summary information about the registers, addressing modes, and instruction set of the CPU of the HCS08 Family. For a more

More information

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS

REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS Malaysian Journal of Computer Science, Vol. 9 No. 1, June 1996, pp. 12-17 REAL-TIME MULTITASKING KERNEL FOR IBM-BASED MICROCOMPUTERS Mohammed Samaka School of Computer Science Universiti Sains Malaysia

More information

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group

Operating Systems (2INC0) 2018/19. Introduction (01) Dr. Tanir Ozcelebi. Courtesy of Prof. Dr. Johan Lukkien. System Architecture and Networking Group Operating Systems (2INC0) 20/19 Introduction (01) Dr. Courtesy of Prof. Dr. Johan Lukkien System Architecture and Networking Group Course Overview Introduction to operating systems Processes, threads and

More information

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions: Techno India Batanagar Department of Computer Science & Engineering Model Questions Subject Name: Operating System Multiple Choice Questions: Subject Code: CS603 1) Shell is the exclusive feature of a)

More information

Parallel Programming Languages COMP360

Parallel Programming Languages COMP360 Parallel Programming Languages COMP360 The way the processor industry is going, is to add more and more cores, but nobody knows how to program those things. I mean, two, yeah; four, not really; eight,

More information

POLITECNICO DI MILANO. Exception handling. Donatella Sciuto:

POLITECNICO DI MILANO. Exception handling. Donatella Sciuto: POLITECNICO DI MILANO Exception handling Donatella Sciuto: donatella.sciuto@polimi.it Interrupts: altering the normal flow of control I i-1 HI 1 program I i HI 2 interrupt handler I i+1 HI n An external

More information

Real-Time Systems and Programming Languages

Real-Time Systems and Programming Languages Real-Time Systems and Programming Languages Ada, Real-Time Java and C/Real-Time POSIX Fourth Edition Alan Burns and Andy Wellings University of York * ADDISON-WESLEY An imprint of Pearson Education Harlow,

More information

Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such

Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such Signals are a kernel-supported mechanism for reporting events to user code and forcing a response to them. There are actually two sorts of such events, to which we sometimes refer as exceptions and interrupts.

More information

What are Exceptions? EE 457 Unit 8. Exception Processing. Exception Examples 1. Exceptions What Happens When Things Go Wrong

What are Exceptions? EE 457 Unit 8. Exception Processing. Exception Examples 1. Exceptions What Happens When Things Go Wrong 8. 8.2 What are Exceptions? EE 457 Unit 8 Exceptions What Happens When Things Go Wrong Exceptions are rare events triggered by the hardware and forcing the processor to execute a software handler Similar

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Spring 2018 Lecture 2: Architectural Support for Operating Systems Geoffrey M. Voelker Administrivia Project 0 Due 4/9 11:59pm, done individually Homework #1 Due

More information

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache

I/O - input/output. system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices. CPU Cache I/O - input/output system components: CPU, memory, and bus -- now add I/O controllers and peripheral devices CPU Cache CPU must perform all transfers to/from simple controller, e.g., CPU reads byte from

More information

Lecture 3: Concurrency & Tasking

Lecture 3: Concurrency & Tasking Lecture 3: Concurrency & Tasking 1 Real time systems interact asynchronously with external entities and must cope with multiple threads of control and react to events - the executing programs need to share

More information

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III

GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATION SEMESTER: III Subject Name: Operating System (OS) Subject Code: 630004 Unit-1: Computer System Overview, Operating System Overview, Processes

More information

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads Today s Topics COS 318: Operating Systems Implementing Threads u Thread implementation l Non-preemptive versus preemptive threads l Kernel vs. user threads Jaswinder Pal Singh Computer Science Department

More information

Introduction to Embedded Systems. Lab Logistics

Introduction to Embedded Systems. Lab Logistics Introduction to Embedded Systems CS/ECE 6780/5780 Al Davis Today s topics: lab logistics interrupt synchronization reentrant code 1 CS 5780 Lab Logistics Lab2 Status Wed: 3/11 teams have completed their

More information