Solution of A Problem in Concurrent Programming Control - Dijkstra
This document presents a solution to the problem of mutual exclusion in concurrent programming. It describes a problem where multiple independent sequential processes need to access a critical section, but only one at a time. The solution uses a common store that the processes can read from and write to. Each process executes a loop that first sets a flag to false before checking flags from other processes and potentially entering the critical section. The solution ensures that at most one process is in the critical section at a time without requiring priorities between processes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
147 views1 page
Solution of A Problem in Concurrent Programming Control - Dijkstra
This document presents a solution to the problem of mutual exclusion in concurrent programming. It describes a problem where multiple independent sequential processes need to access a critical section, but only one at a time. The solution uses a common store that the processes can read from and write to. Each process executes a loop that first sets a flag to false before checking flags from other processes and potentially entering the critical section. The solution ensures that at most one process is in the critical section at a time without requiring priorities between processes.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Sol uti on of a Probl em in
Concurrent Programming Control
E. W. DIJXSTRA Technological University, Eindhoven, The Netherlands A n u m b e r o f m a i n l y i n d e p e n d e n t s e q u e n t i a l - c y c l i c p r o c e s s e s w i t h res tri c ted m e a n s o f c o m m u n i c a t i o n w i t h e a c h o t h e r c a n b e m a d e i n such a w a y t h a t a t a n y m o m e n t o n e a n d o n l y o n e o f t h e m is e n g a g e d i n t h e " c r i t i c a l s e c t i o n " o f its c y c l e . I n t r o d u c t i o n Gi ven in t hi s paper is a sol ut i on t o a pr obl em for which, t o t he knowl edge of t he aut hor , has been an open quest i on since at l east 1962, i rrespect i ve of t he sol vabi l i t y. The paper consists of t hr ee par t s: t he probl em, t he solution, and t he proof. Al t hough t he set t i ng of t he pr obl em mi ght seem somewhat academi c at first, t he aut hor t r ust s t ha t anyone fami l i ar wi t h t he logical probl ems t ha t arise in comput er coupling will appr eci at e t he significance of t he f act t ha t this pr obl em i ndeed can be solved. Th e P r o b l e m To begin, consider N comput ers, each engaged in a process which, for our aims, can be regarded as cyclic. I n each of t he cycles a so-cMled "cri t i cal sect i on" occurs and t he comput ers have to be pr ogr ammed in such a way t ha t at any moment onl y one of t hese N cyclic processes is in its critical section. I n order t o effect uat e t hi s mut ual exclusion of critical-section execut i on t he comput er s can communi cat e wi t h each ot her vi a a common store. Wr i t i ng a word i nt o or nondest r uct i vel y readi ng a word f r om t hi s st ore are undi vi dabl e operat i ons; i.e., when t wo or mor e comput er s t r y t o communi cat e (ei t her f or readi ng or f or writing) si mul t aneousl y wi t h t he same common l ocat i on, t hese communi cat i ons will t ake place one af t er t he ot her, but in an unknown order. The solution must sat i sfy t he following requi rement s. (a) The solution must be symmet r i cal bet ween t he N comput ers; as a resul t we are not allowed t o i nt r oduce a st at i c pri ori t y. (b) Not hi ng ma y be assumed about t he rel at i ve speeds of t he N comput ers; we ma y not even assume t hei r speeds t o be const ant in time. (c) I f any of t he comput er s is st opped well out si de its critical section, this is not allowed t o lead t o pot ent i al blocking of t he others. (d) I f mor e t han one comput er is about t o ent er its critical section, i t must be impossible t o devise f or t hem such finite speeds, t ha t t he decision t o det er mi ne whi ch one of t hem will ent er its critical sect i on first is post poned unt i l et erni t y. I n ot her words, const ruct i ons in whi ch "Af t er you" - " Af t e r you"- bl ocki ng is still possible, al t hough i mprobabl e, are not t o be regarded as val i d solutions. We beg t he challenged r eader t o st op here for a while and have a t r y himself, for t hi s seems t he onl y way t o get a feeling f or t he t r i cky consequences of t he f act t ha t each Vo h m, e 8 / Nu mb e r 9 / S e p t e mb e r , 1965 comput er can onl y r equest one one- way message at a t i me. And onl y t hi s will make t he r eader realize t o what ext ent this pr obl em is f ar f r om t ri vi al . Th e S o l u t i o n The common st ore consists of: " Bo o l e a n a r r a y b, c [ l : N] ; i n t e g e r k " The i nt eger k will sat i sfy 1 < k < N, bi l l and c[i] will onl y be set by t he i t h comput er ; t hey will be i nspect ed by t he others. I t is assumed t ha t all comput er s are st ar t ed well out si de t hei r critical sections wi t h all Bool ean ar r ays ment i oned set t o t r u e ; t he st ar t i ng val ue of k is i mmat eri al . The pr ogr am for t he i t h comput er (1 < i < N) is: " i n t e g e r j ; LiO: b[i ] : = f a l s e ; Li l : i f k # i t h e n Li 2: b e g i n c[i] : = t r ue ; Li 3: i f b [ k ] t h e n k : = i ; g o t o Li l e n d e l s e Li 4: b e g i n c[i] : = f a l s e ; f or j : = 1 s t e p 1 u n t i l N do i f j # i a n d n o t c[ j ] t h e n go t o Li l e n d ; c r i t i c a l s e c t i o n ; c[i] : = t r u e ; bill : = t r u e ; r e ma i n d e r of t h e c yc l e i n wh i c h s t o p p i n g i s a l l o we d ; g o t o Li O" Th e Pr o o f We s t ar t by observi ng t ha t t he solution is safe in t he sense t ha t no t wo comput er s can be in t hei r critical sect i on si mul t aneousl y. For t he onl y way t o ent er i t s critical sect i on is t he per f or mance of t he compound s t at ement Li 4 wi t hout j mnpi ng back t o Li l , i.e., finding all ot her c' s t r u e af t er havi ng set its own e t o f al s e. The second par t of t he pr oof must show t ha t no infinite " Af t er you"- "Af t er you"- bl ocki ng can occur; i.e., when none of t he comput er s is in its critical section, of t he comput er s l oopi ng (i.e., j umpi ng back t o Li l ) at l east one - - a nd t her ef or e exact l y one- - wi l l be allowed t o ent er i t s critical sect i on in due time. I f t he kt h comput er is not among t he l oopi ng ones, bik] will be t r u e and t he l oopi ng ones will all find k # i. As a resul t one or mnore of t hem will find in Li 3 t he Bool ean b[k] t r ue and t her ef or e one or mor e will deci de t o assign "k : = i ". Af t er t he first assi gnment "k : = i ", b[k] be- comes f al s e and no new comput er s can deci de agai n t o assign a new val ue t o k. When all deci ded assi gnment s t o k have been per f or med, / c will poi nt t o one of t he l oopi ng comput er s and will not change its val ue f or t he t i me being, i.e., unt i l b[k] becomes t r u e , viz., unt i l t he kt h comput er has compl et ed i t s critical section. As soon as t he val ue of ]c does not change any more, t he kt h comput er will wai t (via t he compound s t at ement Li 4) unt i l all ot her c's are t r u e , but t hi s si t uat i on will cer t ai nl y arise, if not al r eady present , because all ot her l oopi ng ones are forced t o set t hei r e t r u e , as t hey will find k # i. And this, t he aut hor believes, compl et es t he proof. Co mmu n i c a t i o n s o f t h e AC M 569