dibble2009 ] interrupts

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

Upload: others

Post on 25-May-2022

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Dibble2009 ] Interrupts

476

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

476

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Req

uir

ed m

ech

anis

ms

for

inte

rru

pt d

rive

n p

rogr

amm

ing:

• In

terr

upt

cont

rol:

Gro

up

ing,

en

cod

ing,

pri

ori

tisi

ng,

an

d e

n-/

dis

ablin

g in

terr

up

t so

urc

es

• C

onte

xt s

wit

chin

g: M

ech

anis

ms

for

cpu

-sta

te s

avin

g an

d r

esto

rin

g +

task

-sw

itch

ing

• In

terr

upt

iden

tifi

cati

on: I

nte

rru

pt v

ecto

rs, i

nte

rru

pt s

tate

s

Har

dw

are

sup

po

rted

Imp

lem

ente

d in

so

ftw

are

474

5A

sync

hron

ism

Uw

e R

. Zim

mer

- T

he A

ustr

alia

n N

atio

nal U

nive

rsity

Real

-Tim

e &

Em

bed

ded

Sys

tem

s 20

19

477

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

477

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

• …

at t

he

op

erat

ing

syst

em le

vel

475

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

475

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

[ Bar

nes2

006 ]

Bar

nes

, Jo

hn

Pr

ogr

amm

ing

in A

da

2005

A

dd

iso

n-W

esle

y, P

ears

on

ed

uca

tio

n, I

SBN

-13

978

-0-3

21-3

4078

-8, H

arlo

w, E

ngl

and

200

6

[ Bur

ns20

07 ]

Bu

rns,

A &

Wel

lings

, A

Co

ncu

rren

t an

d R

eal-T

ime

Pro

-gr

amm

ing

in A

da,

ed

itio

n

Cam

bri

dge

Un

iver

sity

Pre

ss 2

007

[ Dib

ble

2009

] D

ibb

le, P

eter

RT

SJ 1

.1 -

JSR-

282

Earl

y D

raft

Rev

iew

ver

sio

n 6

2

009

pp

. 1-1

8

[ NN

2004

] Th

e Re

al-T

ime

Java

Pla

tfo

rm

A T

ech

nic

al W

hit

e Pa

per

Jun

e 20

04 2

004

pp

. 1-2

6

[Ad

aRM

2012

]A

da

Refe

ren

ce M

anu

al -

Lan

-gu

age

and

Sta

nd

ard

Lib

rari

es;

ISO

/IEC

865

2:20

1x (E

)

Ref

eren

ces

Page 2: Dibble2009 ] Interrupts

480

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

480

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

A4A3A2A1

Purpose

TypeD15

D14

D13

D12

D11

D10

D9

D8

D7

D6

D5

D4

D3

D2

D1

D0

00

0InstructionRAM

R/W

Acquisition

Watch-

0to

(RAMPointer=00)

Time

dog

8/12

Timer

Sync

VVIN+

Pause

Loop

11

1

00

0InstructionRAM

R/W

0to

(RAMPointer=

eraCt’no

D)10

>/<

timiL

ngiS

# 1

11

1

00

0InstructionRAM

R/W

0to

(RAMPointer=

eraCt’no

D)01

>/<

timiL

ngiS

# 2

11

1

10

00

Configuration

R/W

Don’tCare

DIAG

Test

RAM

I/OAuto

ChanStand-

Full

Auto-

Reset

Start

Register

=0

Pointer

Sel

Zero ecMask

byCAL

Zero

InterruptEnable

R/W

NumberofConversions

Sequencer

INT7

Don’t

INT5

INT4

INT3

INT2

INT1

INT0

eraC

otsserdd

AOFI

Fnoisrevno

Cni

retsigeR

10

01

toGenerateINT2

GenerateINT1

Address

RActualNumberof

ofINST7

“0”

INST5INST4INST3INST2INST1INST0

10

10

InterruptStatus

ConversionResults

Sequencer noitcurtsnI

OFI

Fnoisrevno

Cni

retsigeR

being

Executed

etyB

woLteser

Pre

miT

etyB

hgiHteser

Pre

miT

W/R

remi

T1

10

1

Register

sBSL

:ataD

noisrevnoC

noisrevnoC

ngiS

sserddA

Rnoisrevno

C0

01

1

sBS

M:ata

Dngi

Sro

OFI

F

timiL

Rsutat

Sti

miL1

01

1#

timiL

sutatS:2

# 1:Status

Register

LM12

L458

– R

egis

ter

bank

478

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

478

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

… a

t th

e in

divi

dual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

• …

at t

he

op

erat

ing

syst

em le

vel

481

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

481

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

InterruptEnable

R/W

NumberofConversions

Sequencer

INT7

Don’t

INT5

INT4

INT3

INT2

INT1

INT0

eraC

otsserdd

AOFI

Fnoisrevno

Cni

retsigeR

10

01

toGenerateINT2

GenerateINT1

Address

RActualNumberof

ofINST7

“0”

INST5INST4INST3INST2INST1INST0

10

10

InterruptStatus

ConversionResults

Sequencer noitcurtsnI

OFI

Fnoisrevno

Cni

retsigeR

being

Executed

LM12

L458

– D

ata

tran

sfer

opt

ions

Sel

ect

inte

rrup

t so

urce

(in

terr

up

t en

able

reg

iste

r, 15

bit

s):

• W

atch

dog

(INT

0): l

imit

co

nd

itio

ns

are

fulfi

lled

.

• In

stru

ctio

n (INT

1): t

he

inst

ruct

ion

po

inte

r eq

ual

s a

pre

-pro

gram

med

val

ue

(bit

s 8-

10).

• C

onve

rsio

ns (IN

T2):

a sp

ecifi

ed n

um

ber

of c

on

vers

ion

s (b

its

11-1

5) h

ave

bee

n p

erfo

rmed

.

• A

uto-

Zer

o (INT

3): s

ho

rt c

alib

rati

on

has

bee

n p

erfo

rmed

.

• Fu

ll-C

alib

rati

on (IN

T4):

lon

g ca

libra

tio

n h

as b

een

per

form

ed.

• Pa

use

(INT

5): S

equ

ence

r ar

rive

d a

t a p

ause

sta

te.

• A

ctiv

e (INT

7): C

on

tro

ller

retu

rned

fro

m p

ow

er-d

ow

n to

act

ive

mo

de.

A4A3A2A1

Purpose

TypeD15

D14

D13

D12

D11

D10

D9

D8

D7

D6

D5

D4

D3

D2

D1

D0

479

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

479

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

A/D

, D/A

& I

nter

face

s: E

xam

ples

LM12

L458

(Nat

ion

al S

emic

on

du

cto

rs)

Page 3: Dibble2009 ] Interrupts

484

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

484

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

… a

t th

e sy

stem

inte

rrup

t co

ntro

ller

leve

l

• …

at t

he

op

erat

ing

syst

em le

vel

482

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

482

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

InterruptEnable

R/W

NumberofConversions

Sequencer

INT7

Don’t

INT5

INT4

INT3

INT2

INT1

INT0

eraC

otsserdd

AOFI

Fnoisrevno

Cni

retsigeR

10

01

toGenerateINT2

GenerateINT1

Address

RActualNumberof

ofINST7

“0”

INST5INST4INST3INST2INST1INST0

10

10

InterruptStatus

ConversionResults

Sequencer noitcurtsnI

OFI

Fnoisrevno

Cni

retsigeR

being

Executed

LM12

L458

– D

ata

tran

sfer

opt

ions

Rea

d in

terr

upt

stat

us (i

nte

rru

pt s

tatu

s re

gist

er, 1

5 b

its)

:

• In

dic

ates

the

curr

entl

y ac

tive

inte

rru

pts

• Sh

ow

s th

e ac

tual

nu

mb

er o

f co

nve

rsio

ns

and

the

curr

entl

y p

roce

ssed

inst

ruct

ion

.

Rea

din

g th

is r

egis

ter

rese

ts a

ll st

atu

s b

its

(bit

s 0-

5, 7

).

A4A3A2A1

Purpose

TypeD15

D14

D13

D12

D11

D10

D9

D8

D7

D6

D5

D4

D3

D2

D1

D0

485

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

485

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Syst

em in

terr

up

t co

ntr

olle

r:•

Col

lect

s th

e in

terr

up

t sig

nal

lin

es fr

om

all

man

aged

dev

ices

.

• [I

dent

ifies

the

dev

ice

stat

us]

, if n

ot g

iven

alr

ead

y as

an

inte

rru

pt v

ecto

r in

dex

.

• En

code

s al

l in

terr

up

t sig

nal

s in

to a

co

mm

on

inte

rru

pt v

ecto

r o

r st

atu

s sc

hem

e.

• O

rder

s an

d m

asks

all

inte

rru

pts

acc

ord

ing

to p

rio

rity

leve

ls.

• Tr

igge

rs a

n a

ctu

al C

PU in

terr

up

t.

Th

ree

com

mo

n fo

rms:

• Em

bed

ded

inte

rru

pt c

on

tro

ller a

s an

intr

insi

c p

art o

f a c

om

ple

x m

icro

-co

ntr

olle

r.

• D

edic

ated

inte

rru

pt c

on

tro

ller

for

a se

t of s

imila

r o

r id

enti

cal d

evic

es (e

.g. a

har

d d

isk

arra

y).

• U

niv

ersa

l in

terr

up

t co

ntr

olle

r (u

sual

ly u

nab

le to

fetc

h in

terr

up

t sta

tus

info

rmat

ion

).

483

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

483

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

A/D

, D/A

& I

nter

face

s: E

xam

ples

LM12

L458

(Nat

ion

al S

emic

on

du

cto

rs)

Sin

gle

inte

rru

pt l

ine

Iden

tify

ing

the

actu

al s

ou

rce

req

uir

es a

n a

dd

itio

nal

rea

d c

ycle

Page 4: Dibble2009 ] Interrupts

488

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

488

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

… a

t th

e op

erat

ing

syst

em le

vel

Co

me

on

thre

e le

vels

: I

nter

rupt

ser

vice

rou

tine

s: D

oes

no

t in

volv

e p

roce

sses

.

Com

mun

icat

ing

inte

rrup

ts t

o pr

oces

ses:

Syn

chro

niz

e to

eve

nts

or

dat

a st

ruct

ure

s.

Tra

nsfo

rmin

g in

terr

upts

to

sign

als:

No

tify

the

sch

edu

ler

that

a p

roce

ss is

to b

e ac

tiva

ted

.

486

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

486

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

… a

t th

e op

erat

ing

syst

em le

vel

Co

me

on

thre

e le

vels

: I

nter

rupt

ser

vice

rou

tine

s: D

oes

no

t in

volv

e p

roce

sses

.

Com

mun

icat

ing

inte

rrup

ts t

o pr

oces

ses:

Syn

chro

niz

e to

eve

nts

or

dat

a st

ruct

ure

s.

Tra

nsfo

rmin

g in

terr

upts

to

sign

als:

No

tify

the

sch

edu

ler

that

a p

roce

ss is

to b

e ac

tiva

ted

.

489

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

489

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

t se

rvic

e ro

utin

es(a

vaila

ble

in r

eal-

tim

e o

per

atin

g sy

stem

s an

d la

ngu

ages

on

ly)

Purp

ose

:

• A

llow

full

acce

ss to

the

inte

rru

pt c

on

tro

ller

(in

terr

up

t vec

tors

, pri

ori

ties

) an

d d

evic

e.

• A

ctiv

ate

a ro

uti

ne

in a

pre

dic

tab

le a

mo

un

t of t

ime.

Can

no

t op

erat

e o

n th

e le

vel o

f th

read

s o

r ta

sks!

Lim

itat

ion

s re

gard

ing

the

acce

ssib

ility

of s

om

e O

S-fa

cilit

ies

(tas

k le

vel s

yste

m c

alls

).

487

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

487

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts(a

t th

e o

per

atin

g sy

stem

leve

l)

Co

me

on

thre

e le

vels

:

Inte

rrup

t se

rvic

e ro

utin

es: D

oes

no

t in

volv

e p

roce

sses

.

All

acti

viti

es u

nd

er s

tric

t rea

l-ti

me

con

stra

ints

will

be

add

ress

ed h

ere.

Com

mun

icat

ing

inte

rrup

ts t

o pr

oces

ses:

Syn

chro

niz

e to

eve

nts

or

dat

a st

ruct

ure

s.

Aft

er th

e re

acti

ve p

art o

f th

e re

spo

nse

has

bee

n a

dd

ress

ed,

pro

cess

es m

igh

t nee

d to

be

no

tifi

ed a

bo

ut t

he

curr

ent s

tate

.

Tra

nsfo

rmin

g in

terr

upts

to

sign

als:

No

tify

a p

roce

ss v

ia th

e sc

hed

ule

r.

For

acti

viti

es w

hic

h a

re n

ot u

nd

er r

eal-

tim

e co

nst

rain

ts, t

he

inte

rru

pt

can

be

tran

slat

ed in

to a

sig

nal

(sch

edu

ler-

leve

l eve

nt)

.

Page 5: Dibble2009 ] Interrupts

492

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

492

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

t se

rvic

e ro

utin

es(a

vaila

ble

in r

eal-

tim

e o

per

atin

g sy

stem

s an

d la

ngu

ages

on

ly)

Init

ial r

esp

on

se to

inte

rru

pt (

exec

ute

d b

y C

PU w

ith

ou

t an

y so

ftw

are

invo

lved

):

save

(pu

sh)

esse

ntia

l CP

U re

gist

ers

(IP,

con

diti

on f

lags

, (S

P))

jump

to

the

(vec

tori

zed)

int

erru

pt s

ervi

ce r

outi

ne

Op

tio

nal

/co

mm

on

so

ftw

are

wra

pp

er (a

dd

ed b

y th

e o

s / r

un

tim

e en

viro

nm

ent)

:

save

(pu

sh)

rema

inin

g/ne

eded

CPU

reg

iste

rssa

ve (

push

) st

ack-

fram

e

Exe

cute

inte

rrup

t se

rvic

e ro

utin

e co

de

rest

ore

(pop

) st

ack-

fram

ere

stor

e (p

op)

all

rema

inin

g/to

uche

d CP

U re

gist

ers

Spec

ial C

PU in

stru

ctio

n (a

lso

ad

ded

by

the

os

/ ru

nti

me

envi

ron

men

t):

rest

ore

(RTE

/IRE

T) I

P, c

ondi

tion

fla

gs,

(SP)

Furt

her

det

ail:

Inte

rru

pt m

asks

are

typ

ical

ly r

aise

d to

the

curr

ent l

evel

by

har

dw

are,

yet

can

be

read

just

ed in

sid

e

the

wra

pp

er c

od

e o

r se

rvic

e ro

uti

ne.

it)

Ree

ntr

ant i

nte

rru

pt s

ervi

ce r

ou

tin

es.

490

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

490

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

t se

rvic

e ro

utin

es(a

vaila

ble

in r

eal-

tim

e o

per

atin

g sy

stem

s an

d la

ngu

ages

on

ly)

Som

e V

xWo

rks

OS

entr

ies:

intC

on

nec

tC

on

nec

t a r

ou

tin

e to

an

inte

rru

pt v

ecto

r

intL

evel

Set

Set t

he

inte

rru

pt m

ask

leve

l

IntL

ock

Dis

able

inte

rru

pts

(bes

ides

NM

I)

intU

nlo

ckEn

able

inte

rru

pts

intV

ecB

aseS

etSe

t th

e in

terr

up

t vec

tor

bas

e ad

dre

ss

intV

ecB

aseG

etG

et th

e in

terr

up

t vec

tor

bas

e ad

dre

ss

intV

ecSe

tSe

t an

inte

rru

pt v

ecto

r

intV

ecG

etG

et a

n in

terr

up

t vec

tor

493

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

493

of 7

05 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Proc

esso

r A

rchi

tect

ures

Inte

rrup

ts

• O

ne

or

mu

ltip

le li

nes

wir

ed

dir

ectl

y in

to th

e se

qu

ence

r

Req

uir

ed fo

r: Pr

e-em

ptiv

e sc

hedu

ling,

Tim

er d

rive

n ac

tion

s,

Tran

sien

t ha

rdw

are

inte

ract

ions

, …

Usu

ally

pre

ced

ed b

y an

ext

ern

al lo

gic

(“in

terr

up

t co

ntr

olle

r”) w

hic

h a

ccu

mu

-la

tes

and

en

cod

es a

ll ex

tern

al r

equ

ests

.

On

inte

rru

pt (

if u

nm

aske

d):

• C

PU s

top

s n

orm

al s

equ

ence

r fl

ow

.

• Lo

oku

p o

f in

terr

up

t han

dle

r’s a

dd

ress

• C

urr

ent I

P an

d s

tate

pu

shed

on

to s

tack

.

• IP

set

to in

terr

up

t han

dle

r.

A

LU

Memory

Sequ

ence

rD

ecod

er

Cod

e m

anag

emen

t

Reg

iste

rs

IP SP

Flag

s

Dat

a m

anag

emen

t

Int.

491

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

491

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

t se

rvic

e ro

utin

es(a

vaila

ble

in r

eal-

tim

e o

per

atin

g sy

stem

s an

d la

ngu

ages

on

ly)

Init

ial r

esp

on

se to

inte

rru

pt (

exec

ute

d b

y C

PU w

ith

ou

t an

y so

ftw

are

invo

lved

):

save

(pu

sh)

esse

ntia

l CP

U re

gist

ers

(IP,

con

diti

on f

lags

, (S

P))

jump

to

the

(vec

tori

zed)

int

erru

pt s

ervi

ce r

outi

ne

Op

tio

nal

/co

mm

on

so

ftw

are

wra

pp

er (a

dd

ed b

y th

e o

s / r

un

tim

e en

viro

nm

ent)

:

save

(pu

sh)

rema

inin

g/ne

eded

CPU

reg

iste

rssa

ve (

push

) st

ack-

fram

e

Exe

cute

inte

rrup

t se

rvic

e ro

utin

e co

de

rest

ore

(pop

) st

ack-

fram

ere

stor

e (p

op)

all

rema

inin

g/to

uche

d CP

U re

gist

ers

Spec

ial C

PU in

stru

ctio

n (a

lso

ad

ded

by

the

os

/ ru

nti

me

envi

ron

men

t):

rest

ore

(RTE

/IRE

T) I

P, c

ondi

tion

fla

gs,

(SP)

Page 6: Dibble2009 ] Interrupts

496

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

496

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

s

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Regi

ster

s

Loca

l va

riab

les

494

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

494

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PC

SP

497

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

497

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Regi

ster

s

Loca

l va

riab

les

495

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

495

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

SP

…Pr

ogra

m

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Page 7: Dibble2009 ] Interrupts

500

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

500

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

esPo

p re

gist

ers

Retu

rn f

rom

inte

rrup

t

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PC

498

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

498

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

es

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Regi

ster

s

501

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

501

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PC

SP

499

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

499

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

esPo

p re

gist

ers

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Page 8: Dibble2009 ] Interrupts

504

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

504

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

)Pu

sh o

ther

reg

iste

rsDe

clar

e lo

cal

vari

able

s

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Regi

ster

s

Loca

l va

riab

les

Scra

tch

regi

ster

s

502

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

502

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

…Pr

ogra

m

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Scra

tch

regi

ster

s

SP

LR is

load

ed w

ith

a s

pec

ial v

alu

e

505

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

505

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

Regi

ster

s

Loca

l va

riab

les

Scra

tch

regi

ster

s

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

) Pu

sh o

ther

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

PC

503

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

503

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

)

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PC

Scra

tch

regi

ster

s

FP

Page 9: Dibble2009 ] Interrupts

508

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

508

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

) Pu

sh o

ther

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

esPo

p ot

her

regi

ster

sRe

turn

("b

x lr

")

PC

SP FP

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

506

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

506

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

Scra

tch

regi

ster

s

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

) Pu

sh o

ther

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

esPo

p ot

her

regi

ster

sPC

509

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

509

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t ha

ndle

r

Thin

gs t

o c

ons

ider

Inte

rru

pt h

and

ler

cod

e ca

n b

e in

terr

up

ted

as

wel

l.

Are

yo

u a

llow

ing

to in

terr

up

t an

inte

rru

pt h

and

ler

wit

h a

n

inte

rru

pt o

n th

e sa

me

pri

ori

ty le

vel (

e.g.

the

sam

e in

terr

up

t)?

Can

yo

u o

verr

un

a s

tack

wit

h in

terr

up

t han

dle

rs?

507

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

507

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

t pr

oces

sing

Stac

k

Cod

e

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Prog

ram

Inte

rrup

t han

dler

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

Scra

tch

regi

ster

s

Clea

r in

terr

upt

flag

(Adj

ust

prio

riti

es)

(Re-

enab

le i

nter

rupt

) Pu

sh o

ther

reg

iste

rsDe

clar

e lo

cal

vari

able

sRu

n ha

ndle

r co

de

..

do s

ome

I/O

..

.

. or

run

som

e ti

me

crit

ical

cod

e ..

Remo

ve l

ocal

var

iabl

esPo

p ot

her

regi

ster

sRe

turn

("b

x lr

")PC

Page 10: Dibble2009 ] Interrupts

512

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

512

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

SP

…Pr

oces

s 1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

SP

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

PCB

……

PCFlags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PC

510

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

510

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Mul

tipl

e pr

ogra

ms

If w

e ca

n e

xecu

te in

terr

up

t han

dle

r co

de

“co

ncu

rren

tly”

to o

ur “

mai

n”

pro

gram

:

Can

we

then

als

o h

ave

mu

ltip

le “

mai

n”

pro

gram

s?

513

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

513

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

s

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

SP

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

PCB

……

PCFl

ags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

511

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

511

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PC

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

SP

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PID

PCB

……

SP

Page 11: Dibble2009 ] Interrupts

516

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

516

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Sche

dule

rLo

ad S

P fr

om P

CB 2

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PCFlags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

SP

514

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

514

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

SP

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PCFlags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

517

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

517

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Sche

dule

rLo

ad S

P fr

om P

CB 2

Remo

ve l

ocal

var

iabl

es

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PCFl

ags

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

sSP

Reg

iste

rs

515

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

515

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

SP

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Sche

dule

r

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

PID

SP

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PCFl

ags

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

Page 12: Dibble2009 ] Interrupts

520

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

520

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

… a

t th

e op

erat

ing

syst

em le

vel

Co

me

on

thre

e le

vels

: I

nter

rupt

ser

vice

rou

tine

s: D

oes

no

t in

volv

e p

roce

sses

.

Com

mun

icat

ing

inte

rrup

ts t

o pr

oces

ses:

Syn

chro

niz

e to

eve

nts

or

dat

a st

ruct

ure

s.

Tra

nsfo

rmin

g in

terr

upts

to

sign

als:

No

tify

the

sch

edu

ler

that

a p

roce

ss is

to b

e ac

tiva

ted

.

518

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

518

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Sche

dule

rLo

ad S

P fr

om P

CB 2

Remo

ve l

ocal

var

iabl

esPo

p re

gist

ers

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

PID

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PCFlags

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

SP

521

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

521

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Co

mm

unic

atin

g in

terr

upts

to

pro

cess

esIn

terr

up

t ser

vice

ro

uti

ne

to ta

sk c

om

mu

nic

atio

n m

eth

od

s:

• Sh

ared

mem

ory

and

ring

buf

fers

: m

ost

low

leve

l co

mm

un

icat

ion

sch

eme.

• Se

map

hore

: tri

gger

a s

emap

ho

re, w

her

e a

task

has

bee

n b

lock

ed b

efo

re.

• M

onit

ors:

free

a ta

sk, w

hic

h is

blo

cked

at a

mo

nit

or

entr

y (s

tan

dar

d A

da-

met

ho

d: p

rote

cted

ob

ject

).

• M

essa

ge q

ueue

s: Se

nd

asy

nch

ron

ou

s m

essa

ges

to a

task

(if q

ueu

e is

no

t fu

ll).

• Pi

pes:

Wri

te to

a p

ipe

(if p

ipe

is n

ot f

ull)

.

• Si

gnal

s: in

dic

ate

an a

syn

chro

no

us

task

sw

itch

to th

e sc

hed

ule

r.

In a

ll ca

ses:

Th

e in

terr

up

t ser

vice

rou

tin

e ca

nn

ot b

lock

!

519

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

519

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Con

text

sw

itch

Cod

eSt

ack

Stac

kC

ode

kd

Cd

k

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

Bas

e

Push

reg

iste

rsDe

clar

e lo

cal

vari

able

sSt

ore

SP t

o PC

B 1

Sche

dule

rLo

ad S

P fr

om P

CB 2

Remo

ve l

ocal

var

iabl

esPo

p re

gist

ers

Retu

rn f

rom

inte

rrup

t

Proc

ess

1

Dis

patc

her

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

Ret

urn

addr

ess

Con

text

Para

met

ers

Glo

bal v

aria

bles

Loca

l var

iabl

es

Ret

urn

addr

ess

Con

text

Para

met

ers

Loca

l var

iabl

es

FP Bas

e

PID

PCB

Proc

ess

2 ……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

……

PCFl

ags

PID

SP

PCB

……

PC

Reg

iste

rs

Co

nte

xt-

swit

ch-

vari

able

s

SP

Page 13: Dibble2009 ] Interrupts

524

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

524

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Sig

nals

• Si

gnal

s ar

e o

rigi

nal

ly a

pro

cess

-lev

el s

ynch

ron

izat

ion

/ te

rmin

atio

n m

eth

od

(‘ki

ll’) y

et a

re c

urr

entl

y b

een

use

d fo

r ev

eryt

hin

g

fro

m h

ard

war

e-in

terr

up

ts a

nd

tim

ers

to a

syn

chro

no

us

task

mes

sagi

ng.

• Si

gnal

s ar

e p

asse

d th

rou

gh th

e sy

stem

wid

e sc

hed

ule

r.

• Si

gnal

s ca

rry

littl

e in

form

atio

n a

s to

wh

at h

app

ened

.

Un

pre

dic

tab

le ‘w

ork

-aro

un

d’ f

or

mis

sin

g d

irec

t h

ard

war

e in

terr

up

t pro

pag

atio

n.

Mak

e su

re th

at y

ou

un

der

stan

d th

e at

tach

ed s

trin

gs, b

efo

re e

mp

loyi

ng

any

sign

als.

522

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

522

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Inte

rru

pt c

on

tro

l …

• …

at t

he

ind

ivid

ual

dev

ice

leve

l

• …

at t

he

syst

em in

terr

up

t co

ntr

olle

r le

vel

… a

t th

e op

erat

ing

syst

em le

vel

Co

me

on

thre

e le

vels

: I

nter

rupt

ser

vice

rou

tine

s: D

oes

no

t in

volv

e p

roce

sses

.

Com

mun

icat

ing

inte

rrup

ts t

o pr

oces

ses:

Syn

chro

niz

e to

eve

nts

or

dat

a st

ruct

ure

s.

Tra

nsfo

rmin

g in

terr

upts

to

sign

als:

No

tify

the

sch

edu

ler

that

a p

roce

ss is

to b

e ac

tiva

ted

.

525

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

525

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

Wis

h li

st fo

r ex

cep

tio

n h

and

ling

in r

eal-

tim

e p

rogr

amm

ing

lan

guag

es:

1.

Exce

pti

on

faci

litie

s sh

ou

ld

no

t ob

scu

re th

e u

nd

erst

and

ing

of t

he

no

rmal

, exc

epti

on

-fre

e co

ntr

ol fl

ow

.

2. E

xcep

tio

n fa

cilit

ies

sho

uld

pro

du

ce

no

or m

inim

al r

un

tim

e o

verh

ead

, un

til a

n e

xcep

tio

n a

ctu

ally

occ

urs

.

3. E

xcep

tio

ns

sho

uld

pro

du

ce p

red

icta

ble

ru

n-t

ime

ove

rhea

d w

hen

an

exc

epti

on

occ

urs

.

4. E

xcep

tio

ns

ind

icat

ed b

y th

e ru

n-t

ime

envi

ron

men

t an

d b

y th

e p

rogr

am it

self

sh

ou

ld b

e tr

eate

d u

nif

orm

ly.

5. T

he

exce

pti

on

mec

han

ism

sh

ou

ld b

e ap

plic

able

to a

syn

chro

no

us

and

syn

chro

no

us

exce

pti

on

s (

mig

ht b

e h

ard

to a

chie

ve w

ith

res

pec

t to

wis

h 3

).

6. T

he

exce

pti

on

mec

han

ism

sh

ou

ld a

llow

for

app

rop

riat

e re

cove

ries

(s

up

ply

su

ffi c

ien

t in

form

atio

n a

nd

ap

pro

pri

ate

re-e

ntr

y p

oss

ibili

ties

).

523

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

523

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m c

lose

to

hard

war

e

Inte

rrup

ts

Sig

nals

POSI

X 1

003.

1bB

SD-U

NIX

sign

alsi

gnal

Spec

ify

the

han

dle

r as

soci

ated

wit

h a

sig

nal

siga

ctio

nsi

gvec

Exam

ine

or

set t

he

sign

al h

and

ler

for

a si

gnal

kill

kill

Sen

d a

sig

nal

(ove

rwri

te a

ll o

ther

pen

din

g si

gnal

s)

sigq

ueu

eSe

nd

a q

ueu

ed s

ign

al

sigs

usp

end

pau

seW

ait f

or

a si

gnal

sigw

aiti

nfo

, sig

tim

edw

ait

Wai

t fo

r a

sign

al, b

ut d

o n

ot i

nvo

ke th

e h

and

ler

sige

mp

tyse

tsi

gset

mas

kM

anip

ula

te a

nd

set

the

mas

k o

f blo

cked

sig

nal

s

sigp

rocm

ask

sigb

lock

Ad

d to

a s

et o

f blo

cked

sig

nal

s

Page 14: Dibble2009 ] Interrupts

528

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

528

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(Ass

emb

ler

leve

l)

Pro

vid

e a

jum

p ta

ble

an

d m

anip

ula

te th

e re

turn

ad

dre

ss o

n th

e st

ack:

Cal

ler:

j

sr p

c, P

RINT

_CHA

R

jmp

IO_

ERRO

R

jmp

DEV

ICE_

NOT_

ENAB

LED

#

nor

mal

proc

essi

ng

Sub

rou

tin

e:

% i

ndic

ate

an e

xcep

tion

:

%

in

crem

ent

the

retu

rn a

ddre

ss o

n th

e st

ack

%

by t

he e

xcep

tion

num

ber

to e

mplo

y th

e ca

ller

-pro

vide

d ex

cept

ion

hand

ling

%

ind

icat

e no

rmal

ope

rati

on:

%

incr

emen

t th

e re

turn

add

ress

on

the

stac

k by

the

max

. ex

cept

ion

numb

er +

1

526

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

526

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(His

tori

c ex

cep

tio

n h

and

ling

met

ho

ds)

Use

an

‘un

usu

al r

etu

rn v

alu

e’ a

nd

a g

lob

al v

aria

ble

co

nve

nti

on

:

if (

func

tion

_cal

l (p

aram

eter

s) <

NOR

MAL_

RETU

RN_V

ALUE

) {

if

errn

o ==

SOM

E_KN

OWN_

ERRO

R {

/*

rea

ct t

o th

e kn

own

erro

r co

ndit

ion

*/

} e

lse

{

/* t

ry t

o im

prov

ise

some

thin

g

*/

}

} el

se {

norm

al c

ontr

ol f

low

};

Infl

exi

ble

(exc

epti

on

s fr

om

the

envi

ron

men

t can

no

t be

det

ecte

d).

Err

or-p

rone

(lo

ts o

f ch

ance

s to

forg

et c

hec

kin

g o

r to

use

the

wro

ng

con

stan

ts).

Obs

truc

tive

(all

frag

men

ts a

re c

om

min

gled

).

529

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

529

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(His

tori

c la

ngu

ages

)

Emu

late

exc

epti

on

han

dlin

g m

eth

od

s b

y re

turn

ing

a:

• Ju

mp

labe

l fo

r u

nre

cove

rab

le e

xcep

tio

ns.

• Pr

oced

ure

vari

able

for

reco

vera

ble

exc

epti

on

s.

Ou

tdat

ed a

s al

l cu

rren

t rea

l-ti

me

pro

gram

min

g la

ngu

ages

p

rovi

de

som

e in

trin

sic

mea

ns

of e

xcep

tio

n h

and

ling.

All

exce

pti

on

han

dlin

g m

eth

od

s u

p to

her

e o

per

ate

on

su

bro

uti

ne

leve

l, w

hile

all

curr

ent d

ay e

xcep

tio

n h

and

ling

met

ho

ds

op

erat

e o

n b

lock

leve

l.

527

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

527

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(His

tori

c ex

cep

tio

n h

and

ling

met

ho

ds)

Use

an

‘un

usu

al r

etu

rn v

alu

e’ a

nd

a g

lob

al v

aria

ble

co

nve

nti

on

:

if (

func

tion

_cal

l (p

aram

eter

s) <

NOR

MAL_

RETU

RN_V

ALUE

) {

if

errn

o ==

SOM

E_KN

OWN_

ERRO

R {

/*

rea

ct t

o th

e kn

own

erro

r co

ndit

ion

*/

} e

lse

{

/* t

ry t

o im

prov

ise

some

thin

g

*/

}

} el

se {

norm

al c

ontr

ol f

low

};

Infl

exi

ble

(exc

epti

on

s fr

om

the

envi

ron

men

t can

no

t be

det

ecte

d).

Err

or-p

rone

(lo

ts o

f ch

ance

s to

forg

et c

hec

kin

g o

r to

use

the

wro

ng

con

stan

ts).

Obs

truc

tive

(all

frag

men

ts a

re c

om

min

gled

).

so

/

p(H

isto

ric

exce

pti

on

han

dlin

g m

eth

od

s)

sual

ret

urn

val

ue’

an

d a

glo

bal

var

iab

le c

on

ven

tio

n:

ion_

call

(pa

rame

ters

) <

NORM

AL_R

ETUR

N_VA

LUE)

{no

==

SOME

_KNO

WN_E

RROR

{re

act

to t

he k

nown

err

or c

ondi

tion

*{ try

to i

mpro

vise

som

ethi

ng

*

/

l co

ntro

l fl

o

ble

(exc

epti

on

sfr

om

the

envi

ron

men

tcan

no

tbe

det

ecte

d).

ing

{UUUEEEE

{{{

*/********//////// ****//////////

ttioo

tio

tio

tio

tio

titiiii

L_R_R_R_R_R_R_R_R_R_

tOROROROR rrrrrrrrrrrrororor

ror

ror

ror

ror

ror

ror

ror

rccococococoo

thi

thi

thi

thi

thi

thi

thi

thi

thihing

me

sose

se

se

se

s ssssssomomomomomomomomomomo

pr i

mproprororororororooovvvvvvvivi

cccccccccononononnnnnnnn

oooooooolololol f

loooooowowowowow

Page 15: Dibble2009 ] Interrupts

532

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

532

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

form

s

fro

m:

Ru

n-t

ime

envi

ron

men

tA

pp

licat

ion

rais

ed: Sy

nch

ron

ou

sly

Asy

nch

ron

ou

sly

530

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

530

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(Ear

ly h

igh

leve

l co

nst

ruct

s in

no

t-fu

lly-s

cop

ed la

ngu

ages

)

PL/I

(IB

M, 1

960’

s): E

xcep

tio

n h

and

ling

rou

tin

es a

re “

regi

ster

ed g

lob

ally

” b

y ru

nn

ing

ove

r an

“On

” co

de

sect

ion

:

On <

exce

ptio

n-na

me>

begi

n;

(…

stat

emen

ts …

)

[<l

ong

jump

to

cont

inua

tion

cod

e>]

e

nd;

Exce

pti

on

han

dlin

g ro

uti

nes

are

rep

lace

d b

y ru

nn

ing

ove

r a

new

“On

” co

de

sect

ion

for

the

sam

e ex

cep

tio

n-n

ame.

Exc

epti

on

han

dlin

g is

co

ncl

ud

ed b

y ei

ther

:

• R

un

nin

g o

ver

the

“ end

” st

atem

ent a

nd

res

um

e ex

ecu

tio

n w

ith

the

stat

emen

t w

hic

h fo

llow

s “i

mm

edia

tely

aft

er”

the

on

e w

hic

h r

aise

d th

e ex

cep

tio

n.

• Ex

ecu

tin

g a

lon

g-ju

mp

to a

nyw

her

e.

C

on

tin

uin

g in

the

cod

e-sc

op

e o

f/af

ter

the

exce

pti

on

han

dle

r w

as n

ot c

on

sid

ered

.

533

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

533

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

form

s

Ad

a

fro

m:

Ru

n-t

ime

envi

ron

men

tA

pp

licat

ion

rais

ed: Sy

nch

ron

ou

sly

Exce

pti

on

s

Asy

nch

ron

ou

sly

Inte

rru

pt h

and

ler

Asy

nch

ron

ou

s tr

ansf

er o

f co

ntr

ol

531

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

531

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

ons

(Ear

ly h

igh

leve

l co

nst

ruct

s in

no

t-fu

lly-s

cop

ed la

ngu

ages

)

PL/I

(IB

M, 1

960’

s): E

xcep

tio

n h

and

ling

rou

tin

es a

re “

regi

ster

ed g

lob

ally

” b

y ru

nn

ing

ove

r an

“On

” co

de

sect

ion

:

On <

exce

ptio

n-na

me>

begi

n;

(…

stat

emen

ts …

)

[<l

ong

jump

to

cont

inua

tion

cod

e>]

e

nd;

Exce

pti

on

han

dlin

g ro

uti

nes

are

rep

lace

d b

y ru

nn

ing

ove

r a

new

“On

” co

de

sect

ion

for

the

sam

e ex

cep

tio

n-n

ame.

Exc

epti

on

han

dlin

g is

co

ncl

ud

ed b

y ei

ther

:

• R

un

nin

g o

ver

the

“ end

” st

atem

ent a

nd

res

um

e ex

ecu

tio

n w

ith

the

stat

emen

t w

hic

h fo

llow

s “i

mm

edia

tely

aft

er”

the

on

e w

hic

h r

aise

d th

e ex

cep

tio

n.

• Ex

ecu

tin

g a

lon

g-ju

mp

to a

nyw

her

e.

C

on

tin

uin

g in

the

cod

e-sc

op

e o

f/af

ter

the

exce

pti

on

han

dle

r w

as n

ot c

on

sid

ered

.

g .g o

ver

a .

Exce

pti

on

han

dlin

g is

m

essy

/har

d/im

po

ssib

le in

:

• W

eakl

y/n

ot s

cop

ed la

ngu

ages

• M

acro

-ass

emb

ler

leve

l lan

guag

es

• St

rict

fun

ctio

nal

lan

guag

es

Page 16: Dibble2009 ] Interrupts

536

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

536

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

gran

ular

ity

(blo

ck le

vel)

Ad

a: begi

n

--

do s

omet

hing

dan

gero

us

exce

ptio

n

whe

n E:

Con

stra

int_

Erro

r =>

Dea

l wi

th i

t;

end;

or

in R

eal-

tim

e Ja

va

try

{

//

do s

omet

hing

dan

gero

us} ca

tch

(Exc

epti

onTy

pe e

) {

//

hand

le e

xcep

tion

e

}

Han

dle

a s

pec

ifi c

exce

pti

on

at t

he

end

of a

defi

ned

co

de

blo

ck

534

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

534

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

form

s

Real

-tim

e Ja

va

fro

m:

Ru

n-t

ime

envi

ron

men

tA

pp

licat

ion

rais

ed: Sy

nch

ron

ou

sly

Exce

pti

on

s

Asy

nch

ron

ou

sly

Asy

nch

ron

ou

s ex

cep

tio

ns

537

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

537

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

gran

ular

ity

(blo

ck le

vel)

Ad

a: begi

n

--

do s

omet

hing

dan

gero

us

exce

ptio

n

whe

n E:

oth

ers

=> D

eal

with

it;

end;

or

in R

eal-

tim

e Ja

va

try

{

//

do s

omet

hing

dan

gero

us} ca

tch

(Exc

epti

on e

) {

//

hand

le e

xcep

tion

e

}

Han

dle

an

y ex

cep

tio

n a

t th

e en

d o

f a d

efi n

ed c

od

e b

lock

Can

be

com

bin

ed: h

and

le s

om

e sp

ecifi

c ex

cep

tio

ns

fi rs

t yet

als

o

pro

vid

e co

de

for “

oth

er”

exce

pti

on

s.

535

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

535

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

form

s

POSI

X

fro

m:

Ru

n-t

ime

envi

ron

men

tA

pp

licat

ion

rais

ed: Sy

nch

ron

ou

sly

N/A

(Glo

bal

var

iab

les)

Asy

nch

ron

ou

sly

(Sig

nal

s)

Page 17: Dibble2009 ] Interrupts

540

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

540

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

gran

ular

ity

(sta

tem

ent l

evel

)

e.g

. su

pp

ort

ed in

CH

ILL

A

: t

empe

ratu

re;

B, C

: i

nteg

er;

begi

n

A

:=

B +

C on

(ov

erfl

ow )

: …;

(ra

ngef

ail)

: …;

els

e …;

en

d;

…en

d;

All

exce

pti

on

s in

CH

ILL

nee

d to

be

han

dle

d

Exce

pti

on

s ar

e n

ot p

rop

agat

ed

Han

dle

rs a

re d

eter

min

ed

at c

om

pile

tim

e

538

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

538

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

gran

ular

ity

(blo

ck s

ize

larg

e)

decl

are

s

ubty

pe T

empe

ratu

re i

s In

tege

r ra

nge

0 ..

100

;

sub

type

Pre

ssur

e

is

Inte

ger

rang

e 0

..

50;

sub

type

Flo

w

is

Inte

ger

rang

e 0

.. 2

00;

begi

n

--

read

tem

pera

ture

sen

sor

and

calc

ulat

e it

s va

lue

-

- re

ad p

ress

ure

sens

or a

nd c

alcu

late

its

val

ue

--

read

flo

w se

nsor

and

cal

cula

te i

ts v

alue

-

- ad

just

tem

pera

ture

, pr

essu

re a

nd f

low

-

- ac

cord

ing

to r

equi

reme

nts

exce

ptio

n

--

hand

ler

for

Cons

trai

nt_E

rror

end;

Mig

ht b

e to

o u

nsp

ecifi

c?

541

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

541

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

attr

ibut

es

Inst

ead

of c

atch

ing

exce

pti

on

s af

ter

each

sta

tem

ent:

Exc

epti

on

s ca

n c

arry

furt

her

att

rib

ute

s ab

ou

t th

eir

sou

rce.

Thu

s ex

cep

tio

n h

and

lers

can

be

furt

her

aw

ay fr

om

the

sou

rce

(an

d

few

er in

nu

mb

ers)

yet

sti

ll b

e ab

le to

iden

tify

the

fau

lt.

Rea

l-ti

me

Java

: Ex

cep

tio

n c

an c

arry

an

y n

um

ber

of u

ser

defi

ned

par

amet

ers.

Ad

a:

The

envi

ron

men

t au

tom

atic

ally

att

ach

es a

dd

itio

nal

info

rmat

ion

to e

xcep

tio

ns,

w

hic

h a

re in

dic

atin

g th

e p

osi

tio

n o

f th

e ex

cep

tio

n-o

ccu

rren

ce a

nd

oth

er o

bse

rved

co

nd

itio

ns

(im

ple

men

tati

on

dep

end

ent,

infl

exib

le, u

sefu

l fo

r d

ebu

ggin

g).

539

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

539

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

gran

ular

ity

(blo

ck s

ize

sm

all)

begi

n

beg

in

--

rea

d te

mper

atur

e se

nsor

and

cal

cula

te i

ts v

alue

e

xcep

tion

--

han

dler

for

Con

stra

int_

Erro

r

end

;

beg

in

--

rea

d pr

essu

re s

enso

r an

d ca

lcul

ate

its

valu

e

e

xcep

tion

--

han

dler

for

Con

stra

int_

Erro

r

end

;

…ex

cept

ion

-

- ha

ndle

r fo

r Co

nstr

aint

_Err

oren

d;

Mig

ht b

eco

me

too

clu

tter

ed?

Page 18: Dibble2009 ] Interrupts

544

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

544

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

reco

very

Res

umpt

ion-

mod

el (o

ffer

ed in

: Pea

rl, M

esa)

:

1.

Fin

d a

n e

xcep

tio

n h

and

ler.

2. E

xecu

te th

e ex

cep

tio

n h

and

ler

(an

d p

ote

nti

ally

rai

se a

no

ther

exc

epti

on

).

3. A

fter

co

mp

leti

on

of t

he

exce

pti

on

han

dle

r (a

nd

po

ssib

ly o

ther

han

dle

rs):

retu

rn to

the

invo

ker

and

try

resu

me

pro

cess

ing

“as

if n

oth

ing

hap

pen

ed”.

Feat

ure

:•

In c

ase

of a

n a

syn

chro

no

us

exce

pti

on

, th

ere

is li

ttle

imp

act o

n th

e cu

rren

t co

ntr

ol fl

ow

.

Pro

ble

ms:

• So

me

erro

rs c

ann

ot b

e ‘r

epai

red

’ (es

pec

ially

all

tim

ing

rela

ted

err

ors

) in

fi n

ite

recu

rsio

n.

• Ex

cep

tio

ns

can

be

rais

ed in

the

mid

dle

of e

valu

atio

ns,

wh

ich

will

be

har

d to

res

tore

.

542

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

542

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

sco

pe

and

pro

pag

atio

n

1. A

ll pr

oced

ures

and

func

tion

s de

clar

e ev

ery

pote

ntia

lly r

aise

d ex

cept

ion

(req

ues

ted

in C

HIL

L, r

equ

este

d in

Rea

l-ti

me

Java

for

use

r d

efi n

ed e

xcep

tio

ns)

If a

n a

pp

rop

riat

e ex

cep

tio

n h

and

ler

can

no

t be

det

erm

ined

at c

om

pile

-tim

e: E

ith

er …

… tr

eat i

t as

a p

rogr

amm

er e

rro

r an

d s

top

co

mp

ilati

on

( C

HIL

L)

or

… p

rop

agat

e th

e ex

cep

tio

n a

t ru

n-t

ime

ou

tsid

e it

s st

atic

sco

pe

( R

eal-

tim

e Ja

va)

2. E

xcep

tion

s ar

e de

clar

ed fo

r w

hole

mod

ules

— n

ot s

pec

ifi ca

lly p

er m

eth

od

(Ad

a):

Th

e h

and

ler

is d

eter

min

ed a

t ru

n-t

ime

in a

ny

case

(e

ith

er b

y p

rop

agat

ion

or

in th

e st

atic

sco

pe)

.

545

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

545

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

reco

very

Blo

ck-R

esum

ptio

n-m

odel

(off

ered

in: E

iffe

l):

1.

Fin

d a

n e

xcep

tio

n h

and

ler.

2. E

xecu

te th

e ex

cep

tio

n h

and

ler

(an

d p

ote

nti

ally

rai

se a

no

ther

exc

epti

on

).

3. A

fter

co

mp

leti

on

of t

he

exce

pti

on

han

dle

r (a

nd

po

ssib

ly o

ther

han

dle

rs):

retu

rn to

the

beg

inn

ing

of t

he

cod

e b

lock

in w

hic

h th

e ex

cep

tio

n o

ccu

rred

.

Feat

ure

:•

Co

ntr

acts

are

en

forc

ed.

Pro

ble

ms:

• Lo

cal v

aria

ble

s m

ust

no

t be

re-i

nit

ializ

ed (p

ote

nti

ally

co

nfu

sin

g st

ate

of t

he

syst

em).

• Th

e co

de

nee

ds

to b

e aw

are

of a

ll co

mb

inat

ion

s o

f hal

f-ev

alu

ated

pro

cess

ing

stat

es.

• Tr

yin

g th

e sa

me

met

ho

d a

gain

(an

d a

gain

) is

usu

ally

no

t a s

uit

able

way

for

real

-tim

e sy

stem

s.

543

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

543

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

(Unc

augh

t) e

xcep

tio

n p

rop

agat

ion

If th

e h

and

ler

can

nei

ther

be

fou

nd

by

pro

pag

atio

n n

or

in th

e st

atic

co

nte

xt o

f a ta

sk:

Sto

p th

e sp

ecifi

c ta

sk —

exc

epti

on

s ar

e n

ot p

rop

agat

ed to

the

par

ent-

pro

cess

(Ad

a).

or

Pro

pag

ate

the

exce

pti

on

to th

e p

aren

t-ta

sk

(an

d p

ote

nti

ally

sta

ll th

e w

ho

le s

yste

m).

Co

mm

on

‘saf

ety-

line’

for

each

pro

cess

:

Use

a ‘c

atch

all’

-han

dle

r (p

oss

ible

in A

da

and

Rea

l-ti

me

Java

) at t

he

hig

hes

t tas

k le

vel.

co

mm

on

rea

ctio

n: P

AN

IC!

Page 19: Dibble2009 ] Interrupts

548

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

548

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Mul

ti-s

tage

exc

epti

on

hand

ling

Ass

um

ing

a b

lock

is h

old

ing

a n

um

ber

of l

oca

l res

ou

rces

, ye

t occ

urr

ing

exce

pti

on

s n

eed

to b

e h

and

led

at t

he

calle

r le

vel:

proc

edur

e Al

loca

te (

Numb

er :

Dev

ices

) is

b

egin

--

req

uest

eac

h de

vice

be

allo

cate

d in

tur

n

--

not

ing

whic

h re

ques

ts a

re g

rant

ed

e

xcep

tion

wh

en o

ther

s =>

--

e.g.

dea

lloc

ate

thos

e de

vice

s al

loca

ted

rai

se;

-- r

e-ra

ise

the

exce

ptio

n

e

nd A

lloc

ate;

Hel

pfu

l to

kee

p a

co

nsi

sten

t sys

tem

-sta

te a

nd

to a

void

dea

d-l

ock

s (a

ll-o

r-n

oth

ing

allo

cati

on

).

… in

Rea

l-ti

me

Java

: th

e ‘fi

nal

ly’ c

lau

se ta

kes

care

of b

lock

co

nsi

sten

t fi n

aliz

atio

n.

546

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

546

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

reco

very

Term

inat

ion-

mod

el (o

nly

mo

del

in: A

da,

Rea

l-ti

me

Java

; off

ered

in: P

earl

, Mes

a):

1.

Fin

d a

n e

xcep

tio

n h

and

ler.

2. E

xecu

te th

e ex

cep

tio

n h

and

ler

(an

d p

ote

nti

ally

rai

se a

no

ther

exc

epti

on

).

3. A

fter

co

mp

leti

on

of t

he

exce

pti

on

han

dle

r (a

nd

po

ssib

ly o

ther

han

dle

rs):

retu

rn to

the

sco

pe

aro

un

d th

e fi

nal

exc

epti

on

han

dle

r.

Feat

ure

:•

The

met

ho

d o

f ch

oic

e, if

exc

epti

on

s im

ply

that

the

op

erat

ion

was

no

t su

cces

sfu

l an

d s

om

eth

ing

else

nee

d to

be

do

ne

no

w

rea

l-ti

me

syst

ems.

Pro

ble

ms:

• Th

ere

is n

o w

ay to

co

nti

nu

e ex

ecu

tio

n “

as if

no

thin

g h

app

ened

” (m

igh

t be

use

ful i

n c

ase

that

the

exce

pti

on

co

uld

be

iden

tifi

ed a

s o

f min

or

imp

act)

.

549

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

549

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

hand

ling

issu

es(A

da

& R

eal-

tim

e Ja

va)

(Ad

a) E

xcep

tio

ns

are

dec

lare

d a

t pac

kage

leve

l, i.e

. it i

s u

ncl

ear,

wh

ich

fun

ctio

ns

may

rai

se w

hic

h e

xcep

tio

ns!

(Ad

a) E

xcep

tio

ns

may

be

pro

pag

ated

ou

tsid

e th

e sc

op

e o

f th

eir

dec

lara

tio

n,

i.e. o

nly

‘wh

en o

ther

s’ c

an h

and

le th

em.

(Ad

a, R

eal-

tim

e Ja

va) E

xcep

tio

n in

task

bo

die

s ar

e n

ot p

rop

agat

ed to

the

par

ent t

ask

i.e. i

f th

ere

cou

ld n

ot b

e an

y h

and

ler

iden

tifi

ed in

the

task

, th

e ta

sk w

ill ‘d

ie s

ilen

tly’

.

(Ad

a, R

eal-

tim

e Ja

va) E

xcep

tio

n in

task

dec

lara

tio

ns

are

alw

ays

pro

pag

ated

to th

e p

aren

t tas

k.

(Ad

a) E

xcep

tio

ns

in ta

sk re

nd

ezvo

us,

wh

ich

are

no

t han

dle

d in

the

acce

pt s

tate

men

t, ar

e p

rop

agat

ed to

bo

th in

volv

ed ta

sks.

Mo

st e

xpen

sive

un

cau

ght e

xcep

tio

n u

p to

no

w:

Hal

f a b

illio

n d

olla

rs (m

aid

en c

rash

of A

rian

e 5,

‘96)

547

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

547

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

reco

very

Hyb

rid-

mod

el (o

ffer

ed in

: Mes

a):

1.

Fin

d a

n e

xcep

tio

n h

and

ler.

2. E

xecu

te th

e ex

cep

tio

n h

and

ler

(an

d p

ote

nti

ally

rai

se a

no

ther

exc

epti

on

).

3. A

fter

co

mp

leti

on

of t

he

exce

pti

on

han

dle

r (a

nd

po

ssib

ly o

ther

han

dle

rs):

the

exce

pti

on

han

dle

r ca

n d

ecid

e w

het

her

to te

rmin

ate

or

to r

esu

me.

Page 20: Dibble2009 ] Interrupts

552

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

552

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

hand

ling

in C

/ P

OSI

X

Th

ere

is n

on

e

Poss

ible

wo

rkar

ou

nd

s b

y u

sin

g PO

SIX

lon

g ju

mp

s o

r si

gnal

s. s

ee a

lso

mac

ro-a

ssem

ble

r o

r ‘o

ld la

ngu

age’

exc

epti

on

han

dlin

g m

eth

od

s.

550

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

550

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

hand

ling

in R

eal-

tim

e Ja

va

Thro

wab

le

Lin

kage

Erro

r

Vir

tual

Mac

hin

eErr

or

Use

r d

efin

ed …

Erro

rs

Exce

pti

on

Inte

rru

pte

dEx

cep

tio

n

Asy

nch

ron

ou

sly-

Inte

rru

pte

dEx

cep

tio

n

Ass

erti

on

Erro

r

Thre

adD

eath

Use

r d

efin

ed …

Use

r d

efin

ed …

Use

r d

efin

ed …

Use

r d

efin

ed …

Use

r d

efin

ed …

……

Ru

nTi

meE

xcep

tio

n

Un

chec

ked

Ch

ecke

d to

be

dec

lare

d p

er m

eth

od

553

Asy

nch

ron

ism

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

hand

ling

over

view

Rec

ove

ryH

and

ler

Dec

lare

d p

er:

Dec

lare

as:

Sco

pe

Rea

l-Tim

e Ja

vaTe

rmin

atio

nD

ynam

ical

/ Pr

op

agat

ing

Met

ho

dC

lass

Blo

ck

Ad

aTe

rmin

atio

nD

ynam

ical

/ Pr

op

agat

ing

Pack

age

Stat

ic n

ame

Blo

ck

CH

ILL

Term

inat

ion

Stat

icV

ia h

and

ler

Stat

ic

han

dle

rSt

atem

ent /

B

lock

/ Ta

sk

Mes

aR

esu

mp

tio

n o

r te

rmin

atio

nD

ynam

ical

/ Pr

op

agat

ing

Pro

ced

ure

Stat

ic

pro

ced

ure

Blo

ck

Pear

lR

esu

mp

tio

n o

r te

rmin

atio

nSt

atic

Pro

cess

Stat

ic n

ame

Task

Eiff

elC

lass

ret

ryD

ynam

ical

/ Pr

op

agat

ing

Co

ntr

act

vio

lati

on

Stat

ic n

ame

Co

ntr

act

C /

POSI

XN

on

e

551

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

551

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onis

m in

gen

eral

pro

gram

fl ow

s

Exce

pti

on

hand

ling

in R

eal-

tim

e Ja

va

Exce

pti

on

s ar

e o

bje

cts

in R

eal-

tim

e Ja

va (E

xcep

tio

ns

hav

e a

hie

rarc

hic

al r

elat

ion

).

Exce

pti

on

s h

and

lers

can

cat

ch:

• O

ne

indi

vidu

al e

xcep

tio

n.

• Ex

cep

tio

ns

ou

t of a

fi ni

te li

st o

f exc

epti

on

s.

• Ex

cep

tio

ns

of a

cla

ss (

mis

sin

g in

Ad

a).

• A

ll ex

cep

tio

ns.

Th

e ki

nd

s o

f exc

epti

on

s w

hic

h a

re to

be

han

dle

d c

an b

e d

eno

ted

pre

cise

ly, c

om

ple

tely

an

d s

afel

y.

Page 21: Dibble2009 ] Interrupts

556

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

556

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

Ato

mic

Act

ion

s

Co

mm

itm

ent t

imes

5

Flow of tasks

30

Ind

ivis

ible

p

has

es

554

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

554

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

(Defi

nit

ion

s)

An

act

ion

is a

tom

ic if

the

pro

cess

es p

erfo

rmin

g it

• …

are

no

t aw

are

of t

he

exis

ten

ce o

f an

y o

ther

act

ive

pro

cess

, an

d

no

oth

er a

ctiv

e p

roce

ss is

aw

are

of t

he

acti

vity

of t

he

pro

cess

es

du

rin

g th

e ti

me

the

pro

cess

es a

re p

erfo

rmin

g th

e ac

tio

n.

• …

do

no

t co

mm

un

icat

e w

ith

oth

er p

roce

sses

w

hile

the

acti

on

is b

ein

g p

erfo

rmed

.

• …

can

no

t det

ect a

ny

ou

tsid

e st

ate

chan

ge a

nd

do

no

t rev

eal

thei

r ow

n s

tate

ch

ange

s u

nti

l th

e ac

tio

n is

co

mp

lete

.

… c

an b

e co

nsi

der

ed to

be

ind

ivis

ible

an

d in

stan

tan

eou

s.

557

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

557

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Nes

ted

ato

mic

act

ions

Act

ion

act

ion

s ca

n b

e n

este

d, i

ff …

… a

ll p

roce

sses

invo

lved

in th

e n

este

d a

tom

ic a

ctio

ns

are

a tr

ue

sub

set o

f th

e p

roce

sses

invo

lved

in th

e en

clo

sin

g at

om

ic a

ctio

n.

555

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

555

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

(Im

plic

atio

ns)

An

ato

mic

act

ion

• …

is e

ith

er p

erfo

rmed

fully

, or

no

t at a

ll.

• …

is d

ecla

red

as

faile

d, i

f an

y p

art o

f th

e ac

tio

n fa

ils.

Thu

s al

l par

ts o

f an

ato

mic

act

ion

nee

d to

be

pre

par

ed:

to b

e in

terr

up

ted

(du

e to

the

failu

re o

f on

e o

f th

em).

to re

set t

o th

eir

init

ial s

tate

at a

ny.

Page 22: Dibble2009 ] Interrupts

560

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

560

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

Failu

re in

on

e o

f th

e ta

sks

Cle

anin

g u

p

in a

ll ta

sks

Act

ion

d

ecla

red

fa

iled

558

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

558

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Nes

ted

ato

mic

act

ions

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

Nes

ted

Ato

mic

A

ctio

ns

561

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

561

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re F

ailu

re in

ou

ter

ato

mic

act

ion

.

Pre

serv

e fu

ll at

om

icit

y.

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

Failu

re in

o

ute

r ac

tio

n

Inn

er a

ctio

n

read

y to

co

mm

it

Asy

nchr

onis

m”

up to

pag

e 62

0)A

sync

hron

ism

”up

topa

ge62

0

Inn

er a

ctio

n

rolli

ng

bac

k

404040

page

561

of 9

61(

page

561

of96

page

561

of96

page

561

of96

Ou

ter

acti

on

ro

llin

g b

ack

Act

ion

d

ecla

red

fa

iled

559

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

559

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

(Req

uir

emen

ts fo

r re

al-t

ime

envi

ron

men

ts)

• W

ell-

defi

ned

boun

dari

es

A s

tart

, en

d a

nd

a s

ide

bo

un

dar

y: D

efi n

e cl

ear

entr

y an

d e

xit p

oin

ts fo

r al

l pro

cess

es in

volv

ed in

the

ato

mic

act

ion

. Pr

oce

sses

can

en

ter

at d

iffe

ren

t tim

e, b

ut n

eed

to b

e re

leas

ed a

t on

ce.

Sep

arat

e th

e in

volv

ed p

roce

sses

fro

m th

e re

st o

f th

e sy

stem

(‘si

de

bo

un

dar

y’).

• In

divi

sibi

lity

(Iso

lati

on)

Pro

hib

it o

r re

stri

ct c

om

mu

nic

atio

ns

to o

uts

ide

pro

cess

es a

nd

res

ou

rces

. E

mp

loyi

ng

resu

lts

fro

m o

ne

ato

mic

act

ion

in a

no

ther

on

e im

plie

s st

rict

ser

ialis

atio

n.

• N

esti

ng

Ato

mic

act

ion

s m

ay b

e n

este

d, i

f th

ey fo

rm a

tru

e en

clo

sin

g re

lati

on

.•

Con

curr

ency

Ind

epen

den

t ato

mic

act

ion

s m

ay b

e ex

ecu

ted

in a

ny

ord

er a

nd

co

ncu

rren

tly.

Page 23: Dibble2009 ] Interrupts

564

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

564

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

Fai

lure

in in

ner

ato

mic

act

ion

.

Bre

ak a

tom

icit

y an

d p

rop

agat

e fa

ilure

imm

edia

tely

.

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

40

(cha

pter

5: “

Asy

nchr

onis

m”

up to

(h

5All

par

ts

rolli

ng

bac

k im

med

iate

ly

562

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

562

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re F

ailu

re in

ou

ter

ato

mic

act

ion

.

Bre

ak a

tom

icit

y an

d p

rop

agat

e fa

ilure

imm

edia

tely

.

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

40 pter

5:“A

sync

hron

ism

”up

topa

g

All

par

ts

rolli

ng

bac

k

Failu

re in

o

ute

r ac

tio

n

353555355

Act

ion

d

ecla

red

fa

iled

565

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

565

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

acti

on A

wit

h (P

2, P

3, …

) do

-

- co

mmun

icat

ion

is r

estr

icte

d to

P2,

P3,

-

- ex

cept

ions

and

tim

ing

cons

trai

nts

viol

atio

ns a

re p

ropa

gate

d

--

t

o al

l in

volv

ed p

roce

sses

exce

ptio

n

whe

n ex

cept

ion_

a =>

… -

- re

cove

r lo

call

y

whe

n ex

cept

ion_

b =>

… -

- re

cove

r lo

call

y

whe

n ot

hers

=>

rai

se a

tomi

c_ac

tion

_fai

lure

; --

and

fai

l th

e ac

tion

end

A;

it

d

Co

nst

ruct

do

es n

ot e

xist

in

any

mai

nst

ream

lan

guag

e

563

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

563

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re F

ailu

re in

inn

er a

tom

ic a

ctio

n.

Pre

serv

e fu

ll at

om

icit

y.

tim

e0

510

1520

2530

3545

Ato

mic

Task

4

Task

3

Task

2

Task

1

page

563

of 9

61(c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

page

563

of96

1(c

hapt

er5:

“Asy

nch

Ou

ter

acti

on

on

ly n

oti

fi ed

afte

r in

ner

act

ion

ro

lled

bac

k

and

co

mm

itte

d to

failu

re

Page 24: Dibble2009 ] Interrupts

568

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

568

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

(sp

ecifi

cati

on)

t

ype

Acti

on_P

art_

Time

_Sco

pe i

s re

cord

St

art_

Dela

y_Mi

n :

Time

_Spa

n :=

Tim

e_Sp

an_Z

ero;

St

art_

Dela

y_Ma

x :

Time

_Spa

n :=

Tim

e_Sp

an_L

ast;

Ma

x_El

apse

:

Time

_Spa

n :=

Tim

e_Sp

an_L

ast;

De

adli

ne

:

Time

:=

Tim

e_La

st;

e

nd r

ecor

d;

t

ype

Acti

on_P

art_

Proc

is

acce

ss p

roce

dure

;

typ

e Ac

tion

_Par

t_Pr

ocs

is r

ecor

d

Acti

on,

Cl

eanu

p :

Acti

on_P

art_

Proc

;

Scop

e

: Ac

tion

_Par

t_Ti

me_S

cope

;

end

rec

ord;

typ

e Ac

tion

_Par

ts i

s ar

ray

(Pos

itiv

e ra

nge

<>)

of A

ctio

n_Pa

rt_P

rocs

;

Th

e Cl

eanu

p p

roce

du

re is

mea

nt t

o r

esto

re th

e in

itia

l sta

te!

(‘un

do

ing’

all

effe

cts

of A

ctio

n)

566

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

566

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

imp

lem

enta

tio

ns•

Imp

lem

ente

d b

y d

edic

ated

task

s.

• “C

lien

t tas

k” is

blo

cked

du

rin

g th

e at

om

ic a

ctio

n.

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

569

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

569

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

(usa

ge)

Acti

ons

: Ac

tion

_Par

ts (

Task

s_In

dex)

:=

(1

=> (Ac

tion

=>

Act

ion_

Task

_1’A

cces

s,

Cl

eanu

p =>

Cle

anup

_Tas

k_1’

Acce

ss,

Scop

e

=> (

Star

t_De

lay_

Min

=> M

illi

seco

nds

(33)

,

St

art_

Dela

y_Ma

x =>

Mil

lise

cond

s (1

33),

Max_

Elap

se

=> T

ime_

Span

_Las

t,

De

adli

ne

=>

Tim

e_La

st)

)

,

2 =>

pack

age

Atom

ic_A

ctio

n is

new

Gen

eric

_Ato

mic_

Acti

on (

Acti

ons)

;

proc

edur

e Pe

rfor

m is

b

egin

At

omic

_Act

ion.

Perf

orm;

exc

epti

on

when

end

Per

form

;

567

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

567

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

with

Ato

mic_

Acti

on_T

ypes

; us

e At

omic

_Act

ion_

Type

s;

gene

ric

A

ctio

ns :

in

Acti

on_P

arts

;

pack

age

Gene

ric_

Atom

ic_A

ctio

n is

p

roce

dure

Per

form

;

F

ailu

re_S

tate

,

Tim

e_Ou

t_St

ate,

L

ate_

Acti

vati

on_S

tate

: e

xcep

tion

;

end

Gene

ric_

Atom

ic_A

ctio

n;

Sco

pe

mec

han

ism

is e

mp

loye

d to

lim

it c

om

mu

nic

atio

n p

oss

ibili

ties

of a

tom

ic a

ctio

n p

arts

.

Th

e p

erfo

rm-c

all i

s at

om

ic fo

r th

e ca

ller

and

invi

sib

le fo

r o

ther

s.

Fai

lure

s in

on

e p

art a

re a

uto

mat

ical

ly p

rop

agat

ed in

the

wh

ole

ato

mic

act

ion

.

Page 25: Dibble2009 ] Interrupts

572

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

572

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

(imp

lem

enta

tio

n)pr

otec

ted

Moni

tor

is

e

ntry

Che

ck_I

n

(

Task

_Id

:

in

Task

_Ids

);

ent

ry F

ail

(Co

ndit

ion

: in

At

omic

_Con

diti

on);

ent

ry F

aile

d

(Ta

sk_I

d

: in

Ta

sk_I

ds);

--

bloc

king

unt

il F

ail

is c

alle

d

ent

ry C

heck

_Out

(Ta

sk_I

d

: in

Ta

sk_I

ds);

--

bloc

king

unt

il a

ll p

arts

are

com

plet

ed o

r al

l ar

e cl

eane

d up

e

ntry

Act

ion_

Resu

lt (

Cond

itio

n :

out

Atom

ic_C

ondi

tion

);

priv

ate

C

heck

_Lis

t

:

Tas

k_Li

st

:=

Che

ck_L

ist_

Out;

S

tate

:

Ato

mic_

Stat

e

:=

Che

ckin

g_In

;

Fin

al_C

ondi

tion

: A

tomi

c_Co

ndit

ion

:= S

ucce

eded

;

end

Moni

tor;

Ch

eck

the

cou

rse

pag

e fo

r th

e co

mp

lete

so

urc

es.

570

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

570

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

(imp

lem

enta

tio

n)ta

sk b

ody

Acti

on_T

ask

is… be

gin

M

onit

or.C

heck

_In

(Tas

k_Id

);

s

elec

t

Moni

tor.

Fail

ed (

Task

_Id)

;

Acti

ons

(Tas

k_Id

).Cl

eanu

p.al

l;

Atom

ic_A

ctio

n.Mo

nito

r.Ch

eck_

Out

(Tas

k_Id

);

the

n ab

ort

be

gin

sel

ect

dela

y To

_Dur

atio

n (A

ctio

ns (

Task

_Id)

.Sco

pe.S

tart

_Del

ay_M

ax);

rais

e La

te_A

ctiv

atio

n_St

ate;

the

n ab

ort

dela

y To

_Dur

atio

n (A

ctio

ns (

Task

_Id)

.Sco

pe.S

tart

_Del

ay_M

in);

end

sel

ect;

573

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

573

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

imp

lem

enta

tio

ns•

Imp

lem

ente

d a

llow

s fo

r ta

sks

to d

edic

ate

them

selv

es.

• N

este

d a

ctio

ns

are

po

ssib

le, c

lien

t tas

k n

ot b

lock

ed.

Lab

ora

tori

es.

tim

e0

510

1520

2530

3540

45

Ato

mic

Task

4

Task

3

Task

2

Task

1

571

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

571

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

in A

da

(imp

lem

enta

tio

n)…

s

elec

t

de

lay

unti

l Re

al_D

eadl

ine;

--

base

d on

Max

_Ela

pse

& De

adli

ne

ra

ise

Time

_Out

_Sta

te;

the

n ab

ort

Acti

ons

(Tas

k_Id

).Ac

tion

.all

;

end

sel

ect;

Ato

mic_

Acti

on.M

onit

or.C

heck

_Out

(Ta

sk_I

d);

ex

cept

ion

whe

n Ti

me_O

ut_S

tate

=> M

onit

or.F

ail

(Tim

e_Ou

t);

whe

n La

te_A

ctiv

atio

n_St

ate

=> M

onit

or.F

ail

(Lat

e_Ac

tiva

tion

);

whe

n ot

hers

=> M

onit

or.F

ail

(Oth

er_E

xcep

tion

);

en

d;

end

sel

ect;

end

Acti

on_T

ask;

Page 26: Dibble2009 ] Interrupts

576

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

576

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

and

tra

nsfe

r of

con

trol

Inte

rrup

ts v

s. A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Fro

m in

terr

up

ts (s

ub

-pro

cess

leve

l) e

mp

loye

d in

: …

co

mm

un

icat

ion

wit

h s

low

/ as

ynch

ron

ou

s / s

po

rad

ic d

evic

es.

… s

amp

ling

/ co

ntr

ol l

oo

ps.

… c

lose

ly c

ou

ple

d r

efl e

ctiv

e sy

stem

s.

To a

syn

chro

no

us

tran

sfer

of c

on

tro

l (p

roce

ss le

vel)

use

d in

:Er

ror

reco

very

— s

up

po

rtin

g at

om

ic a

ctio

ns

and

forw

ard

rec

ove

ry.

Mod

e ch

ange

s —

su

dd

en c

han

ges

fro

m ‘n

orm

al’ o

per

atio

ns

to e

mer

gen

cy m

easu

res.

Part

ial /

impr

ecis

e co

mpu

tati

ons

— w

hen

ever

tim

elin

ess

is m

ore

imp

ort

ant t

han

pre

cisi

on

.

Ope

rato

r in

terv

enti

on —

Use

r tr

igge

red

mo

de

chan

ges.

574

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

574

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re r

ecov

ery

Bac

kwar

d er

ror

reco

very

in re

al-t

ime

envi

ron

men

ts

Sin

ce o

nce

so

me

par

ts o

f th

e ac

tio

n m

igh

t hav

e fa

iled

: S

om

e ac

tio

n-p

arts

mig

ht r

e-ex

ecu

te th

e sa

me

met

ho

d a

gain

,

Or

exec

ute

alt

ern

ativ

e m

eth

od

s, e

ven

if th

e o

rigi

nal

met

ho

d w

as lo

cally

val

id.

In r

eal-

tim

e en

viro

nmen

ts, f

aile

d a

tom

ic a

ctio

ns

oft

en im

ply

irre

vers

ible

failu

res:

Tra

ckin

g b

ack

and

re-

tryi

ng

the

sam

e at

om

ic a

ctio

n w

ith

mo

difi

ed p

aram

eter

s o

r m

eth

od

s is

rar

ely

use

ful,

con

sid

erin

g ti

min

g co

nst

rain

ts.

Bac

ktra

ckin

g is

oft

en p

hys

ical

ly im

po

ssib

le.

577

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

577

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

and

tra

nsfe

r of

con

trol

Real

-tim

e Ja

va

Sup

plie

s th

ree

bas

ic fe

atu

res:

1. B

ind

ing

of h

and

lers

to in

tern

al a

nd

ext

ern

al a

syn

chro

no

us

even

ts.

1a.

Spec

ifyi

ng

asyn

chro

no

us

even

ts

1b. S

pec

ifyi

ng

adeq

uat

e h

and

lers

2. A

syn

chro

no

us

tran

sfer

of c

on

tro

l.

3. A

syn

chro

no

us

term

inat

ion

of t

hre

ads.

575

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

575

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Hid

ing

asyn

chro

nism

Ato

mic

act

ions

failu

re r

ecov

ery

Forw

ard

erro

r re

cove

ry in

real

-tim

e en

viro

nm

ents

A ‘m

od

e ch

ange

’ an

d a

dif

fere

nt s

et o

f (at

om

ic) a

ctio

ns

(an

d g

oal

s!)

will

be

mo

re u

sefu

l in

man

y ca

ses.

Fo

rwar

d e

rro

r re

cove

ry is

mo

re c

om

mo

n in

rea

l-ti

me

syst

ems.

(mo

re o

n fo

rwar

d e

rro

r re

cove

ry in

ch

apte

r 1 )

Page 27: Dibble2009 ] Interrupts

580

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

580

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

eve

nts

publ

ic a

bstr

act

clas

s As

yncE

vent

Hand

ler

impl

emen

ts S

ched

ulab

le{

pub

lic

Asyn

cEve

ntHa

ndle

r (S

ched

ulin

gPar

amet

ers

sch

edul

ing,

Rel

ease

Para

mete

rs

r

elea

se,

Mem

oryP

aram

eter

s

m

emor

y,

M

emor

yAre

a

are

a,

P

roce

ssin

gGro

upPa

rame

ters

gro

up);

pub

lic

voi

d ad

dToF

easi

bili

ty (

);

pub

lic

voi

d re

move

From

Feas

ibil

ity

();

pro

tect

ed

int

ge

tAnd

Clea

rPen

ding

Fire

Coun

t ()

; p

ubli

c ab

stra

ct v

oid

hand

leAs

yncE

vent

();

//

call

ed b

y ru

n wh

ile

Fire

Coun

t /=

0

pub

lic

fina

l

voi

d ru

n ()

;

…}

578

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

578

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

eve

nts

Wh

enev

er a

n in

stan

ce o

f Asy

ncE

ven

t occ

urs

:

• al

l.ru

n() m

eth

od

s o

f all

inst

ance

s o

f Asy

ncEv

entH

andl

er, w

hic

h a

re

bo

un

d to

this

Asy

ncEv

ent

are

sch

edu

led

for

exec

uti

on

.

• M

ult

iple

Asy

ncEv

ents

may

hav

e d

iffe

ren

t im

pac

ts o

n th

e sc

hed

ulin

g.

• A

n e

ven

t co

un

ter

(Fir

eCou

nt) i

s su

pp

lied

.

• As

yncE

vent

s an

d Asy

ncEv

entH

andl

ers

may

be

crea

ted

an

d u

sed

by

any

pro

gram

logi

c.

• M

ore

than

on

e h

and

ler

can

be

atta

ched

to o

ne

even

t.

• M

ore

than

on

e ev

ent c

an b

e at

tach

ed to

on

e h

and

ler.

Fle

xib

le, b

ut h

and

led

as

a sc

hed

ula

ble

ob

ject

581

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

581

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

eve

nts

publ

ic c

lass

Bou

ndAs

yncE

vent

Hand

ler

exte

nds

Asyn

cEve

ntHa

ndle

r{

pub

lic

Boun

dAsy

ncEv

entH

andl

er (

); /

/ in

heri

t mo

des

from

the

cur

rent

thr

ead

p

ubli

c Bo

undA

sync

Even

tHan

dler

(Sc

hedu

ling

Para

mete

rs

sche

duli

ng,

Re

leas

ePar

amet

ers

rele

ase,

Me

mory

Para

mete

rs

memo

ry,

Me

mory

Area

area

,

Proc

essi

ngGr

oupP

aram

eter

s gr

oup,

bo

olea

n

nonh

eap,

ja

va.l

ang.

Runn

able

logi

c);

} bin

d th

e cu

rren

t th

read

to a

n Asy

ncEv

entH

andl

er

(oth

erw

ise

the As

yncE

vent

Hand

ler

will

exe

cute

in a

thre

ad o

f its

ow

n).

579

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

579

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

eve

nts

publ

ic c

lass

Asy

ncEv

ent

{ p

ubli

c As

yncE

vent

();

pub

lic

sync

hron

ized

voi

d ad

dHan

dler

(Asy

ncEv

entH

andl

er h

andl

er);

pub

lic

sync

hron

ized

voi

d re

move

Hand

ler

(Asy

ncEv

entH

andl

er h

andl

er);

pub

lic

voi

d se

tHan

dler

(Asy

ncEv

entH

andl

er h

andl

er);

pub

lic

voi

d bi

ndTo

(jav

a.la

ng.S

trin

g ha

ppen

ing)

;

pub

lic

Rele

aseP

aram

eter

s cr

eate

Rele

aseP

aram

eter

s ()

;

pub

lic

voi

d fi

re (

);

…}

Page 28: Dibble2009 ] Interrupts

584

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

584

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

nC

ases

of o

per

atio

ns

if a

Asy

nchr

onou

slyI

nter

rupt

edEx

cept

ion

(AIE

) occ

urs

:

1. I

f co

ntr

ol i

s in

a s

ynch

ron

ized

sec

tio

n (w

ith

in a

n in

terr

up

tib

le s

ecti

on

):

AIE

is p

ut i

nto

a p

end

ing

stat

e.

2. I

f co

ntr

ol i

s in

an

inte

rru

pti

ble

sec

tio

n:

Co

ntr

ol i

s tr

ansf

erre

d to

the

nea

rest

dyn

amic

ally

en

clo

sin

g ca

tch

cla

use

, wh

ich

is in

a n

on

-in

terr

up

tib

le s

ecti

on

.

3. I

f co

ntr

ol i

s in

wai

t, sl

eep,

or jo

in:

Th

read

is a

ctiv

ated

an

d 1

. or

2. is

follo

wed

.

4. I

f co

ntr

ol i

s in

a n

on

-in

terr

up

tib

le s

ecti

on

:

No

thin

g h

app

ens

un

til a

n in

terr

up

tib

le s

ecti

on

is r

each

ed.

5. I

f an

inte

rru

pti

ble

sec

tio

n is

rea

ched

wh

ile p

rop

agat

ing

an e

xcep

tio

n:

Ori

gin

al e

xcep

tio

n is

dis

card

ed (!

) an

d re

pla

ced

by

the

AIE

.

582

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

582

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Java

: Int

erru

pti

ng e

xcep

tio

nW

hile

an

Asy

ncEv

ent

just

sch

edu

les

a h

and

ler

for

exec

uti

on

, oth

er e

ven

t cl

asse

s ar

e n

eed

ed to

alt

er th

e co

ntr

ol fl

ow

mo

re d

irec

tly:

Stan

dar

d Ja

va:

The In

terr

upte

dExc

epti

on in

dic

ates

the

wis

h to

inte

rru

pt a

thre

ad, w

hic

h it

self

nee

d to

p

oll

the is

Inte

rrup

ted

met

ho

d to

fi n

d o

ut,

wh

eth

er it

is s

up

po

sed

to b

e in

terr

up

ted

.

• If

the

thre

ad is

cu

rren

tly

exec

uti

ng

and

ign

ori

ng

the

fl ag

:

No

eff

ect o

n th

e ac

tual

co

ntr

olfl

ow

!

• If

the

thre

ad, w

hic

h is

to b

e in

terr

up

ted

is c

urr

entl

y b

lock

ing:

It is

act

ivat

ed a

nd

rec

eive

s an

Int

erru

pted

Exce

ptio

n.

Too

wea

k to

be

emp

loye

d in

an

asy

nch

ron

ou

s tr

ansf

er o

f co

ntr

ol!

585

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

585

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

n

publ

ic c

lass

Asy

nchr

onou

slyI

nter

rupt

edEx

cept

ion

exte

nds

j

ava.

lang

.Int

erru

pted

Exce

ptio

n{

pub

lic

sync

hron

ized

voi

d

dis

able

();

pub

lic

sync

hron

ized

boo

lean

ena

ble(

);

pub

lic

sync

hron

ized

boo

lean

fir

e();

pub

lic

boo

lean

doI

nter

rupt

ible

(In

terr

upti

ble

logi

c);

p

ubli

c

b

oole

an h

appe

ned

(boo

lean

pro

paga

te);

p

ubli

c st

atic

Asy

nchr

onou

slyI

nter

rupt

edEx

cept

ion

getG

ener

ic()

;

//

ret

urns

the

Asy

nchr

onou

slyI

nter

rupt

edEx

cept

ion

whic

h

// i

s ge

nera

ted

when

Rea

ltim

eThr

ead.

inte

rrup

t ()

is

invo

ked

p

ubli

c

v

oid

p

ropa

gate

();

}

l

Nee

d to

be

par

t of a

RealtimeThread

e 58

5 of

961

(cha

pter

5: “

Asy

nchr

onis

m”

up to

pag

e 62

0)

invo

ked

Will

pro

pag

ate

any

oth

er

exce

pti

on

imm

edia

tely

n gggege

tGen

ept

ion

whi

t()

is

i

583

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

583

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

n

Wh

ile a

n Asy

ncEv

ent

just

sch

edu

les

a h

and

ler

for

exec

uti

on

, oth

er e

ven

t cl

asse

s ar

e n

eed

ed to

alt

er th

e co

ntr

ol fl

ow

mo

re d

irec

tly:

Rea

l-ti

me

Java

:

the As

ynch

rono

usly

Inte

rrup

tedE

xcep

tion

mig

ht i

nte

rcep

t a c

on

tro

l fl o

w d

irec

tly,

wh

ile:

• Th

e co

de r

egio

ns, w

hic

h a

re in

terr

up

tib

le n

eed

to b

e in

dic

ated

.

• Sy

nch

ron

ized

blo

cks,

task

cre

atio

ns

and

fi n

aliz

atio

ns

are

no

t in

terr

up

tib

le.

• Th

e re

spo

nse

tim

e o

f a th

read

mu

st b

e w

ith

in ‘a

bo

un

ded

nu

mb

er

of b

ytec

od

es’ (

wh

ich

itse

lf n

eed

to b

e d

ocu

men

ted

).

• If

the

inte

rru

pti

ble

thre

ad is

cur

rent

ly b

lock

ed (i

n a

jav

a.io

.* o

per

atio

n)

then

the

thre

ad is

eit

her

rele

ased

or k

ept i

n th

e b

lock

(d

efi n

itio

n o

f a r

easo

nab

le b

lock

ing

tim

e o

r si

tuat

ion

is im

ple

men

tati

on

dep

end

ent)

.

Page 29: Dibble2009 ] Interrupts

588

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

588

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

n

Wh

ile a

syn

chro

no

usl

y in

terr

up

tin

g ev

ent h

and

ling

is p

art o

f th

e st

and

ard

exc

epti

on

h

and

ling

mec

han

ism

, th

ere

are

nev

erth

eles

s d

iffe

ren

ces

in e

xcep

tio

n p

rop

agat

ion

:

• A

sta

nd

ard

exc

epti

on

is n

ot p

rop

agat

ed b

y d

efau

lt w

hen

cau

ght b

y an

y ‘c

atch

’ sta

tem

ent

(an

exp

licit

re-r

aisi

ng

of t

he

exce

pti

on

is n

eces

sary

to p

ass

it o

n).

• A

Asy

nchr

onou

slyI

nter

rupt

edEx

cept

ion

is p

rop

agat

ed b

y d

efau

lt, e

ven

if c

augh

t (a

n e

xplic

it p

rop

agat

ion

sto

p is

nec

essa

ry to

avo

id it

s fu

rth

er p

rop

agat

ion

).

real

ized

in th

e AI

E.ha

ppen

ed m

eth

od

Rat

ion

ale:

Lo

cal c

atch

-all

clau

ses

mig

ht n

ot b

e aw

are

of a

po

ten

tial

asy

nch

ron

ou

s in

terr

up

tin

g ex

cep

tio

n.

Pra

ctic

al c

om

pro

mis

e, b

ut d

estr

oyi

ng

som

e in

tegr

ity

of t

he

Java

-exc

epti

on

co

nce

pt.

586

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

586

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

nim

port

Non

Inte

rrup

tibl

eSer

vice

s.*;

publ

ic c

lass

Int

erru

ptib

leSe

rvic

e{

pub

lic

AIE

stop

Now

= AI

E.ge

tGen

eric

();

p

ubli

c bo

olea

n Se

rvic

e()

thro

ws A

IE

{

tr

y {

//

code

int

erdi

sper

sed

with

cal

ls t

o No

nInt

erru

ptib

leSe

rvic

es

}

catc

h AI

E AI

{

i

f (s

topN

ow.h

appe

ned

(tru

e))

{

//

hand

le t

he A

TC

}

}

}}

NonI

nter

rup

Inte

rru

pti

ble

co

de

sect

ion

Han

dle

the stopNow

pro

pag

ate

anyt

hin

g el

se

589

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

589

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: I

nter

rup

tib

le in

terf

ace

publ

ic i

nter

face

Int

erru

ptib

le{

pub

lic

void

int

erru

ptAc

tion

(As

ynch

rono

usly

Inte

rrup

tedE

xcep

tion

exc

epti

on);

pub

lic

void

run

(As

ynch

rono

usly

Inte

rrup

tedE

xcep

tion

exc

epti

on)

thr

ows

Asyn

chro

nous

lyIn

terr

upte

dExc

epti

on;

}

An

ob

ject

may

dec

lare

an

inte

rru

pti

ble

met

ho

d e

xplic

itly

by

imp

lem

enti

ng

the

abo

ve in

terf

ace.

So

le p

urp

ose

: pas

s th

is im

ple

men

tati

on

to a

do

Inte

rru

pti

ble

met

ho

d o

f a AIE

cla

ss.

Th

e AI

E.do

Inte

rrup

tibl

e ca

n o

nly

be

calle

d b

y o

ne

thre

ad a

t a ti

me!

587

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

587

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: A

sync

hro

nous

ly in

terr

upti

ng e

xcep

tio

nim

port

Non

Inte

rrup

tibl

eSer

vice

s.*;

publ

ic c

lass

Int

erru

ptib

leSe

rvic

e{

pub

lic

AIE

stop

Now

= AI

E.ge

tGen

eric

();

p

ubli

c bo

olea

n Se

rvic

e()

thro

ws A

IE

{

tr

y {

//

code

int

erdi

sper

sed

with

cal

ls t

o No

nInt

erru

ptib

leSe

rvic

es

}

catc

h AI

E AI

{

i

f (s

topN

ow.h

appe

ned

(fal

se))

{

//

han

dle

the

ATC

} e

lse

{ //

cle

anup

AI.p

ropa

gate

}}

}

}

NonI

nter

rup

Inte

rru

pti

ble

co

de

sect

ion

Han

dle

the stopNow

oth

erw

ise:

cle

an u

p a

nd

pro

pag

ate

anyt

hin

g el

se

Page 30: Dibble2009 ] Interrupts

592

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

592

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

ts

Ad

a: In

terr

upt

hand

lers

pack

age

Ada.

Inte

rrup

ts i

s

t

ype

Inte

rrup

t_ID

is

imp

leme

ntat

ion-

defi

ned;

typ

e Pa

rame

terl

ess_

Hand

ler

is a

cces

s pr

otec

ted

proc

edur

e;

fun

ctio

n Is

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n Is

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D)

r

etur

n Pa

rame

terl

ess_

Hand

ler;

pro

cedu

re A

ttac

h_Ha

ndle

r

(New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re E

xcha

nge_

Hand

ler

(Old

_Han

dler

: o

ut P

aram

eter

less

_Han

dler

;

New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re D

etac

h_Ha

ndle

r

(Int

erru

pt

: i

n I

nter

rupt

_ID)

;

fun

ctio

n Re

fere

nce

(Int

erru

pt :

Int

erru

pt_I

D) r

etur

n Sy

stem

.Add

ress

;

end

Ada.

Inte

rrup

ts;

590

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

590

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s ev

ents

Real

-tim

e Ja

va: T

imeo

ut o

n ac

tio

ns

publ

ic c

lass

Tim

ed e

xten

ds A

sync

hron

ousl

yInt

erru

pted

Exce

ptio

n

imp

leme

nts

java

.io.

Seri

aliz

able

{ p

ubli

c Ti

med

(Hig

hRes

olut

ionT

ime

time

) th

rows

Ill

egal

Argu

ment

Exce

ptio

n;

pub

lic

bool

ean

doIn

terr

upti

ble

(Int

erru

ptib

le l

ogic

);

pub

lic

void

rese

tTim

e

(Hig

hRes

olut

ionT

ime

time

);}

• Th

e ti

mer

is s

tart

ed s

om

etim

e b

etw

een

the

invo

cati

on

of t

he

doI

nter

rupt

ible

itse

lf a

nd

the .r

un m

eth

od

of t

he

inte

rru

pti

ble

inte

rfac

e.

• A

gen

eric

int

erru

pt()

is th

row

n a

t th

e ex

pir

atio

n o

f th

e ti

mer

.

• “t

ime”

can

be

abso

lute

or

rela

tive

.

593

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

593

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

ts

Ad

a: In

terr

upt

hand

lers

pack

age

Ada.

Inte

rrup

ts i

s

t

ype

Inte

rrup

t_ID

is

imp

leme

ntat

ion-

defi

ned;

typ

e Pa

rame

terl

ess_

Hand

ler

is a

cces

s pr

otec

ted

proc

edur

e;

fun

ctio

n Is

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n Is

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D)

r

etur

n Pa

rame

terl

ess_

Hand

ler;

pro

cedu

re A

ttac

h_Ha

ndle

r

(New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re E

xcha

nge_

Hand

ler

(Old

_Han

dler

: o

ut P

aram

eter

less

_Han

dler

;

New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re D

etac

h_Ha

ndle

r

(Int

erru

pt

: i

n I

nter

rupt

_ID)

;

fun

ctio

n Re

fere

nce

(Int

erru

pt :

Int

erru

pt_I

D) r

etur

n Sy

stem

.Add

ress

;

end

Ada.

Inte

rrup

ts;

e errl

ess_

Hand

ler;

er:

ininininininininiiiinPa

rame

terl

ess

Hand

ler;

erru

ptID

)re

turn

Bl

erru

pt_I

D) r

etur

n Bo

olea

n;

: In

terr

upt_

ID)

retu

rn P

aram

eter

less

_Han

dler

;er

: i

n P

aram

eter

less

_Han

dler

;

: in

Int

erru

pt_I

D);

r :

out

Para

mete

rles

s_Ha

ndle

r;

Pro

tect

ed p

roce

du

res

nee

d to

qu

alif

y as

an

inte

rru

pt h

and

ler:

use

pra

gma Interrupt_Handler

let

the

com

pile

r ev

alu

ate

the

suit

abili

ty.

rupt

: I

ntru

pt :

Int

591

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

591

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Form

s of

asy

nchr

onis

m

Ad

a

Pro

vid

es:

• Ex

cept

ion

hand

ling

(syn

chro

no

us

on

ly).

• A

sync

hron

ous

tran

sfer

of c

ontr

ol.

• Ta

sk a

bort

s.

• In

terr

upt

hand

ling

(clo

se to

har

dw

are)

.

Set

of d

iffe

ren

t met

ho

ds

to h

and

le d

iffe

ren

t kin

ds

of e

ven

ts!

Page 31: Dibble2009 ] Interrupts

596

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

596

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

ts

Ad

a: In

terr

upt

hand

lers

pack

age

Ada.

Inte

rrup

ts i

s

t

ype

Inte

rrup

t_ID

is

imp

leme

ntat

ion-

defi

ned;

typ

e Pa

rame

terl

ess_

Hand

ler

is a

cces

s pr

otec

ted

proc

edur

e;

fun

ctio

n Is

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n Is

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D)

r

etur

n Pa

rame

terl

ess_

Hand

ler;

pro

cedu

re A

ttac

h_Ha

ndle

r

(New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re E

xcha

nge_

Hand

ler

(Old

_Han

dler

: o

ut P

aram

eter

less

_Han

dler

;

New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re D

etac

h_Ha

ndle

r

(Int

erru

pt

: i

n I

nter

rupt

_ID)

;

fun

ctio

n Re

fere

nce

(Int

erru

pt :

Int

erru

pt_I

D) r

etur

n Sy

stem

.Add

ress

;

end

Ada.

Inte

rrup

ts;

er :

P

aram

eter

less

_Han

dler

;:

iniiiiiIn

terr

upt

ID);

erru

ptID

)t

erru

pt_I

D)re

turn

Boo

lean

;er

rupt

_ID)

retu

rn B

oole

an;

: In

terr

upt_

ID)

retu

rnPa

rame

terl

ess_

Hand

ler;

er :

in P

aram

eter

less

_Han

dler

;

Dir

ect

acce

ss t

o th

e in

voca

tion

add

ress

:

May

be

use

d to

co

nn

ect a

ny

cod

e se

ctio

n

to in

terr

up

ts –

use

wit

h s

pec

ial c

are.

I

nter

rupt

Ha

ndle

r (O

ld_H

andl

er

N

ew_H

andl

er

Int

erru

pt

ndle

r

(Int

erru

pt

(Int

erru

pt :

Int

erru

p

594

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

594

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

ts

Ad

a: In

terr

upt

hand

lers

pack

age

Ada.

Inte

rrup

ts i

s

t

ype

Inte

rrup

t_ID

is

imp

leme

ntat

ion-

defi

ned;

typ

e Pa

rame

terl

ess_

Hand

ler

is a

cces

s pr

otec

ted

proc

edur

e;

fun

ctio

n Is

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n Is

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D)

r

etur

n Pa

rame

terl

ess_

Hand

ler;

pro

cedu

re A

ttac

h_Ha

ndle

r

(New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re E

xcha

nge_

Hand

ler

(Old

_Han

dler

: o

ut P

aram

eter

less

_Han

dler

;

New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re D

etac

h_Ha

ndle

r

(Int

erru

pt

: i

n I

nter

rupt

_ID)

;

fun

ctio

n Re

fere

nce

(Int

erru

pt :

Int

erru

pt_I

D) r

etur

n Sy

stem

.Add

ress

;

end

Ada.

Inte

rrup

ts;

t t t l t

: inn

Int

erru

pt_I

D);

ll

dl

t t t l t:

inIn

terr

upt

ID);

enta

tion

-def

ined

;

prot

ecte

d pr

oced

ure;

terr

upt_

ID)

retu

rn B

oole

an;

terr

upt_

ID)

retu

rn B

oole

an;

t :

Inte

rrup

t_ID

)re

turn

Para

mete

rles

s_Ha

ndle

r;le

r :

in P

aram

eter

less

_Han

dler

;t

:in

Inte

rrup

tID

);

e t t t l t:

inIn

terr

upt

ID);

Alt

ern

ativ

ely,

a protected

procedure

can

also

be

stat

ical

ly a

ttac

hed

to a

n in

terr

up

t:

use

pragma Interupt_Handler_Attach

or

use

… with Attach_Handler => …;

as a

n a

ttri

bute

for

a protected procedure.

(Int

erru

pt

(Ne

w_Ha

ndlt l

597

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

597

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Not

ions

of t

ime

in A

da

Ada.

Real

-Tim

e.Ti

ming

_Eve

nts

pac

kage

pack

age

Ada.

Real

_Tim

e.Ti

ming

_Eve

nts

is

t

ype

Timi

ng_E

vent

is

tagg

ed l

imit

ed p

riva

te;

typ

e Ti

ming

_Eve

nt_H

andl

er i

s

ac

cess

pro

tect

ed p

roce

dure

(Ev

ent

: in

out

Tim

ing_

Even

t);

pro

cedu

re S

et_H

andl

er (

Even

t

: in

out

Tim

ing_

Even

t;

At

_Tim

e :

in T

ime;

Ha

ndle

r :

in T

imin

g_Ev

ent_

Hand

ler)

;

pro

cedu

re S

et_H

andl

er (

Even

t

: in

out

Tim

ing_

Even

t;

In_T

ime

: in

Tim

e_Sp

an;

Ha

ndle

r :

in T

imin

g_Ev

ent_

Hand

ler)

;

fun

ctio

n Cu

rren

t_Ha

ndle

r (E

vent

: T

imin

g_Ev

ent)

ret

urn

Timi

ng_E

vent

_Han

dler

;

pro

cedu

re C

ance

l_Ha

ndle

r (E

vent

: i

n ou

t Ti

ming

_Eve

nt;

Can

cell

ed :

out

Boo

lean

);

fun

ctio

n Ti

me_O

f_Ev

ent

(Eve

nt :

Tim

ing_

Even

t) r

etur

n Ti

me;

pri

vate

...

--

not

spec

ifie

d by

the

lan

guag

e e

nd A

da.R

eal_

Time

.Tim

ing_

Even

ts;

Effe

ctiv

ely

an

inte

rru

pt h

and

ling

mec

han

ism

wh

ich

is

sp

ecia

lized

o

n ti

mer

s.

595

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

595

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Inte

rrup

ts

Ad

a: In

terr

upt

hand

lers

pack

age

Ada.

Inte

rrup

ts i

s

t

ype

Inte

rrup

t_ID

is

imp

leme

ntat

ion-

defi

ned;

typ

e Pa

rame

terl

ess_

Hand

ler

is a

cces

s pr

otec

ted

proc

edur

e;

fun

ctio

n Is

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n Is

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

fun

ctio

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D)

r

etur

n Pa

rame

terl

ess_

Hand

ler;

pro

cedu

re A

ttac

h_Ha

ndle

r

(New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re E

xcha

nge_

Hand

ler

(Old

_Han

dler

: o

ut P

aram

eter

less

_Han

dler

;

New

_Han

dler

: i

n P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;

pro

cedu

re D

etac

h_Ha

ndle

r

(Int

erru

pt

: i

n I

nter

rupt

_ID)

;

fun

ctio

n Re

fere

nce

(Int

erru

pt :

Int

erru

pt_I

D) r

etur

n Sy

stem

.Add

ress

;

end

Ada.

Inte

rrup

ts;

le

n n n r r

;reeeeee

Deta

ch_H

andl

er

(Int

erru

pt

: i

ninininininininininiinIn

terr

upt_

ID);

terr

upt

IDis

il

tte

rrup

t_ID

is i

mple

ment

atio

n-de

fine

d;

rame

terl

ess_

Hand

ler

isac

cess

prot

ecte

d pr

oced

ure;

nIs

_Res

erve

d (I

nter

rupt

: I

nter

rupt

_ID)

retu

rn B

oole

an;

nIs

_Att

ache

d (I

nter

rupt

: I

nter

rupt

_ID)

ret

urn

Bool

ean;

n C

urre

nt_H

andl

er

(Int

erru

pt :

Int

erru

pt_I

D) retu

rn P

aram

eter

less

_Han

dlre

Atta

ch_H

andl

er

(Ne

w_Ha

ndle

r :

in P

aram

eter

less

_Han

dler

;

In

terr

upt

:

in I

nter

rupt

_ID)

;re

Exch

ange

_Han

dler

(Ol

d_Ha

ndle

r :

out

Para

mete

rles

s_Ha

ndle

r;

Ne

w_Ha

ndle

r :

in P

aram

eter

less

_Han

dler

;

Int

erru

pt

: i

n I

nter

rupt

_ID)

;e

Deta

chHa

ndle

r(I

nter

rupt

Th

e m

ech

anis

m to

invo

ke a

n in

terr

up

t han

dle

r m

ay b

e

dif

fere

nt f

rom

cal

ling

a p

rote

cted

pro

ced

ure

fro

m a

task

.

Imp

lem

enta

tio

n a

dvi

ce:

Wh

enev

er p

oss

ible

, th

e im

ple

men

tati

on

sh

ou

ld a

llow

inte

rru

pt h

and

lers

to b

e ca

lled

dire

ctly

by

the

hard

war

e.

Met

rics

:

The

imp

lem

enta

tio

n s

hal

l doc

umen

t th

e w

orst

cas

e ov

erhe

ad

for

an in

terr

up

t han

dle

r in

voca

tio

n (i

n c

lock

cyc

les)

.

Page 32: Dibble2009 ] Interrupts

600

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

600

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

, th

en:

1.

If th

e tr

igge

r ca

n be

com

plet

ed:

Th

e o

pti

on

al s

tate

men

ts

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

co

mp

lete

d (t

he

abo

rtab

le p

art i

s n

ever

sta

rted

).

2.

If th

e tr

igge

r is

blo

cked

or

req

ueu

ed to

a b

lock

ed e

ntr

y:

Th

e st

atem

ents

in th

e ab

ort

able

par

t are

exe

cute

d:

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

598

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

598

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

601

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

601

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

, th

en:

1.

If th

e tr

igge

r ca

n be

com

plet

ed:

Th

e o

pti

on

al s

tate

men

ts

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

co

mp

lete

d (t

he

abo

rtab

le p

art i

s n

ever

sta

rted

).

2.

If th

e tr

igge

r is

blo

cked

or

req

ueu

ed to

a b

lock

ed e

ntr

y:

Th

e st

atem

ents

in th

e ab

ort

able

par

t are

exe

cute

d:

2a.

If th

e ab

orta

ble

part

com

plet

es b

efor

e th

e tr

igge

r is

com

plet

ed,

An

att

emp

t is

mad

e to

rev

oke

the

trig

geri

ng

stat

emen

t. Th

e se

lect

sta

tem

ent i

s co

mp

lete

d a

fter

the

can

celle

d o

r co

mp

lete

d tr

igge

rin

g st

atem

ent.

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

599

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

599

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

, th

en:

1.

If th

e tr

igge

r ca

n be

com

plet

ed:

Th

e o

pti

on

al s

tate

men

ts

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

co

mp

lete

d (t

he

abo

rtab

le p

art i

s n

ever

sta

rted

).

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

Page 33: Dibble2009 ] Interrupts

604

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

604

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

No

te a

bo

ut e

xcep

tio

n h

and

ling:

All

par

ts o

f a sel

ect-

then

-abo

rt s

tate

men

t can

rai

se e

xcep

tio

ns,

yet

:

… in

cas

e o

f an

inte

rru

pti

on

of t

he

abo

rtab

le p

art,

the

exce

pti

on

s fr

om

the

abo

rtab

le p

art a

re lo

st!

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

602

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

602

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

, th

en:

1.

If th

e tr

igge

r ca

n be

com

plet

ed:

Th

e o

pti

on

al s

tate

men

ts

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

co

mp

lete

d (t

he

abo

rtab

le p

art i

s n

ever

sta

rted

).

2.

If th

e tr

igge

r is

blo

cked

or

req

ueu

ed to

a b

lock

ed e

ntr

y:

Th

e st

atem

ents

in th

e ab

ort

able

par

t are

exe

cute

d:

2a.

If th

e ab

orta

ble

part

com

plet

es b

efor

e th

e tr

igge

r is

com

plet

ed,

An

att

emp

t is

mad

e to

rev

oke

the

trig

geri

ng

stat

emen

t. Th

e se

lect

sta

tem

ent i

s co

mp

lete

d a

fter

the

can

celle

d o

r co

mp

lete

d tr

igge

rin

g st

atem

ent.

2b.

If th

e tr

igge

r is

com

plet

ed b

efor

e th

e ab

orta

ble

part

is c

ompl

eted

, T

he

abo

rtab

le p

art i

s ab

ort

ed, a

nd

the

op

tio

nal

sta

tem

ents

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

com

ple

ted

.

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

605

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

605

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

D

: D

urat

ion;

begi

n

...

s

elec

t

dela

y un

til

T;

the

n ab

ort

de

lay

D;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

D

: D

urat

ion;

begi

n

...

s

elec

t

dela

y D;

t

hen

abor

t

dela

y un

til

T;

e

nd s

elec

t;

end

B;

Eq

uiv

alen

t?

603

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

603

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

Exec

ute

the

trig

ger (en

try-

call

or de

lay)

, th

en:

1.

If th

e tr

igge

r ca

n be

com

plet

ed:

Th

e o

pti

on

al s

tate

men

ts

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

co

mp

lete

d (t

he

abo

rtab

le p

art i

s n

ever

sta

rted

).

2.

If th

e tr

igge

r is

blo

cked

or

req

ueu

ed to

a b

lock

ed e

ntr

y:

Th

e st

atem

ents

in th

e ab

ort

able

par

t are

exe

cute

d:

2a.

If th

e ab

orta

ble

part

com

plet

es b

efor

e th

e tr

igge

r is

com

plet

ed,

An

att

emp

t is

mad

e to

rev

oke

the

trig

geri

ng

stat

emen

t. Th

e se

lect

sta

tem

ent i

s co

mp

lete

d a

fter

the

can

celle

d o

r co

mp

lete

d tr

igge

rin

g st

atem

ent.

2b.

If th

e tr

igge

r is

com

plet

ed b

efor

e th

e ab

orta

ble

part

is c

ompl

eted

, T

he

abo

rtab

le p

art i

s ab

ort

ed, a

nd

the

op

tio

nal

sta

tem

ents

follo

win

g th

e tr

igge

r are

exe

cute

d a

nd

the

sele

ct s

tate

men

t is

com

ple

ted

.

select

<entry-call | delay>

[ … statements … ]

then abort

… statements …

end select;

Page 34: Dibble2009 ] Interrupts

608

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

608

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 1:

Ren

dez

vou

s st

arts

an

d c

om

ple

tes

bef

ore

tim

eou

t

606

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

606

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

end

sel

ect;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

end

sel

ect;

end

C;

Eq

uiv

alen

t?

609

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

609

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 1a

: SR

com

ple

tes

bef

ore

tim

eou

t

607

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

607

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

the

n ab

ort

Se

rver

.Ent

ry;

SR

;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

end

sel

ect;

end

C;

Eq

uiv

alen

t?

Ab

ort

able

cod

e se

ctio

ns

bbbb

stan

dar

d c

od

ese

ctio

ns

tttttttttta

td

dd

Trig

gers

follo

wed

by

T

: T

ime;

begi

n

... sele

ct S

;;;Ti

me

ct

T :

T

ninininin S

e

SRSR

or

egegegegegininininin ...

sele

c

bbbbbbb

S

endd

end

B;

Page 35: Dibble2009 ] Interrupts

612

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

612

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

S T;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 2a

: Ren

dez

vou

s co

mp

lete

s b

efo

re S

T

610

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

610

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 1b

: SR

do

es n

ot c

om

ple

te b

efo

re ti

meo

ut

613

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

613

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 2b

: ST

com

ple

tes

bef

ore

ren

dez

vou

s

611

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

611

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 2:

Ren

dez

vou

s st

arts

bef

ore

bu

t co

mp

lete

s af

ter

tim

eou

t

Page 36: Dibble2009 ] Interrupts

616

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

616

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 3b

: Ren

dez

vou

s co

mp

lete

s b

efo

re ST

star

ts

614

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

614

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 3:

Tim

eou

t occ

urs

bef

ore

the

ren

dez

vou

s st

arts

617

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

617

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 3c

: Ren

dez

vou

s co

mp

lete

s b

efo

re S

T co

mp

lete

s

615

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

615

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

onou

s Tra

nsfe

r of

Con

trol

Ad

a: A

sync

hro

nous

Tra

nsfe

r o

f Co

ntro

l

task

bod

y A

is

T

: T

ime;

begi

n

...

s

elec

t

dela

y un

til

T;

ST;

t

hen

abor

t

Serv

er.E

ntry

;

SR;

e

nd s

elec

t;

end

A;

task

bod

y B

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

t

hen

abor

t

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

B;

task

bod

y C

is

T

: T

ime;

begi

n

...

s

elec

t

Serv

er.E

ntry

;

SR;

o

r

dela

y un

til

T;

ST;

e

nd s

elec

t;

end

C;

Cas

e 3a

: ST

com

ple

tes

bef

ore

ren

dez

vou

s st

arts

Page 37: Dibble2009 ] Interrupts

620

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

620

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Asy

nchr

oni

sm•

Inte

rrup

ts /

Sig

nals

• D

evic

e / s

yste

m /

lan

guag

e / o

per

atin

g-sy

stem

leve

l in

terr

up

t co

ntr

ol.

• C

har

acte

rist

ics

of i

nte

rru

pts

an

d s

ign

als.

• Ex

cept

ions

• Ex

cep

tio

n c

lass

es /

gran

ula

rity

/ p

aram

etri

sati

on

/ p

rop

agat

ion

.

• R

esu

mp

tio

n a

nd

term

inat

ion

, sp

ecifi

c la

ngu

age

issu

es.

• A

tom

ic A

ctio

ns•

Defi

nit

ion

/ re

qu

irem

ents

/ fa

ilure

cas

es /

imp

lem

enta

tio

n /

erro

r re

cove

ry.

• A

sync

hron

ous

tran

sfer

of c

ontr

ol /

Int

erru

pts

in c

onte

xt•

Inte

rru

pts

an

d A

TC in

Rea

l-ti

me

Java

an

d A

da.

Sum

mar

y

618

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

618

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Lang

uage

Sup

port

for

Asy

nchr

onis

m

Asy

nchr

oni

sm in

Ad

a an

d R

eal-

tim

e Ja

va:

(Co

mm

on

feat

ure

s)

• A

TC-e

nab

led

reg

ion

s m

ust

be

dec

lare

d.

• So

me

regi

on

s ar

e al

way

s d

efer

red

fro

m a

syn

chro

no

us

tran

sfer

of c

on

tro

l (t

ask

/ th

read

co

mm

un

icat

ion

/ sy

nch

ron

izat

ion

/ fi

nal

izat

ion

).

• Ex

cep

tio

ns

fro

m th

e ru

n-t

ime

envi

ron

men

t as

wel

l as

use

r-d

efi n

ed e

xcep

tio

ns

are

sup

po

rted

.

• A

syn

chro

no

us

even

ts m

ay b

e tr

igge

red

by

the

envi

ron

men

t as

wel

l as

fro

m a

task

.

619

Asy

nch

ron

ism

© 2

019

Uw

e R

. Zim

mer

, The

Aus

tral

ian

Nat

iona

l Uni

vers

ity

page

619

of 9

61 (c

hapt

er 5

: “A

sync

hron

ism

” up

to p

age

620)

Lang

uage

Sup

port

for

Asy

nchr

onis

m

Asy

nchr

oni

sm in

Ad

a an

d R

eal-

tim

e Ja

va:

(Dif

fere

nce

s)

Ad

aR

eal-

tim

e Ja

vaM

ech

anis

ms

Inte

rru

pts

are

inte

rru

pts

an

d

ATC

is e

mb

edd

ed in

the

‘sel

ect’

sch

eme.

Asy

nch

ron

ism

is e

mb

edd

ed in

to th

e sy

nch

ron

ou

s ex

cep

tio

n s

chem

e.

Asy

nch

ron

ou

s tr

ansf

er o

f co

ntr

ol r

egio

ns

Ass

um

es th

at a

ll co

de

wh

ich

is c

alle

d fr

om

w

ith

in a

n A

TC-e

nab

led

reg

ion

is A

TC-e

nab

led

.

Dec

lare

s A

TC-e

nab

led

reg

ion

s p

er m

eth

od

an

d a

ny

asyn

chro

no

us

even

t is

def

erre

d u

nti

l th

e n

ext A

TC-e

nab

led

met

ho

d is

exe

cuti

ng.

Han

dle

r id

enti

fi ca

tio

n

Del

iver

s an

inte

rru

pt t

o o

ne

glo

bal

han

dle

r an

d e

ach

ATC

-en

able

d r

egio

n

has

exa

ctly

on

e ex

it p

oin

t.

Del

iver

s as

ynch

ron

ou

s ev

ents

to a

ll en

rolle

d

han

dle

rs a

nd

pro

pag

ates

an

asy

nch

ron

ou

s in

-te

rru

pti

ng

even

t th

rou

gh th

e cl

ose

st h

and

lers

.