Process Management and Exception Handling in ... - CiteSeerX

9 downloads 443 Views 1MB Size Report
Sep 26, 1988 - tives, scheduling mechan/sms, .... dispatching and ... operating systems [8]include a monolithic, kernel, process hierarchy,functional hierarchy,.
Report

No.

UILU-ENG-88-1720

UIUCDCS-R-88-1415

TAPESTRY

Principal

Technica/Report

No.

Process

TTR88-4

Management

and

in Multiprocessor Using

Investigators

Exception

Operating

Object-Oriented

Handling Systems

Design

Vincent

Roy Campbell and Daniel Reed

Techniques

Russo

Gary Johnston Roy Campbell September

26, 1988

TAPESTRY

DEPARTMENT UNIVERSITY

OF COMPUTER OF ILLINOIS

SCIENCE

AT URBANA-CHAMPAIGN

• URBANA,

ILLINOIS

61801-2987

Contents 1

Introduction

1

1.1

Related

Research

1.2

Structuring

2

The

Choices

8

Processes

.................................

an Operating Class

System

3 Using

Class

Hierarchies

...........

4

Hierarchy

6 7

3.1

Memory

Management

.......................

3.2 3.3

Process Implementation and Context ProcessContxiners .................................

3.4 3.5

Exception The CPU

Handling ................................ ProcessContxiner Subclass

3.6

Hardware

Exceptions

...............................

, ....... Switching

......................

................

7 8 9 9 i0 ii

4

Semaphores

12

5

Schedulers

13

6

Summary

15

References

17

Process

Management

and Exception

in Multiprocessor Using

Operating

Object-Oriented

Design

Vincent

Handling

Systems Techniques*

Russo

Gary

Johnston

Roy

Campbell

September

26, 1988

Abstract The progr_=rrrn;n_ of the interrupt

h_n,]1;n_

mechanisms,

process

switching

tives, scheduling mechan/sms, and synchronization primitives of an operating for a mnltiprocessor require both efficient code in order to support the needs

primisystem of high-

performance or real-time applications and careful organization to facilitate maintenance. Although many advantages have been claimed for object-oriented class hierarchical languages and their corresponding design methodologies, the application of these techniques to the design of the primitives within an operating system has not been widely demonstrated. To investigate the role of class hierarchical design in systems programming, the authors have constructed the CTw/ces multiprocessor operating system architecture using the C++ progr_mm_ language. During the implementation, it was found that many operating system design concerns can be represented advantageously using a class hierarchical approach, including: the separation of mechanism and policy; the organization of an operating system into layers, each of which represents an abstract machine; and the notions of process and exception management. In this paper, we discuss strategy

1

an implementation

of the low-level

by which we developed

primitives

of this system

and

outline

the

our solution.

Introduction

The tion

Choices [i] [2] operating system architecture to the design problems of operating systems.

is organized Applications

as a class for which

hierarchical Choices has

solubeen

•This work was supported in part by NASA under grant number NSG14T1 and by ATtzT METIIONET.

designed

include

itoring

numerical

systems,

research

and

controllers

was motivated

spedalized

memory

and

be easily

extended

gration,

and

ing system

applications

to organize

implemented this

that

the

family

abstnac_

minimize cations

overhead

that

design

shared

memory.

within

the

process

Any

dais

A major

the

hierarchy,

are

switching

motivation

The C++ programming

Choices.

Therefore,

class

complex

Mesa

or AdaS).

xMultimax

systems

designer

may

hierarchy

define

conclasses

objects

be specialized

application many

into

in

for a

in order

different

a "general

to

appli-

purpose _

nor uses.

across

the and

interprocess

the applications

memory.

as objects,

Choices network.

have

the

design

language

and

communication is supported

support 2

by

for networked

Processes

implementations

exclusively

is also an investigation to either

classes

of Encore

that

already

within

Computer

class

are

defined

that

reduce

hierarchical

of complete

supports

features

object-oriented

to an existing

has system

Choices

that

objectoperating

in the implementation

of the appropriateness

which

adding

if the

implementation

[7] was used

in a language

language

we discuss

was to determine

for the

as opposed

is a trademark

memory

Choices

classes

supports

for efficient between

virtual

research

be used

programming

In this paper,

required

modeled

this _-'search

hierarchies,

more

requires

techniques

1

systems.

primitive

dedicated

hier-

system

Multimax.

The

may

designed

class

service

of these

Choices

and

system

system.

hierarchy

features

for particular

overheads.

systems.

operating

Thus,

neither

in shared

for this

could

the

Encore

system

of a particular with

memory

and

of system

An operating

operating

mi-

operat-

selection

services

operating

subclasses within

efficiency.

virtual

approach

and

Concrete

communication

oriented

in 8 complete

a custom

associated

objects

extends

context

to build

or the needs

virtual

runs on the

systems

process

uses objects

of a family

classes

operating conventional

problems.

The

Classes

the application

exploit

Choices

example

for

of heterogeneous

current the

The

systems

reconfiguration,

specialized

mon-

networks.

operating

a predefined

of classes.

in order

requests.

on persistent

multiprocessors

hardware.

hardware-independent

and to improve

system

operations

components

to provide

concept

a hierarchy

any overheads

Choices via

through

example,

offers

currently

the

switched

Similarly,

that

ground-based

coUections

balancing,

to both

architecture supports

environment

but avoids

operating

parallel

implementations.

hardware

on large

management.

extended

and

and packet

load

a Ukernel"

solutions

Choices

to application

Choices

specific

facilitate

primitive

respond

particular

be easily

architecture

or spedalize

talus

resource with

control

multiprocessor

For

dynamic

on particular

and

with

Choices

provides choose

CPU

cannot

circuit

of building

multiprocessors.

applications

flight

applications

to manage

heterogeneous

this kernel

concurrent

real-time

networked

provides

services;

The

difficulties

high-performance,

cannot

embedded

for high-speed

by the

shared

archies

computations,

support

of implementprogramming

language

programming process

of

or using

features

(e.g.,

dispatching

and

a

Corporation.

2Messsse-oziented kernels like the V Kernel [3], Accent I4], Amoeba [5], and MICROS [6] build specific communication schemes into the lowest levels of the kernel. For example, some systems implement a few ways of providing _virtusl _ messages like "fetch on access, m However, these systems are not easy to adapt to support other approaches such as "send process on read" or '_.mote procedure caU on execute." aAds is s trademark of the Department of Defense (Ads Joint Program Office).

2

execution, exception handling, processcontext The

classes

provide

the primitives

application-specific

systems

1.1

Research

Related

The

from

which

switching,

scheduling,

higher-level

layers

and

of the

synchronization.

operating

system

or

are constructed.

organization of an operating system is a dimcult task. Many

differentapproaches to

structuring operating systems have evolved in response to advances in hardware technology and improvements

in software ensineering techniques. Approaches

to the structuring of

operating systems [8]include a monolithic, kernel, process hierarchy,functional hierarchy, and object-orientedcapabilitystructure. Many

simple microprocessor and some early batch operating systems are structured using

the monolithic approach: as a large program

that invokes user programs

as _subroutines."

These applications Ureturn" by requesting operating system servicein the form of a system call,by terminating, or by being preempted Many which

current

application

such

as its

often

introduce

the

the

often

notion

of a CPU

abstractions

among

and

applications

multiple

of operating

the

are organized

on an Uabstract

of a concurrent

provided

though

is large

execute

by a hardware interrupt.

like UNIX

use by other

the majority

Even

systems

programs

concurrent

sharing

minimal; the

operating

CPU" and

process

executes

details

hardware the

Typically,

software

a /_eene[

that hides I/O

to support

applications.

system

its

using

abstraction

the

to build

can benefit

provided

However, may

in a kernel

should,

from structuring.

system

may

The

objects Both

for

small

by definition,

Layered

operating

large

that

and

systems

system

manner.

operating

into

process

most

is

exploiting

kernel

system

that

the

processes

within

kernel

a system

the

system

operating

considers

The interaction

it of

of such an object-oriented

processes

systems

of the

desirable

lack

of today's

the

asynchronism

solution major

internal

of separating

through

it structures

is a practical

are suitable

of any

property

communicating

because to many

operating

because

has the

of a kernel

applied

Instead, within

services.

One example

up well

important

contents

has been

system

to organizing

scale

approach

is very

layers.

processes

required

portability,

[12].

approaches do not

solutions

and

an operating

and

of capabilities. 432 system

[9] and

Each layer is built as the abstractions and

various

into

THE

it

the hierarchy.

to structuring

applications

a set of cooperating model

the

the

to a minimum,

notably

maintainability

[11]. Concurrent

approach

iAPX

By separating

levels

includes

but

Layering systems

of the kernel

of the kernel

be kept

systems,

improved

to organize hierarchy

as a network

The operating

layer. offers

at different

is the Intel

the monolithic

cooperating

easy

capability

is organized

an operating intuitive

functions

of objects

system

structure. The

always

objec_-o_ented

operating

layering

as a j_anction_

access

as a collection the

by the previous system,

it is not

be organized

permits

by the kernel.

software

an operating

Kernel's

that

software

outside

in

of the real CPU

interface.

Venus [i0], structure an operating system as a series of layers, or levels. a collection of concurrent processes and software modules that exploit enhancements

approach

kernel. in an

to structuring

operating

systems

[13][14][15][z6]. The major layer

di_culty

in which

processes

of a particular by lower disk

since

memory

memory

planning

memory

paging

caused

such

networks.

However,

organized

into layers.)

To summarize, by providing

operating

a machine processes,

hierarchy,

or by representing

system Each

as objects. approach

dif[erent

1.2

approach.

without

standard

concerns

that

would

like

programming

and some

objects

concurrent

processes.

The class inheritance

The between language

engineering class

that

A process Class

within

hierarchies that

do classes

been

previous

among

operating

complexity. derived

by a

approaches

with

of

include

class

existing

from

one layer

may

coercions and

structure

access

objects

references

modular

operating

are

used

as

collection8 or contain

in other

layers.

to these also

objects have

the

programming.

a operating

system

systems. Reuse is gained from the that care is used in the construction

4

In this

are

define

programming

within

major

object-oriented

that

may

object-oriented

of the

organize

approaches.

Choices, layers

of such

hierarchies.

others allow

design

hierarchies

Within and

reuse

to

The

construction

expression

and

design

hierarchies

a kernel

reuse

to the the

by class

functions

code

operating system layers, and across with class and inheritance provided

permit

of a system.

code

encourages

Hierarchies and

also represent

within

type and

Class

is permitted

to build

and upward

approach

with

have

organization

or kernel.

system

defined

advantages

hierarchical

used

the they

layering

of a layer

are

dependencies,

of an

inheritance

but easily

use

and

only

that

the

provide

mechanism

manner.

Not

to the

internals may

Using

improve

methodology

issue

inheritance

of objects;

in a structured

the

will

techniques,

to emphasize

to structure

this

not be expressed

the design

is an orthogonal

a means

software

could

System

penalty.

design

these

are

approach.

of class hierarchies

believe

system

we describe

systems

We

objects

into a functional

or coping

could

distinguish

to reduce

to represent

the

abstractions

that

in designing

helps

machine

But, virtual

of shsrin 8 of a CPU

of simplicity

to implementations

the

problem

(unless

the

paging

store.

with

of processes,

and

systems,

can be used

the details

into layers

internals

memory

approach

by hiding

services,

we shall

difficult

the

provided

as a backing

lack structure

in terms

Operatin_g

a performance

operating

support

section,

of the applications

systems.

that hides

object-oriented

is a study

systems

We

next

an

of operating

section,

In the

hierarchical,

kernel

mechanisms,

lead

disk

capabilities

organized

system

memory virtual

be coordinated

capability

since

the

or functions

the

use the must

is determining

structuring

in virtual than

are the most

been

has merits

Structuring

Choices

design

the

Each approach sometimes

must

networks

have

by structuring

may

our own class

arbitrary

independent

concurrent

level

buffers

dependencies

systems

and

For example,

by a lower

mechanism

kernels

on the processes

The object-oriented

cyclic

somehow

rely

dependencies

system.

by such

arbitrary

only

use for I/O

Such circular

system

be implemented

may

is necessary.

drivers

of an operating

the problems

operating

should

be provided

the disk

management.

the layers

layered

each layer

should

the

that

building

or functions

Since

careful

drivers

mechanism the

layer.

layers,

device

with

layer,

use of a of the

subclasses. By building class hierarchies in which methods are through subclassing, much code can be shared between classes. Layered

operating

functions

and utilities

are

mutual

exclusion

hash tables, in several

layers

form

algorithms

and

to apply

them

classes

Families

repeated

data structures

of useful

to the

needs

specific

within

of operating

operating

also

portion

of reuse simplifies and application. The class

hierarchical

operating

system

concepts,

offer many

possibilities

the family

the

parent

also encourages

of systems

is 8uided

and

hierarchy.

The

hierarchy

view

of how the

the possible

with

function

addition,

subclassing

to be modified

without

All machine operating classes

system class

instances

policies

specifies

of the

class

system

archy.

so that

(Not

be reused, the

_fan

out"

In later management

implement similar

only do classes including

and

support (2-7)

of this paper exception

and

overall

view

of a Choices

form

machine and

by

the

mod-

structure

designer

with

a

It classifies

com-

of a parent

class,

for Choices,

of the system. operating

class

to specify

In

system

encapsulated that

may

refines

design

within

class

from a common

operating policies

hierarchy ancestor

by a hierarchy

Overall,

on

the implementaversions,

the

An

be used

to specify

particular

possible, induced

management),

set of subclasses.

we have

is hier-

may

also

constrmned

reuse.

the use of this methodology Choices.

table

are

(its methods)

in the hierarchy.) code

page

dec/s/ons

be specialized

5

This

for a target

systems

as a potential

but the structure

to encourage

with many

similar.

function.

(e.g.,

Wherever

can

are

the function

A concrete

are used

we will discuss within

these

An abstraction

as a class

8 and

the

are used in our system

of the classes

handling

des/gn

protocol

abstraction. reuse,

classes

system. meclmn_,r_

and

subclasses the

these

Customization

system

part

subclasses.

classes

abstract

instantiating

reuse.

systems

subclassin

a good

implemented

sub-hierarchies

code reuse

to be small

parts

Abstract

Concrete

that

constructed

and its concrete

by

to achieve

system

behavior

of a system.

[17] [18]. In the class hierarchy

rest of the

are

and

for a particular hardware or of the class can all share a

provides

of a specific

schedulers)

decision

a general

class.

abstractions.

or mechanisms

the

operating (e.g.,

Design

tion of an abstract

behavior

chansing

then

if they

by learning

can be inferred

the

class

of an operating

to be mastered

depemienc_es,

in Choices.

abstroct

need permits

aided

to their function;

of a subclass

only the top few classes

class

components

respect

be used

the

subclassing

customization.

of a family

of a system

the layers

of code

of operating

by the

ponents

may

lists,

of the definition

may be defined

a "version" of that class The different versions

induced conceptual

queues,

to represent

and

system

layer.

ification

class

system,

Common

schedulers

throughout classes

of the family

approach

and

allow the reuse

generic

through

the customization

reuse.

incrementally

For example,

processes,

data structures

within

of the implementation

layers.

Classes

of an operating

component

code

by defini'ng

different subclasses each implementing a particular application's requirements. large

layer.

a specific

systems

system

for

d_erent

semaphores, and

is enhanced

objects

opportunities within

primitives, algorithms

reuse

to produce

of some

many

the application

of abstract

of code

offer

often

including

implementation This

systems

specialized

to design

process

Choices

Base

Classes

Class

Methods c'tor

d'tor

_MemoryRsnge

c'tor

d'tor

_Process

c'tor

d'tor

_ProcessConts/ner

c'tor

_Exception

c'tor

Object

reserve

release

physicaiAddress

d'tor

add

remove

-

d'tor

raise

-

Legend Symbol method

Meaning of method.

Definition

method

Redefinition Subdass

Table

2

The

Before

going

into

the

Base

Class

details

of the

hierarchy

is appropriate.

Choices

class

hierarchy

&re shown

in a Choices This

about

the

executed Class

system.

is usus/ly

memory

ProcessContaine_

To aid lowest provides Germ

an "ides/ized" Objects

subclasses

of generic

the

h&rdw&re

system

include

memory

4The %'irtual" machine copy of the actual hardware

by

major

classes,

a brief

classes

in the

subclass

the

(i.e.,

redefines

information machine

to execute.

added

to provide

in this

to and

overview first

and

of the

level

adds

necess&ry

registers) Processes

removed

for Process

that

design

of the

methods

to execute

and

information

&re scheduled

from

execution

for mansgin

for use in the

classes and

that

define

physical

management,

&re grouped

encapsulates

h&rdw&re &rchitecture

defined

exception,

Each

it expects

by being

objects

the meclmnisrrs8

computer.

1.

information

in which system

It is a set of objects

provides

Hierarchy.

and

ProcessContainers.

and

scheduling.

Class

basis for exception handling, inc.luding traps and interrupts. The usually causes Exception-specific movement of Processes between

in portability,

layer.

Choices

exception

of the

is represented state

is specialized

Ezception provides the raising of an Exception ProcessContainers."

and

Some

in Table

A Process

a Choices

in the

MemoryRange provides the base for storage management Instances of class Process are the basic units of execution

the processor

virtual within

Classes

process

class

defined for class Object. Class in a Choices operating system.

method.

method.

Hierarchy

Choices

it.

or inherited

Undefined

1: Major

Choices

of method.

the

to the

into

major

rest

Germ

interfaces processor

exception

for specific to the manasement

Germ

is the

dependencies

and

layers

in the system.

4 The

the physics/resources architectures

h&rdw&re

mechmxisms.

The

h&rdw&re

of the

8 and maintaining

layers.

&re instances

memory

Intermediate , schedulin

of the of

management, layers

8 and naming.

in the The

provided to the higher layers of the system by the Germ objects is not a virtual m in the IBM VM/370 [16] operating system, but rather an idealized _chitecture.

6

Kernel

is the

highest

to applications. particular

hardware

appropriate

layer

in the system.

A complete

operating

of the system,

for the

It defines

system

objects

applications

that

belonging

are

system

are implemented oriented

thus is ideal

example,

classes,

design

whose

loading

class

stack

thus

system

while

are

imposing

the functions

memory

management

sections,

run-time handling,

it supports

assembly

in C ++. It is easy

registers).

itself

(for

However, of methods

even

class

and

to the lowest

hierarchical

even of low-

levels

of

object-oriented

overhead.

we will describe

of interrupt

a few small

implementations

implementation

because

object-

overhead

in the language

unit

with

synchronization,

It implements

directly

impossible

objects

Individual

hierarchy

runtime

are, of course,

not be implemented

the object-oriented

negligible

and

minimal

machine-dependent

C++ was chosen

for parallelism portable.

things

and Kernel

the class

and

system for the

system.

augment

with

to achieve

and

mostly

layers,

semantics There

by the

appropriate

operating

is efficient

could

in order

by the

support

programming.

functionality

preserving

hierarchy.

language

provided

objects

to the middle

can further

including

hierarchy

pointers

routines

In the following ment

The class

C++ to assembler

assembly

level

C++. and

for operating

routines

to interface

the

using

programming

language

these

components,

of Germ

supported

applications that run on top of the new system their own classes. All operating

the interface

consists

in more

process

detail

some

dispatching,

of the classes

context

which

switching,

imple-

scheduling,

and synchronization.

3

Processes

Choices

supports

lightweight,

the

concept

independent

of a computation

parallel

application may use multiple lelism. A single one of these class.

Each instance

share

memory

such

of the

Process

to be useful

Memory

A complete

discussion

order to discuss Memory

of the

represents

management

and basis

Choices

description

process

management

MemoeyRange

SA more complete

to those

described

to allow and

an independent mechanisms

efficient

the context

process switching

large

number

in [3] [13] and

of

[19]. An

concurrency and paralof the Choices Process flow of control

described

below.

migration,

the

effort between

that

can

In order amount

for

of in-

two processes

Management

this paper, s A general

stract

class

throu8 h the memory

an abstraction

similar

of a potentially

communicating processes to achieve processes is represented by an instance

formation kept on a per-process is minimized.

3.1

processes

composed

of the

management

and

in Choices

class as root. description

memory

management

way memory context

is implemented The classes

is contained

in [1].

system

is managed

switching

is, however,

the

scope

necessary

of in

in Choices.

by a hierarchy

in this hierarchy

is beyond

of classes

support

virtual

with

the

memory,

abthe

sharing

of memory,

a contiguous

and memory

range

to represent

the

class

Space.

A Space

cess.

The class

Domain

class

Choices

code,

within

this

Domain.

initial

processor

The

a Process

switching Process

Context

minimum

context

represented

can

be

within

associated

real

may be locked only

resident Locking

sired. in the

is currently

switching

overhead.

to be locked

as addressable in resident

can optimize

privileged

shared

Spaces

locked

as addressable and

to exclude Germ

access

and

the

as Spaces Domain,

arguments

scheduling

virtual

to

parameters,

processor

incurs

from

in non-privileged

process

system

switch

the

Domain

processes

with

code,

context

switchin

memory

and 8

to be and

In addition,

the

a Space

that

addresses

loadin 8 overhead, processes

e as de-

by runnin 8 the processes protection

of the

even though

a Space

from

are implemented

the

within

a stack,

fast

and real-time

ePlns MMU cache flnshin 8 overhead, if the old and new Domains differ.

8

in

is necessary.

to a process

memory Thus,

within

to be validated

register

protected

object

execute

matches

Locking

applications

mode.

which

accesses

memory.

handlers

are stored

between

addresses

only

contents

Process

switching

its Domain,

8 the

it can remain

of a Choices

dispatched

as resident.

other

settin

that

to switch

virtual

of interrupt and

by each

Processes

in physical

and register

class is used by the process

context

ability

A context

memory

state

copies

being

within

as resident

by all Processes.

by all Domains, memory

the

corresponding

still be protected

of the

with between

of s Space

the performance

may

state

the

processor

no memory

contained

memory

causes

Usually,

by an initial

manipulate

Since an executing

a Space

pases

registers

8 require

memory

memory.

pointer),

is maintained

of the Process

Spaces

the

either

Spaces.

are represented

of the Process

is lowest

executing,

processin

Such processes

The Kernel

if the Domain

by locking

stack

a CPU's

real-time

stack

or stack

the

method

overhead

by the various

achieved

resident

since

and

supervisory

to reload

memory

be accomplished

is parameterized

Domains,

by storing

The dispatch

switching

the processor

Interrupt data

A small

their

can

be accessed

during

list common

its virtual

and

counter

may

into the

8.

is recorded

object.

Domain

alter

and dispatchin

code in Choices

a common in which

for Processes

preemption.

object.

for a process program

that

is

by a Pro-

Switching

specifies data,

example

It is subclassed

is consulted

which

Context

that

important

memory

processes

Domains

unlnitialized

(for example,

of a process

order to handie

a Domain

constructor

of virtual

represents

is subclassed

addressable

of Spaces.

between

different

most

memory

of a process

and

data,

The

state

preemption

state

within

or through

initialized

Methods

handie

view

Domain

Implementation

executable

and

in the

class

MemoryRange

The

of virtual

for the a_regation

the complete

references

implies.

in a system. a range

Sharin 8 of memory

Process

the process.

of memory

of Spaces

Domains

Process

Each

list

of a MemoryRange

as the name

to represent

is provided

decisions.

shared

3.2

kinds

represents

The

An instance

addresses,

is used

which

manasement throush

different SpaceList

by a Process.

protection.

of memory

unprivileged as sets

81obally may

be

processes.

of such Spaces.

Processesand ProcessContsiners Methods

Class Object _Process

.... dispatch

_P_ocessContsiner _1SinsleProcessContsiner H_CPU ilFIFOSchedu]er H _RoundRob/nSehedu/e_

add add add add _

Table

3.3

2: Process

chanKeDomaln

getSchedulerInfo

setSchedulerInfo

remove

is_.mpty

-

remove

_Emp£v

-

_mo_ remove _-mo_e

_ iaEmptv 1

-

and ProcessContainer

Base

Classes.

ProcessContainers

Primitives instances name

for scheduling, blocking of the Pro_ssContainer

implies,

involve

is a container

transferring

in Choices

Subclasses Some

are de_ed

and defines or not).

Processes

LIFO,

ProcessContainers implement

queues

queuing

contain add

or priority

of processes

dispatching Table

disciplines

a single

algorithms

2 shows

Processes

and isEmpty these

methods,

(e.g.,

dling.

The

condition.

Exception The

system

"run queues"

class

defines class

HardwareExceptions architecture.

ily by an executing Processes

way for a process

in Choices

the base the

classes

method

has subclasses

for a HardwareException

of the underlying cause

3 shows

Exception

The raise method interrupt.

are introduced Table

process.

to be moved to suspend

abstraction

and

are used Exceptions

by the

"ready

abstract

of Choices raise

class

is

remove

the container

to add and

that

to intercept

to encapsulate method are

ProcessContainers.

and

remove

refined

may

and

and

and

han-

SoftwareEzception. of a hardware

hardware

exception

Raising

refined

the exception

as a result

objects

be used

exception

correct

to

Scheduling

class

implement

of a SoftwareException

the primary

its own execution.

the

be

operation.

Ezception

which

directly

may

queues"),

HardwareEzception

is called

The raise between

contain.

order.

an operating

Handling

exceptions

whether

for example,

3.4

Low level

they

into the container),

(for testing

await an event or are blocked on a Semaphore in more detail in a later section.

by its subclasses.

of the classes

The ProcessContalner

to store processes that in Choices is discussed

Exception

by using as the in Choices

some

on the Processes

Process.

(for inserting

can redefine

represent

and

in Choices are built A ProcessContainer,

ProcessContalners.

from the container),

Subclasses

in FIFO,

and

impose

to only

the operations

Processes

Scheduling ProcessContahlers.

Processes

of ProcessContainer

(for removing is empty

between

implement

subclasses

abstract

of Processes.

Processes

which

and dispatching processes class and its subclasses.

mechanism

is called

in Choices

whose

an Exception

trap or voluntarmethods

is the only

Exceptions Class

Methods

Object

w

J,Exception _HardwareException _ _Interrupt

Exception

await

ra/se

fixFault

rcl/Se

-

$_DivideByZeroTrap

ra/ae

-

_TimeSUceInterrupt

m/Be

clockTick

l_SoftwareException

ra/se

handler

1_ J,SemaphoreException

J,

handler

processing of the

CPU

subclass

of ProcessContainer,

class,

add method

3: Exception

Handling

ProcessContainer

fits naturally

CPU

-

Table

A special

1 ra/ae

_ J,_MegallnstructionT_ap

The

-

ra/se

_Abort'i_ap

3.5

raise

into this model

each

corresponding

to dispatch

and execute

Base

Classes.

Subclass

CPU,

represents

since

a system

to an actual a Process

an actual

physical

can consist

of more

processor.

on the

The

processor

To effect

the

process

Exception

transfer

must

is raised,

of the

first

the context

stack. These supervisory to hold a single process invokes of any

the

Exception

particular

Exception

CPU

be saved.

handler.

behave

define

the raise

the

exception,

class

after

defines Exceptions

7This executed CPU

and

stack within added

processing

methods

to install

the itself

context

by

the

context

is saved

the

remove

It returns of the

an exception.

the

to another

from the second ProeessContainer two processors at the same time.

method

exe-

When

an

on its supervisory

class

ProcenContainet), added

its

Proceu

a race to

another

10

a minimum

exception

would

where

resulting

in

amount

the the

Process

it

of context The

CPU

an Exception

handling

to remove Proceu

store

Exceptions.

invoking

attempted

CPU

state

of Exceptions

the process.

if a Process exist

CPU,

of hardware

voluntarily If the

the

all classes

resume

initialisation.

(i.e.

from

Not

as the handlers

of the

stack/

Process

CPU.

to save only

by a Process

during

patticulaz

and

the

to the

objects

independent

supervisory

it will immediately

Exception

CPU

is executed

to remove

Process

syneXronously

of any

handler

code

add another

can be raised is created

process

The

preemption.

by raising

to a per-processor

contain

and

because,

redefines

it represents.

to another,

executing

The Exception

by switching usually

way; some

process

of the currently

in a ProcessContainer, this

one

is accomplished

class

stacks exist one per Process object and need only be large enough context. Once the state is saved on this stack, the raise method

process

handlers

from

This

Multi-

than one instance

CPU

method of the CPU class is used by Exceptions to implement CPU the Process for which the CPU has most recently saved a context. cuting

processor.

itself

could being

be

code

was

from

the

removed

executed

by

object's raise method, or voked"

through

more

detail

most

notably

3.6

the

asynchronously

hardware

in the following

sections.

anism

that

traps

for handling

traps

machine

traps

and protection (for example,

Many

a "system

occur

await.

The

occurs,

at which

if they

the

sequence

the

processor

tion object the

and

interrupt

awaited.

and

placed

ready having

queue

When on the

"in-

discussed

and

Exceptions,

in

one

occurs

ready

queue

await

the

of the

the interrupt

and

queue.

This would,

until class

queue" Figure

Process The

Process1 shows

R is running

CPU

object

from

and

the

on

InterruptExcep-

to hold the Process

the

a

InterruptException

occurs,

interrupts,

un-awaited

described

process

awaiting

added

to the

interrupt

then

cause

however,

11

CPU.

class.

The

objects

the require

context

must

have

removed

from

is then

chosen

effect switch

an extra

a

a time-slice

TimeSHceInterrupts

process same

that

For example,

is preempted, Another

to the

above,

interrupts.

TimeSliceIntereupt

ProcessContainer. added

its execution

"ready

is removed

cur-

object.

running

and

the

defines

must

's occurrence.

from

ser-

resumes,

to do with

of the interrupt.

a ProcessContainer W

handler

then

InterruptExceptions

of the

the interrupt

Process

memory program

Trap

to block

adds it to the system's

interrupt

virtual

and

nothing

be resumed. method

R is removed

provides

The

This

explicit

of HardwareException

the occurrence the

and

Process

have

a mech-

of its execution.

types),

by a Process

may

provides

instruction),

trapping

subclass

The raise

hardware

by an instance

the ready

in general,

Before

to the CPU

result

like instruction).

is invoked

Finally

Choices

ProcessContainer

a process

chosen from first method.

added

them,

is handled

not

Process

illegal

and,

process,

Trap class

of various

of the

variable

to the synchronous

awaiting

"SVC"

awaiting

detail.

as an instance

and

In addition

and

context

is awaiting

ProcessContainer.

ProcessContainer process

W

In the figure,

queue

being

are

later.

The

as a direct

faults

the Process

to be missed.

in more

Process

contains

interrupt.

ready

method time

the Process

of events

an

the

of the interrupted

and resumes

page

InterruptEzception

await

are not

the context

Container

call" via

The

subclasses.

may generate

asynchronously

process.

the interrupt saves

are discussed

divide-by-zero

within

new method, be awaited

exceptions

uses of ProcessContainers

major

(for example,

condition Process.

interrupts

executing

a process

(for example, errors

vices the exception or terminates that

rently

of an Exception

Exceptions class has several

access

method Hardware

of semaphores,

The HardwareException includes

raise

mechanism. Combined

in the implementation

Hardware

by the

exception

are

the

CPU,

from

the

can be achieved

by

to a second

context

switch

process over

the

CPU

Ready Queue

Object _er

Raise Message (from hardware)

Queue

Interrupt Object Figure

4

Processing.

Semaphores

In Choices, V, defined

a semaphore [9] is implemented abstractly as follows:

P (Semaphore) count

count

:

count

:= count

( count

if

Wakeup A constructor semaphore.