2 * This model describes the implementation of QemuEvent in
3 * util/qemu-thread-win32.c.
5 * Author: Paolo Bonzini <pbonzini@redhat.com>
7 * This file is in the public domain. If you really want a license,
11 * spin -a docs/event.promela
12 * gcc -O2 pan.c -DSAFETY
19 /* Primitives for a Win32 event */
20 #define RAW_RESET event = false
21 #define RAW_SET event = true
22 #define RAW_WAIT do :: event -> break; od
25 /* Basic sanity checking: test the Win32 event primitives */
26 #define RESET RAW_RESET
30 /* Full model: layer a userspace-only fast path on top of the RAW_*
31 * primitives. SET/RESET/WAIT have exactly the same semantics as
32 * RAW_SET/RAW_RESET/RAW_WAIT, but try to avoid invoking them.
41 #define SET if :: state != EV_SET -> \
42 atomic { /* xchg_result=xchg(state, EV_SET) */ \
43 xchg_result = state; \
46 if :: xchg_result == EV_BUSY -> RAW_SET; \
52 #define RESET if :: state == EV_SET -> atomic { state = state | EV_FREE; } \
57 #define WAIT tmp1 = state; \
58 if :: tmp1 != EV_SET -> \
59 if :: tmp1 == EV_FREE -> \
61 atomic { /* tmp2=cas(state, EV_FREE, EV_BUSY) */ \
63 if :: tmp2 == EV_FREE -> state = EV_BUSY; \
67 if :: tmp2 == EV_SET -> tmp1 = EV_SET; \
68 :: else -> tmp1 = EV_BUSY; \
72 assert(tmp1 != EV_FREE); \
73 if :: tmp1 == EV_BUSY -> RAW_WAIT; \
80 active proctype waiter()
94 active proctype notifier()