tag:blogger.com,1999:blog-5246987755651065286.post3473054207972539443..comments2024-02-22T16:15:42.388-08:00Comments on cbloom rants: 07-16-11 - Ticket FIFO Mutexcbloomhttp://www.blogger.com/profile/10714564834899413045noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-5246987755651065286.post-53809001120703426372012-02-01T09:18:38.775-08:002012-02-01T09:18:38.775-08:00"Okay, this is a very cheap lock in terms of ..."Okay, this is a very cheap lock in terms of the number of expensive atomics required, and it's FIFO (fair) which is nice in some cases, but it simply cannot be used outside of a kernel environment. The reason is that if the thread who is next in line get swapped out, then no currently running threads can get the lock, and we don't have any wakeup mechanism to get that sleeping thread to take the lock so we can make progress. This is okay in the kernel because the kernel is controlling which threads are awake or asleep, so obviously it won't put a thread to sleep that is currently spinning trying to get the lock. "cbloomhttps://www.blogger.com/profile/10714564834899413045noreply@blogger.comtag:blogger.com,1999:blog-5246987755651065286.post-3342548009817762842012-02-01T04:40:35.244-08:002012-02-01T04:40:35.244-08:00Very nice, but... after fixing the std::memory_ord...Very nice, but... after fixing the std::memory_order constants to make it compile, it turns out that, ironically, the presumably much faster ticket mutex performs about the same as a simple W32 API critical section with a concurrency of 1 and 2, and is roughly 8 times *slower* with a concurrency of 4 (on a 4-core Intel).Anonymousnoreply@blogger.com