[cpp-threads] modes
Alexander Terekhov
alexander.terekhov at gmail.com
Sat May 7 19:11:50 BST 2005
On 5/7/05, Doug Lea <dl at cs.oswego.edu> wrote:
>
> Alexander (and Peter?), how about you humor me and, for each mode you
> like not in minimal list, present a case that arguably meets the
> criteria ...
>
> > only if there are compelling use cases for modes needed in
> > constructions that:
> > 1. arise in common or important situations,
> > 2. can't be expressed without special modes,
> > 3. will remain inefficient even when compilers start
> > routinely optimizing wrt memory barriers etc in compliant code,
> > 4. will remain useful even as hardware vendors continue
> > with their (very) recent trends to make most barriers etc cheaper
> > (and thus less worthwhile to evade in corner cases).
> >
>
> ... so we can discuss whether they pass some consensus threshold that
> we must establish.
<quote>
The minimal list seems to be along the lines of
read-with-acquire
write-with-release
write-preserving-order
CAS-with-acquire-release
CAS-with-release
</quote>
Forget atomics for a moment.
Is this program
#include <stdio.h>
#include <pthread.h>
pthread_rwlock_t rwlock;
int var;
void * thread(void *) {
pthread_rwlock_rdlock(&rwlock);
var = 0;
//pthread_rwlock_unlock(&rwlock);
return 0;
}
int main() {
pthread_t tid;
pthread_rwlock_init(&rwlock, 0);
pthread_rwlock_wrlock(&rwlock);
pthread_create(&tid, 0, thread, 0);
var = 1;
pthread_rwlock_unlock(&rwlock);
pthread_join(tid, 0);
printf("%d\n", var);
}
data-race-free (under future C/C++/revised-POSIX memory model)?
Hopefully not.
regards,
alexander.
More information about the cpp-threads
mailing list