Sir,
In a programming assignment I have asked to implement Test and Set lock, with POSIX threads… Each thread will execute the following code..
—————————————————
register int p, q, i, j; // Thread-local
BARRIER(…); // Start measuring time here
for (i=0; i<N; i++) {
ACQUIRE(…);
for (j=0; j<K; j++) {
q++;
}
RELEASE(…);
for (j=0; j<M; j++) {
p++;
}
} // End measuring time here
a[MyID*FALSE_SHARING_AVOIDING_PAD] = p+q; // This is to make sure that the compiler
// does not optimize away the entire code.
———————————————————
could you please help me in implementing the AQUIRE and RELEASE function using "cmpxchg".. I am naive in this …
Thanking You,
-Debjyoti Paul
Sir,
In a programming assignment I have asked to implement Test and Set lock, with POSIX threads… Each thread will execute the following code..
—————————————————
register int p, q, i, j; // Thread-local
BARRIER(…); // Start measuring time here
for (i=0; i<N; i++) {
ACQUIRE(…);
for (j=0; j<K; j++) {
q++;
}
RELEASE(…);
for (j=0; j<M; j++) {
p++;
}
} // End measuring time here
a[MyID*FALSE_SHARING_AVOIDING_PAD] = p+q; // This is to make sure that the compiler
// does not optimize away the entire code.
———————————————————
could you please help me in implementing the AQUIRE and RELEASE function using "cmpxchg".. I am naive in this …
Thanking You,
-Debjyoti Paul