Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Paradise Lost - Operating System Design and Implementation - Lecture Slides, Slides of Operating Systems

This lecture is from Operating System Design and Implementation course. Its key words are: Paradise Lost, Lowly Worker Thread, Find Work, Queue Work, Thirda Third Thread, Protected, Happiness Revocation, Summary, Tocttou

Typology: Slides

2013/2014

Uploaded on 02/01/2014

sashie
sashie 🇮🇳

4.2

(40)

185 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
15-410, F'13
1
“Paradise Lost”
Sep. 20, 2013
Dave Eckhardt
Dave Eckhardt
Todd Mowry
Todd Mowry
L11a_Lost
15-410
“What could possibly go wrong?”
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Paradise Lost - Operating System Design and Implementation - Lecture Slides and more Slides Operating Systems in PDF only on Docsity!

“Paradise Lost”

Sep. 20, 2013

Dave Eckhardt Dave Eckhardt Todd Mowry Todd Mowry L11a_Lost

“What could possibly go wrong?”

Outline

When to use When to use if()if() vs.vs. while()while()

What's Wrong With This Picture?

workitem * find_work(void) { workitem *w; mutex_lock(&m); if (going_out_of_business) w = (workitem *) 0; else w = (workitem *) dequeue(q); mutex_unlock(&m); return (w); }

Better?

mutex_lock(&m); if (going_out_of_business) w = (workitem *) 0; else { if (!(w = (workitem *) dequeue(q))) { cond_wait(&new_work, &m); w = (workitem *) dequeue(queue); } } mutex_unlock(&m); return (w);

What Went Wrong?

What went wrong? What went wrong?

What Went Wrong?

What went wrong? What went wrong?  (^) Nothing!

Not Exactly What We Hope For

find_work() queue_work() find_work() lock(&m); if (!..deq(.).) cwait(&new, &m); lock(&m); enqueue(...) csignal(&new); unlock(&m); lock(&m); if (!..deq(.).) unlock(&m); w = deq(.)... return(w); return (0);

Have We Seen This Before?

What went wrong? What went wrong?  (^) Protected world state wasn't ready for us  (^) We blocked  (^) Somebody prepared the world for us to run  (^) We ran  (^) We assumed nobody else had run  (^) We assumed the world state was still ready for us When have we seen this “happiness revocation”? When have we seen this “happiness revocation”?

Summary

if() vs. while() if() vs. while()  (^) If somebody can revoke your happiness, you'd better check

Related Work

TOCTTOU TOCTTOU

 (^) This is “just a sub-case of 'TOCTTOU bugs'”, but...  (^) Many people think TOCCTOU bugs are always security bugs  (^) Fundamentally, we expect the revoked condition to become unrevoked again (soon!)  (^) Unlike the general case, this can be fxed in less than a line of code!