Condvar: New "wait_record" type
Both mutex and condvar have a wait queue - which is a linked list of wait records, each containing a thread pointer to wake and a "next" pointer. Unfortunately, mutex and condvar each used a different type: mutex used linked_item<thread*>, while condvar used struct ccondvar_waiter. We want both mutex and condvar to use the same wait_record structure, so we can add in a later patch the "wait morphing" feature (moving a waiter from the condvar's queue to a mutex's queue). This patch defines a single type, "struct wait_record", suitable for both uses. In particular, it is a struct, not a template, so that pointers to it can be used in C code (see <osv/condvar.h>). wait_record is a structure containing a "waiter" and a "next" pointer. The "waiter" is just a thread pointer, which together with a few methods becomes a simple synchronization mechanism which we always used but now for the first time we encapsulate it in a type.
Loading
Please register or sign in to comment