La lecture en ligne est gratuite
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
Télécharger Lire

Concurrency 102 : From shared memory to synchronization by communcation on channels

23 pages
.Concurrency 2From shared memoryto synchronizationby communication onchannelsJean-Jacques L¶evy (INRIA - Rocq)MPRI concurrency course with :Pierre-Louis Curien (PPS)Eric Goubault (CEA)James Leifer (INRIA - Rocq)Catuscia Palamidessi (INRIA - Futurs)1.Plan• exercises (followup)• readers and writers• the flve philosophers• synchronous communication channels• CML• coding semaphores2.Readers and Writers (1/6)A shared resource is concurrently read or modifled.• Several processes may concurrently read the shared resource.• A single process (the writer) may modify the resource.• When readers are running, no writer can be executed.• When a writer is no other writer, nor a reader can runconcurrently.PROCEDURE Read() = PROCEDURE Write() =BEGIN BEGINAcquireShared(); AcquireExclusive();(∗ read shared data ∗) (∗ write shared data ∗)ReleaseShared(); ReleaseExclusive();END Read; END Write;3.Les lecteurs et les ¶ecrivains (2/6)En lecture, on a nReaders simultan¶es (nReaders >0).En ¶ecriture, on a nReaders =−1.PROCEDURE AcquireShared() = PROCEDURE AcquireExclusive() =BEGIN BEGINLOCK m DO LOCK m DOWHILE nReaders = −1 DO WHILE nReaders != 0 DOThread.Wait(m, c); Thread.Wait(m, c);END; END;++ nReaders; nReaders := −1;END; END;END AcquireShared; END AcquireExclusive;PROCEDURE ReleaseShared() = PROCEDURE ReleaseExclusive() =BEGIN BEGINLOCK m DO LOCK m DO−− nReaders; nReaders := 0;IF nReaders = 0 THEN Thread.Broadcast(c);END;Thread.Signal(c) ...
Voir plus Voir moins
.
Concurrency 2
From shared memory
to synchronization
by communication on
channels
Jean-JacquesLe´vy(INRIA-Rocq)
MPRI concurrency course with :
Pierre-Louis Curien (PPS) Eric Goubault (CEA) James Leifer (INRIA - Rocq) Catuscia Palamidessi (INRIA - Futurs)
1
.
.
.
.
.
.
.
.
oCmmnetarriver`acequaucunomnieneemureedafmi?9
.
.
Un pour Un
Permettre à tous d'accéder à la lecture
Pour chaque accès à la bibliothèque, YouScribe donne un accès à une personne dans le besoin