-
Notifications
You must be signed in to change notification settings - Fork 155
Description
After checking the source code, I believe that photo::mutex should follow a FIFO policy. This means that the next thread to acquire the lock will definitely be the first thread in the waiting queue. This implies that there must be at least one wake-up process between the time when the thread holding the lock releases it and the time when the next thread acquires the lock and continues to execute.
In contrast, the mutex implementation in brpc allows any bthread to preempt the lock after it is unlocked, so there is only one CAS operation between the time when the thread holding the lock releases it and the time when the next thread acquires the lock and continues to execute.
Why didn't photon adopt this kind of implementation? I think such an implementation would perform much better in cases where the critical section is small and contention is heavy.