Commit 0e725620 authored by Grégory Mounié's avatar Grégory Mounié

passage à minted du code des notes de cours

parent 43bc980a
......@@ -110,7 +110,8 @@ int main(int argc, char **argv) {
t2.join();
cout << compteur << "/" << NBINC * 2 << endl;
compteur = 0;
cout << u8"** Increm. dekker + volatile **" << endl;
cout << u8"** Increm. dekker + volatile **"
<< endl;
thread t3 = thread(incrementeur_fdekker, 0, 1);
thread t4 = thread(incrementeur_fdekker, 1, 0);
......@@ -121,7 +122,8 @@ int main(int argc, char **argv) {
cout << compteur << "/" << NBINC * 2 << endl;
cout << u8"** Increm dekker + atomic var **" << endl;
cout << u8"** Increm dekker + atomic var **"
<< endl;
compteur = 0;
thread t5 = thread(incrementeur_dekker, 0, 1);
......@@ -131,5 +133,4 @@ int main(int argc, char **argv) {
t6.join();
cout << compteur << "/" << NBINC * 2 << endl;
}
......@@ -18,16 +18,21 @@ atomic_int tour_mm;
void debut_sc_mm(int me, int other) {
debut:
atomic_store_explicit(& demande_mm[me], true, memory_order_seq_cst);
if (atomic_load_explicit(& demande_mm[other], memory_order_acquire)) {
if (atomic_load_explicit(& tour_mm, memory_order_acquire) == me) {
atomic_store_explicit(& demande_mm[me], true,
memory_order_seq_cst);
if (atomic_load_explicit(& demande_mm[other],
memory_order_acquire)) {
if (atomic_load_explicit(& tour_mm,
memory_order_acquire)
== me) {
while(atomic_load_explicit(& demande_mm[other],
memory_order_acquire));
}
else {
atomic_store_explicit(& demande_mm[me], false,
memory_order_release);
while(atomic_load_explicit(& tour_mm, memory_order_acquire)
while(atomic_load_explicit(& tour_mm,
memory_order_acquire)
!= me);
goto debut;
}
......@@ -35,8 +40,10 @@ void debut_sc_mm(int me, int other) {
}
void fin_sc_mm(int me, int other) {
atomic_store_explicit(& tour_mm, other, memory_order_relaxed);
atomic_store_explicit(& demande_mm[me], false, memory_order_release);
atomic_store_explicit(& tour_mm, other,
memory_order_relaxed);
atomic_store_explicit(& demande_mm[me], false,
memory_order_release);
}
......@@ -48,7 +55,3 @@ void incrementeur_dekker_mm(int me, int other) {
fin_sc_mm(me, other);
}
}
......@@ -90,7 +90,8 @@ int main(int argc, char **argv) {
t2.join();
cout << compteur << "/" << NBINC * 2 << endl;
compteur = 0;
cout << u8"** Increm. Peterson + volatile **" << endl;
cout << u8"** Increm. Peterson + volatile **"
<< endl;
thread t3 = thread(incrementeur_fpeterson, 0, 1);
thread t4 = thread(incrementeur_fpeterson, 1, 0);
......@@ -101,7 +102,8 @@ int main(int argc, char **argv) {
cout << compteur << "/" << NBINC * 2 << endl;
cout << u8"** Increm Peterson + atomic var **" << endl;
cout << u8"** Increm Peterson + atomic var **"
<< endl;
compteur = 0;
thread t5 = thread(incrementeur_peterson, 0, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment