The atomic operations while nice are basically useless without memory visibility rules or semantics. This is something that get discussed a lot on comp.programming.threads. I suppose you can assume they are there but that's assuming a lot.
Also, doing condvars on windows isn't that easy as Douglas Schmidt writes up here [wustl.edu].
Writing portable thread libraries seems to be a popular activity. It would be nice if the authors of those packages documented that they were aware of the issues as a first step in convincing those of us who know about those issues that they know what they are doing. Yeah, I know that the Apache authors are considered experts, but it wouldn't be the first time some rather well known experts got tripped up on multi-threading.
For the atomic operations, the intel based code is ok since the lock prefix serializes memory. The powerpc load reserved / store conditional do not however and explicit memory barriers are required and they are not there. That's bad.
For the win32 version of condvar, I don't think a win32 Event isn't going to hack it. The current logic allows a condvar to remain signaled until the all waiters have woken up and have decremented the use count to zero. This could lead to a lot of spurious wakeups if some waiting thread takes it time to wake up. The APR authors need to read that Schmidt document I mentioned earlier and maybe also look at Schmidt's ACE project [wustl.edu] and see how he did it.
This is not a comprehensive critique as I only took a cursory look but what I did see indicates that APR needs some more work.
Please, if your comments are creative, and useful, forward them to the team who are doing it (give them plenty of easy links to the resources so they don't instantly dismiss you).
I don't know enough in this field to help, but if somone sent me some details on any project I'm working on which allows me to improve it, I'd be greatful, though not likely to give you pizza tokens:)
For the atomic operations, the intel based code is ok since the lock prefix serializes memory.
Well, yes, that is true, but only for uniprocessors or Pentiums. P5 is a strongly-ordered architecture. Unfortunately this is not the case for P6, which are weekly-ordered, and hence for multiprocessors require much more expensive synchronization - typically LOCKed CMPXCHG that is followed by CPUID.
An adequate bootstrap is a contradiction in terms.
Multi-threading isn't that simple (Score:5, Interesting)
Also, doing condvars on windows isn't that easy as Douglas Schmidt writes up here [wustl.edu].
Writing portable thread libraries seems to be a popular activity. It would be nice if the authors of those packages documented that they were aware of the issues as a first step in convincing those of us who know about those issues that they know what they are doing. Yeah, I know that the Apache authors are considered experts, but it wouldn't be the first time some rather well known experts got tripped up on multi-threading.
Follow up - I took a quick look at the source. (Score:5, Insightful)
For the win32 version of condvar, I don't think a win32 Event isn't going to hack it. The current logic allows a condvar to remain signaled until the all waiters have woken up and have decremented the use count to zero. This could lead to a lot of spurious wakeups if some waiting thread takes it time to wake up. The APR authors need to read that Schmidt document I mentioned earlier and maybe also look at Schmidt's ACE project [wustl.edu] and see how he did it.
This is not a comprehensive critique as I only took a cursory look but what I did see indicates that APR needs some more work.
Re:Follow up - I took a quick look at the source. (Score:2)
Dropping a link to Schmidt's work in there might not be a bad means of stealth education, either.
Re:Follow up - I took a quick look at the source. (Score:3, Insightful)
I don't know enough in this field to help, but if somone sent me some details on any project I'm working on which allows me to improve it, I'd be greatful, though not likely to give you pizza tokens
Re:Follow up - I took a quick look at the source. (Score:1)