Print

Print


In light of this new evidence, I think we don't need the full memory barrier. Please insert `asm volatile("": : :"memory")` before line 66 and after line 90 in [XrdClMessageUtils.hh](https://github.com/xrootd/xrootd/blob/master/src/XrdCl/XrdClMessageUtils.hh). If this helps, I will create a nicer patch for the built-in semaphores.

The semaphores are better here because we just need a very trivial synchronization mechanism. Posting/waiting on a semaphore involves just one atomic update and one syscall in case of congestion. Condvars are far more complex and, typically, involve multiple locks and multiple updates.

You would typically use a condvar if you have:
1. a complex condition for signaling
2. need to bump the owning thread's priority either because the critical section (the mutex) has a priority ceiling or because you're blocking a thread of higher priority and the mutex is in the inheritance mode.

If you're interested in how a condvar may be implemented, take a look at this: [tb-condvar.c](https://github.com/ljanyst/thread-bites/blob/master/tb-condvar.c#L61). I was once bored and implemented pretty much all of the pthread functions NPTL-style mostly in simple C: https://github.com/ljanyst/thread-bites

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/404#issuecomment-241016278

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1