[cpp-threads] A question about N2153
Chris Thomasson
cristom at comcast.net
Thu Jan 18 05:00:02 GMT 2007
----- Original Message -----
From: "Chris Thomasson" <cristom at comcast.net>
To: "C++ threads standardisation" <cpp-threads at decadentplace.org.uk>;
<paulmck at linux.vnet.ibm.com>
Sent: Wednesday, January 17, 2007 4:09 PM
Subject: Re: [cpp-threads] A question about N2153
> [...]
>
>>> load_depends == *#LoadDepends | #LoadLoad
>
>> Ummm... On all CPUs other than Alpha, you don't need -any- fencing,
>> barriers, or special instructions to cause the CPU to respect
>> ordering on data dependencies.
>
> I know... Of course load_depends would be a NOP on everything except
> Alpha.
Okay... Let me just sum up how I would like the new and improved version of
C++, or whatever...
To do RCU, well, you do can do the barriers like this:
<pseudo c++ code>
// shared stack
class node;
static mystack_t gs;
// writer side - mutex-based
void writer_thread(...) {
node *n = node_cache::pop(...);
lock_guard lock(gs);
n:(#StoreStore)->next = gs:(#Naked).front;
gs:(#Naked).front = n;
}
// reader side
void reader_thread(...) {
// nop on most systems
node *n:(#LoadDepends | #LoadLoad) = gs:(#Naked).front;
while(n) {
// again, its a nop
node *nx:(#LoadDepends | #LoadLoad) = n:(#Naked)->next;
n->const_function(...);
n = nx;
}
}
so, the reader-side has exactly 0 memory barriers on every current system
out there except the alpha. Also, its weak enough to express just a normal
#StoreStore inside the writers critical section that is guarded by the stack
objects associated mutex... I would kind of like it if C++ would copy from
the SPARC model... Just my humble opinion of course...
;^)
More information about the cpp-threads
mailing list