malbrain / rwlock

Phase Fair and Standard Reader Writer Locks
16 stars 5 forks source link

Task fair, not phase fair #1

Open WonderfulVoid opened 5 years ago

WonderfulVoid commented 5 years ago

I think the type 1 lock is only task fair, not phase fair. You see this in the ReadLock1() function where a reader thread waits for all previous (to itself) writers to complete. I.e. a reader thread cannot join an intermediate read phase. https://github.com/malbrain/rwlock/blob/588b6278e5ca7269e76a348ef8555b7b87fbbe4c/readerwriter.c#L167

malbrain commented 5 years ago

What you are describing is phase fair.  An incoming reader cannot move ahead of a waiting writer, and vice-versa.  Otherwise a stream of incoming readers could freeze out a waiting writer indefinitely.  I think you are arguing for a more descriptive name for the current behaviour? On Friday, April 12, 2019, 5:25:10 AM PDT, WonderfulVoid notifications@github.com wrote:

I think the type 1 lock is only task fair, not phase fair. You see this in the ReadLock1() function where a reader thread waits for all previous (to itself) writers to complete. I.e. a reader thread cannot join an intermediate read phase. https://github.com/malbrain/rwlock/blob/588b6278e5ca7269e76a348ef8555b7b87fbbe4c/readerwriter.c#L167

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.