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

Related documents


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! 15-410, F'131 “Paradise Lost” Sep. 20, 2013 Dave Eckhardt Todd Mowry L11a_Lost 15-410 “What could possibly go wrong?” Outline When to use if () vs. while() 15-410, F'13 15-410, F'135 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); 15-410, F'136 What We Hope For find_work() queue_work() mutex_lock(&m); if (!..dequeue(..)) cond_wait(&new, &m); mutex_lock(&m); enqueue(...) cond_signal(&new); mutex_unlock(&m); w = dequeue(..); mutex_unlock(&m); 15-410, F'137 What Went Wrong? What went wrong? 15-410, F'1310 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); 15-410, F'1311 Have We Seen This Before? 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”? 15-410, F'1312 To “if()” Or Not To “if()”? mutex_lock(&m); if (going_out_of_business) w = (workitem *) 0; else { while (!(w = (workitem *) dequeue(q))) cond_wait(&new_work, &m); } mutex_unlock(&m); return (w); /* XXX still wrong! - rewrite after class */