Chapter 11: Distributed Processing Variations of subprogram control

Slides:



Advertisements
Similar presentations
Lecture 9. 2 Exception  An exception is a unusual, often unpredictable event, detectable by software or hardware, that requires special processing occurring.
Advertisements

Exception Handling Chapter 15 2 What You Will Learn Use try, throw, catch to watch for indicate exceptions handle How to process exceptions and failures.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
Objectives In this chapter you will: Learn what an exception is Learn how to handle exceptions within a program See how a try / catch block is used to.
Exception Handling Exception handling (EH) allows a programmer to provide code in the program to handle run-time errors or exceptional situations – this.
Chapter 8Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 8 l Basic Exception Handling »the mechanics of exceptions l.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 13 In a language without exception handling: When an exception occurs, control goes to the operating.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Jerry Lebowitz. Topics  Provides a facility for a systematic object oriented approach to handling runtime errors ◦ Can also handle runtime errors.
Chapter 14 Exception Handling and Event Handling.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
Chapter 9 Subprogram Control Consider program as a tree- –Each parent calls (transfers control to) child –Parent resumes when child completes –Copy rule.
EXCEPTIONS Def: An exception is a run-time error. Examples include: attempting to divide by zero, or manipulate invalid data.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 17 Exceptions and.
ISBN Chapter 14 Exception Handling and Event Handling.
Exceptions (Large parts of these copied from Ed Schonberg’s slides)
Chapter 11 Exception Handling and Event Handling.
Chapter 9: Subprogram Control
Introduction to Java Chapter 11 Error Handling. Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle.
1 Exception and Event Handling (Based on:Concepts of Programming Languages, 8 th edition, by Robert W. Sebesta, 2007)
Advances in Language Design
1 Exception Handling Introduction to Exception Handling Exception Handling in PLs –Ada –C++ –Java Sebesta Chapter 14.
PZ11A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ11A - Exception handling Programming Language Design.
Chapter 13, Slide 1 Exception Handling Exception handling is a language feature that allows the programmer to handle runtime "exceptional conditions."
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
Object Oriented Programming
CIS 270—Application Development II Chapter 13—Exception Handling.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Question: What causes asynchronous control? Asynchronous control ≈ not determined by normal instruction execution Example int x = 2; // suppose a transfer.
Java Software Solutions Lewis and Loftus Chapter 14 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Advanced Flow of Control --
VB.Net - Exceptions Copyright © Martin Schray
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
ISBN Chapter 14 Exception Handling and Event Handling.
Trapping Oracle Server Exceptions. 2 home back first prev next last What Will I Learn? Describe and provide an example of an error defined by the Oracle.
Computer Programming with JAVA Chapter 8. Exception Handling Basic Exception Handling the mechanics of exceptions Defining and Using Exceptions some "simple"
1 An Exception is… An unusual, often unpredictable event, detectable by software or hardware, that requires special processing An exception handler is.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
CSCI 383 Object-Oriented Programming & Design Lecture 20 Martin van Bommel.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
EXCEPTIONS. Catching exceptions Whenever a runtime error occurs, it create an exception object. The program stops running at this point and Python prints.
1 Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
16 Exception Handling.
Exception Handling and Event Handling
Exception Handling and Event Handling
PZ11A Programming Language design and Implementation -4th Edition
Exception and Event Handling
Exception Handling and Event Handling
Chapter 14: Exception Handling
Chapter 12 Exception Handling and Text IO
Exception Handling and Event Handling
Exception Handling In Text: Chapter 14.
Exception Handling and Event Handling
Languages and Compilers (SProg og Oversættere)
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Ninth step for Learning C++ Programming
Tenth step for Learning C++ Programming
Exception and Event Handling
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Lecture 9.
Exception Handling and Event Handling
Exception Handling.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
Presentation transcript:

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

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

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

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…….}

Implementation .Operating system exceptions - raised directly by hardware interrupts. .Programmer defined - the translator inserts code to handle the exceptions.

Co-routines Subprograms that can return control to the caller before completion of execution. Resume B Resume A Coroutine A Coroutine B

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.

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

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.