Download presentation
1
Chapter 11: Distributed Processing Variations of subprogram control
Explicit call statements Exception handlers Subprograms must execute completely Co-routines Control must be transferred immediately Scheduled subprograms Single execution sequence Parallel programming
2
Exceptions and exception handlers
Exception Handlers are subprograms that are not invoked by explicit calls Special situations, called exceptions: Error conditions Unpredictable conditions Tracing and monitoring
3
Exceptions and exception handlers
Exception handlers typically contain only: A set of declarations of local variables A sequence of executable statements Exception Handlers can be predefined in the language programmer defined
4
Raising and catching an exception
Languages provide methods for raising (throwing) and testing for exceptions. try { statement1; statement2; … if badCondition throw ExceptionName; } catch ExceptionName { ……….// do something for exception…….}
5
Implementation .Operating system exceptions - raised directly by hardware interrupts. .Programmer defined - the translator inserts code to handle the exceptions.
6
Co-routines Subprograms that can return control to the caller before completion of execution. Resume B Resume A Coroutine A Coroutine B
7
Implementation of co-routines
Similar to the simple call-return structure, the difference is in handling the CIP. Each co-routine has IP location in its activation record, used to provide the value for CIP on resuming the execution.
8
Scheduled subprograms
Subprograms scheduling techniques: Execution after other subprograms – call B after A Execution when a Boolean expression is true – call B when X=5 Execution on the basis of a simulated time scale - call B when time=25 Execution based on priority – call B with priority 7
9
Implementation of scheduling techniques
Scheduling is a run-time activity. The process is controlled (usually) by a system-defined scheduler program that maintains a list of currently scheduled subprogram activations.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.