ran the foo object alloe on heap monitor vars ar alloe on stack - - PDF document

ran the
SMART_READER_LITE
LIVE PREVIEW

ran the foo object alloe on heap monitor vars ar alloe on stack - - PDF document

Announcements 4410 lets 9 17,9 19 for Tutorial on Semaphores attended Tapia Conference students who es4410 student welcome to attend Best any 9 29 Hollister B 14 2 3pm 430pm Sunday Assignment 2 hints For problem l Crated sections always terminate


slide-1
SLIDE 1

4410

Announcements

Tutorial on Semaphores

lets 9 17,9 19 for

students who

attended Tapia Conference

Best any

es4410 student welcome to attend

Sunday

9 29

3pm 430pm

Hollister B 14 2

Assignment 2 hints

For problem l

Crated sections always terminate

Non critical sections

Nes

is

not required to terminate and might not

a For problem2

mutual exclusion protocols are

expected to

work for

Nz

2

processes

Looking ahead

prelim 1

is Thurs 10 10

1 2 weeks

Likely Naew

session

10 8

in class

slide-2
SLIDE 2

Beyond Semaphores

9 26 2019

54410

FBS

Synchronization primitives

shared memory Semaphore's

Monitors

legions

Tension

general.ly

expoessweness

Vs

usability clarity

Laoading errors

Exploit

syntax

compilers

f syntaxcheday

ran the

slide-3
SLIDE 3

foo

  • bject

ar

monitor vars

alloe on heap

alloe on stack

  • pli operation pi P2

Var locals

code

i I 1

  • p

2 operation P1 P2

Var locals

code

initialization

schematic representation of monitor

slide-4
SLIDE 4

Support for synchronization Muta

t

and synch

perkperation

Opi

OPI

pi

R

VI

locals

Regulge that B holds

t

N

end

slide-5
SLIDE 5

BB

monitor

bufffo

N

  • f portion

strt

  • H

len

  • Ntt

slob

On Htt

insert

  • peration

b

portion

need

a slot

buff stettler

to

Len

ler 11

slots

slots

I

rmv

  • peration

was wal porton

need

a ponton

vale

buffett

len

ler

1

slots

slots H

sht

start

I mod Ntt

begin stit

Len

O

slots

end

slide-6
SLIDE 6

a Boolean

condition variables

f

ta

a

n

condition

associateBee

c wet

releases math lockfor Monta

blocks process

c continue

exit monitor te unblock 1 process

I

e.ua EEhBe

Topi

cortina

end

slide-7
SLIDE 7

BB

monitor

buff

  • N
  • f portion

strt

  • H

len

  • Ntt

slob

Ntl

slots og

B

space

space

condition

stuff

condita

Lento G Bstuff

insert

  • peration

b

portion

needas

if slots

then spacewet

buff stettler

to

Len

lent

slots

slots

1

stuff continue

RMV

  • peration

was wal parton

needa.io

n

iflen otherstuffwait

Vale buffett

len

ler

1

slots

slots11

Sth

start 11 mod Nti

space continue

begin slit

Len

O

slots

_0

end BB

slide-8
SLIDE 8

II

saI.EE

eopeatT

If

runs after esignal

Efe wait

InBc

IAB

e signal

I

17in

ini

IBO

to monitor

slide-9
SLIDE 9

Implemented of signayargest senates

entry queue

for monitor

conditanqueue for each condition variable

urgent queue

for monitor

monitorcall

If

monitor ri use

then

add thread to entayqua

else grant access

e wait

Put thread on queue for

a

Inooke scheduler

c signal

Put thread on urgentqueue

If conditaqua for

c notempty

then

run head next

else

invokescheduler

scheduler

An thread

  • n went wes

T Rn.tt g

g

Else any

thread on entgque Run it

slide-10
SLIDE 10

Implemented of signayargest seventies with semphs

M monitor

Vor Mateen semaphumit D

semen semaphore Hit argon

semaphore hit G

  • p
  • perated

1

Pfmutexm

C court

c court 4

c wait

if urgcounta

  • then

urgeoutneurgeout l

Is.ge

nEEm

e signal

urgcountainurgcounty11

end

  • ften
  • ggqgtenjqg.com

qfurgcountm othf.LYYm9uTIm

slide-11
SLIDE 11

4410

Announcements

10 1

Tutorial on this

week's lectures

10 1,10 3

Sunday

10 6

3pm 430pm

Hollister 1314

Looking ahead

prelim 1

is Thurs

10 10

11

week

Likely Kaew

session

10 8

in class

slide-12
SLIDE 12

Beyondsemaphaeskon.HN

Monitor

Vad

Manker

vars

C condition

Be

Opi

Oprah pi

R

VI

locals

1

end

c wet

thread suspended

e continue

thread exits Monitor a

Ehead blocked an

c

runs

US Csignal

thread suspends

  • n

urgent

queue I

thred blocked

are

rung

slide-13
SLIDE 13

Aent

monitor

xaranti

integer

man

Condition

wzacnt

deposit

  • perator vintager

ant

  • utta

end

Mor Signal

withdraw

  • perator

W

integer

whale ants

w

do

inor.ua

end antares

ant

ant

to

end

end A cut

slide-14
SLIDE 14

My

notify

Suppose signal operation

907,1

digged.oteaue

Fife I i

il

Note Actually

I need

notes

E

E

at thatpoint

slide-15
SLIDE 15

notify

Implementater of agungatenartees

entry queue

for monitor

conditanqueue for each condition variable

monitorcall

If

monitor ri

use

then

add thread to entagquea

else grant access

e wait

Put thread on queue for conditioner

Inooke scheduler

c notify

I process

  • n conditonqua for c

made

runnable

taut continue exeauty in monitor

c notify

htt

all process

  • n eond.tnquefor a

made runnable continue executing an monitor

scheduler

Pick

some

runnable thread

to

run

it

at most

  • ne process exeates

in monitor

slide-16
SLIDE 16

summaryofs.gr regimes

e continue

thread exits monitor

C signal

thread suspends

  • r

urgent

queue

e notify

thread continues to

exec in Mordor

All cause thread suspended

  • n

C wait

to obtain monitor lock eventually

C continue E signal

immediately

e notify

eventually

compare with

Pax

slide-17
SLIDE 17

Use of notify

is tricky

tooprocesses can Acquire when f instead ofwhite

Monitor

var

locked

boolean init false

Q

condition

Acquire operation

ifloekedthenQ.ua

G while locked

de

Q wait end

locked

true

end

Release

  • peration

locked

false

Q notify

end

end monitor

slide-18
SLIDE 18

Cautions

when using

mortars

INestedlocking

call

M op

f

slide-19
SLIDE 19

II

Priority Inversion

thread

A

high pro

B

med pro

C

low pro

C looks mute M

C yields processor to B

B

runs long computaton

e

err

i

i

i

B yields processes to A

A attempts to lock mutexM

blocked due to

C

i

A yields processor to B

f

B

continues long computation

slide-20
SLIDE 20

Deconstructing Monitors

Critical Regions

Yetanother synchronizationpinata

Good ref Birrell

AnIntroductiontoPrograngwiti

Threads

Monitor

mutual exclusion forceps

ideas

card synch

Cwulhin ops

selectee mutes

due to visibility

rules for vars

looks define regions

syntax of

a

region

star

M

Lock

region in de

end

slide-21
SLIDE 21

Condition variables allow release of locks wait

notify

notifyAll

Var M

Lock

space Condition with m

stuff

condefeon with M

1

re

ion

m de

Thile N een

  • despace East end

Touffffstittler modeN

yal

ler

lent stuff signal

end

1

re non Moto

while een

  • de stuff wet end

Tal

but stiff

sht

Coletti med N

Lem

een

t

space signal

end

slide-22
SLIDE 22

associate sets of

variables

with

each lock

allows arbitrary firegraingroupingof

variables

problems if

each

Varts

associated

with multiple locks

slide-23
SLIDE 23

Message Passing

send

m to

dest

receive

m

too

wce

Various design deasons

slide-24
SLIDE 24

How to specify destfatnd sofa

  • f msg

forsend

for receue

directnanny

sender

names

recewen

receiver names sender

0442

charnels

Problem

Processes need to know each other's homes

asymetric direct hang

sender names receiver

receiver names nobody

slide-25
SLIDE 25

Synchrony

bloday

synchronous

causes primitue to

delayuntil some event

nonbloday

asynchronous

primitive continues

bloclaysend sender delayed until msg

received

client

send

yz to e

Sen

g

receive val

receive a b e

I l

send res to

slide-26
SLIDE 26

Buffery capacity

How manysent but notreceived Msgs

allowed

O

capaaly

N

capacity

send

as

V

receive

as

p

b