mirror of
https://github.com/mborgerson/xemu.git
synced 2025-12-01 16:10:01 +00:00
coroutine-lock: make CoRwlock thread-safe and fair
This adds a CoMutex around the existing CoQueue. Because the write-side can just take CoMutex, the old "writer" field is not necessary anymore. Instead of removing it altogether, count the number of pending writers during a read-side critical section and forbid further readers from entering. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Message-id: 20170213181244.16297-7-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
committed by
Stefan Hajnoczi
parent
1ace7ceac5
commit
a7b91d35ba
@ -204,8 +204,9 @@ bool qemu_co_queue_empty(CoQueue *queue);
|
||||
|
||||
|
||||
typedef struct CoRwlock {
|
||||
bool writer;
|
||||
int pending_writer;
|
||||
int reader;
|
||||
CoMutex mutex;
|
||||
CoQueue queue;
|
||||
} CoRwlock;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user