-
-
Notifications
You must be signed in to change notification settings - Fork 192
/
WindowsPipeReadThread.tla
504 lines (438 loc) · 22.4 KB
/
WindowsPipeReadThread.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
---- MODULE WindowsPipeReadThread ----
(*
NOTE[Event_Loop_Windows-Registered_Pipe_Read-proof]:
This is a TLA+/PlusCal specification for how Event_Loop_Windows manages the
Event_Loop_Windows::Registered_Pipe_Read thread.
The specification has three threads (PlusCal processes):
* The main thread. In C++ it executes Event_Loop_Windows::run.
* The reader thread. In C++ it executes
Event_Loop_Windows::Registered_Pipe_Read::thread_routine.
* An arbitrary other thread, which in C++ could be the main thread or the reader
thread or some other thread. It requests a that the reader thread stop via a
call to Event_Loop_Base::un_keep_alive.
NOTE[Event_Loop_Windows-Registered_Pipe_Read-terminate]: The specification
proves that calling the Win32 TerminateThread API can only interrupt a ReadFile
call, not a running user callback. See the
ReaderThreadCannotBeTerminatedDuringCallback constraint.
The specification also proves that the reader thread and the main thread
eventually terminate if a stop is requested (and if the OS scheduler is fair, of
course). See the ReaderThreadFinishesIfStopped and MainThreadFinishesIfStopped
liveness properties.
The specification also proves that neither the reader thread nor the main thread
deadlock.
NOTE[Event_Loop_Windows-Registered_Pipe_Read-data-loss]: The specification does
*not* prove no data loss. In fact, it proves data loss! A Win32 ReadFile call
might finish successfully but the reader thread might still be terminated via
Win32 TerminateThread before the ReadFile's data is given to a user callback.
See the ReadDataIsNotDropped liveness property.
*)
EXTENDS Naturals, Sequences
MainThreadID == 0
ReaderThreadID == 1
OtherThreadID == 2
InvalidReadTicket == 0
LegalReadTickets == {1, 2}
(*
--fair algorithm WindowsPipeReadThread {
variables
(* Whether Win32 TerminateThread is allowed to be called.
std::atomic<bool>
Writable by the reader thread and readable by the main thread. *)
allowTerminate = FALSE,
(* Whether the event loop should stop.
std::atomic<bool> (actually std::atomic<int> in C++)
Writable by the other thread and readable by the main thread and the reader thread. *)
stopRequested = FALSE,
(* Implementation of Win32 TerminateThread.
Writable by any thread (M_TerminateThread) and readable by the reader thread (R_CheckTerminateThread). *)
terminateRequested = FALSE,
(* Implementation of Win32 CancelIoEx.
Writable by any thread (M_CancelIoEx) and readable by the reader thread (R_CheckTerminateThread). *)
cancelIORequested = FALSE,
(* Implementation of Win32 _beginthreadex.
Writable by the main thread and readable by the reader thread. *)
readerThreadSpawned = FALSE,
(* Counter representing the result of a Win32 ReadFile call.
This variable is used by ReadDataIsNotDropped to correlate calls to
ReadFile with calls to the user callback.
Possible values:
* InvalidReadTicket (ReadFile never returned yet)
* 1 (every odd ReadFile call)
* 2 (every even ReadFile call)
Sequence over time: <<InvalidReadTicket, 1, 2, 1, 2, 1, 2, ...>> *)
readTicket = InvalidReadTicket;
(* Win32 _beginthreadex *)
macro M_BeginThread() {
readerThreadSpawned := TRUE;
}
(* Win32 CancelIoEx *)
(* NOTE(strager): CancelIoEx isn't called in this model. It's here anyway in
case you want to play around with an algorithm that uses it. *)
macro M_CancelIoEx() {
(* NOTE(strager): Win32 CancelIoEx only has an effect if the thread is
blocked in ReadFile. *)
if (pc[ReaderThreadID] = "R_InBlockingRead") {
cancelIORequested := TRUE;
}
}
(* Win32 TerminateThread *)
macro M_TerminateThread() {
terminateRequested := TRUE;
}
(* Win32 WaitForSingleObject *)
macro M_JoinReaderThread() {
await pc[ReaderThreadID] = "Done";
}
(* Win32 ReadFile *)
macro R_ReadFile() {
readTicket := CASE readTicket = InvalidReadTicket -> 1
[] readTicket = 1 -> 2
[] readTicket = 2 -> 1;
}
process (MainThread = MainThreadID) {
M_Idle:
if (~stopRequested) {
M_BeginThread();
M_StartedReader:
await stopRequested;
M_MaybeTerminate:
if (allowTerminate) {
M_TerminateThread();
};
M_StartedHalt:
M_JoinReaderThread();
};
}
(* Win32 TerminateThread could be called at any time. We model this by calling
R_CheckTerminateThread between every label. 'CT' stands for 'Check for
Termination'. *)
process (ReaderThread = ReaderThreadID) {
R_NotStarted:
either {
await readerThreadSpawned;
} or {
await pc[MainThreadID] = "Done";
goto Done;
};
R_LoopCT: if (terminateRequested) { goto Done; };
R_Loop:
while (~stopRequested) {
R_AllowTerminateCT: if (terminateRequested) { goto Done; };
R_AllowTerminate:
allowTerminate := TRUE;
R_CheckStopRequestedBeforeReadCT: if (terminateRequested) { goto Done; };
R_CheckStopRequestedBeforeRead:
if (stopRequested) {
goto Done;
};
R_InReadCT: if (terminateRequested) { goto Done; };
R_InRead:
either {
R_InFinishingRead:
R_ReadFile();
R_FinishedRead: skip;
} or {
(* ReadFile is blocked because the write end of the pipe is inactive. *)
(* NOTE(strager): We need an extra label here. Otherwise, we would not
catch the deadlock which would occur if Win32 CancelIoEx was not
called. *)
R_InBlockingRead:
await terminateRequested \/ cancelIORequested;
goto Done;
};
R_DisallowTerminateCT: if (terminateRequested) { goto Done; };
R_DisallowTerminate:
allowTerminate := FALSE;
R_BeforeCallbackCT: if (terminateRequested) { goto Done; };
R_BeforeCallback:
(* This check is unnecessary but is an optimization. *)
if (stopRequested) {
goto Done;
};
R_InCallbackCT: if (terminateRequested) { goto Done; };
R_InCallback:
(* readTicket can be used by the user callback here. *)
skip;
R_CheckReadEOFCT: if (terminateRequested) { goto Done; };
R_CheckReadEOF:
either {
skip;
} or {
(* ReadFile returned EOF. *)
goto Done;
};
};
}
process (OtherThread = OtherThreadID) {
O_RequestingStop:
stopRequested := TRUE;
}
}
*)
\* BEGIN TRANSLATION (chksum(pcal) = "33218624" /\ chksum(tla) = "7893d0fd")
VARIABLES allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned, readTicket, pc
vars == << allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned, readTicket, pc >>
ProcSet == {MainThreadID} \cup {ReaderThreadID} \cup {OtherThreadID}
Init == (* Global variables *)
/\ allowTerminate = FALSE
/\ stopRequested = FALSE
/\ terminateRequested = FALSE
/\ cancelIORequested = FALSE
/\ readerThreadSpawned = FALSE
/\ readTicket = InvalidReadTicket
/\ pc = [self \in ProcSet |-> CASE self = MainThreadID -> "M_Idle"
[] self = ReaderThreadID -> "R_NotStarted"
[] self = OtherThreadID -> "O_RequestingStop"]
M_Idle == /\ pc[MainThreadID] = "M_Idle"
/\ IF ~stopRequested
THEN /\ readerThreadSpawned' = TRUE
/\ pc' = [pc EXCEPT ![MainThreadID] = "M_StartedReader"]
ELSE /\ pc' = [pc EXCEPT ![MainThreadID] = "Done"]
/\ UNCHANGED readerThreadSpawned
/\ UNCHANGED << allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readTicket >>
M_StartedReader == /\ pc[MainThreadID] = "M_StartedReader"
/\ stopRequested
/\ pc' = [pc EXCEPT ![MainThreadID] = "M_MaybeTerminate"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
M_MaybeTerminate == /\ pc[MainThreadID] = "M_MaybeTerminate"
/\ IF allowTerminate
THEN /\ terminateRequested' = TRUE
ELSE /\ TRUE
/\ UNCHANGED terminateRequested
/\ pc' = [pc EXCEPT ![MainThreadID] = "M_StartedHalt"]
/\ UNCHANGED << allowTerminate, stopRequested,
cancelIORequested, readerThreadSpawned,
readTicket >>
M_StartedHalt == /\ pc[MainThreadID] = "M_StartedHalt"
/\ pc[ReaderThreadID] = "Done"
/\ pc' = [pc EXCEPT ![MainThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
MainThread == M_Idle \/ M_StartedReader \/ M_MaybeTerminate
\/ M_StartedHalt
R_NotStarted == /\ pc[ReaderThreadID] = "R_NotStarted"
/\ \/ /\ readerThreadSpawned
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_LoopCT"]
\/ /\ pc[MainThreadID] = "Done"
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_LoopCT == /\ pc[ReaderThreadID] = "R_LoopCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_Loop"]
/\ UNCHANGED << allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned, readTicket >>
R_Loop == /\ pc[ReaderThreadID] = "R_Loop"
/\ IF ~stopRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_AllowTerminateCT"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned, readTicket >>
R_AllowTerminateCT == /\ pc[ReaderThreadID] = "R_AllowTerminateCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_AllowTerminate"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_AllowTerminate == /\ pc[ReaderThreadID] = "R_AllowTerminate"
/\ allowTerminate' = TRUE
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_CheckStopRequestedBeforeReadCT"]
/\ UNCHANGED << stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned,
readTicket >>
R_CheckStopRequestedBeforeReadCT == /\ pc[ReaderThreadID] = "R_CheckStopRequestedBeforeReadCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_CheckStopRequestedBeforeRead"]
/\ UNCHANGED << allowTerminate,
stopRequested,
terminateRequested,
cancelIORequested,
readerThreadSpawned,
readTicket >>
R_CheckStopRequestedBeforeRead == /\ pc[ReaderThreadID] = "R_CheckStopRequestedBeforeRead"
/\ IF stopRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InReadCT"]
/\ UNCHANGED << allowTerminate,
stopRequested,
terminateRequested,
cancelIORequested,
readerThreadSpawned,
readTicket >>
R_InReadCT == /\ pc[ReaderThreadID] = "R_InReadCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InRead"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_InRead == /\ pc[ReaderThreadID] = "R_InRead"
/\ \/ /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InFinishingRead"]
\/ /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InBlockingRead"]
/\ UNCHANGED << allowTerminate, stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned, readTicket >>
R_InFinishingRead == /\ pc[ReaderThreadID] = "R_InFinishingRead"
/\ readTicket' = (CASE readTicket = InvalidReadTicket -> 1
[] readTicket = 1 -> 2
[] readTicket = 2 -> 1)
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_FinishedRead"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned >>
R_FinishedRead == /\ pc[ReaderThreadID] = "R_FinishedRead"
/\ TRUE
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_DisallowTerminateCT"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_InBlockingRead == /\ pc[ReaderThreadID] = "R_InBlockingRead"
/\ terminateRequested \/ cancelIORequested
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_DisallowTerminateCT == /\ pc[ReaderThreadID] = "R_DisallowTerminateCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_DisallowTerminate"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_DisallowTerminate == /\ pc[ReaderThreadID] = "R_DisallowTerminate"
/\ allowTerminate' = FALSE
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_BeforeCallbackCT"]
/\ UNCHANGED << stopRequested, terminateRequested,
cancelIORequested, readerThreadSpawned,
readTicket >>
R_BeforeCallbackCT == /\ pc[ReaderThreadID] = "R_BeforeCallbackCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_BeforeCallback"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_BeforeCallback == /\ pc[ReaderThreadID] = "R_BeforeCallback"
/\ IF stopRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InCallbackCT"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_InCallbackCT == /\ pc[ReaderThreadID] = "R_InCallbackCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_InCallback"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_InCallback == /\ pc[ReaderThreadID] = "R_InCallback"
/\ TRUE
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_CheckReadEOFCT"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_CheckReadEOFCT == /\ pc[ReaderThreadID] = "R_CheckReadEOFCT"
/\ IF terminateRequested
THEN /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
ELSE /\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_CheckReadEOF"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
R_CheckReadEOF == /\ pc[ReaderThreadID] = "R_CheckReadEOF"
/\ \/ /\ TRUE
/\ pc' = [pc EXCEPT ![ReaderThreadID] = "R_Loop"]
\/ /\ pc' = [pc EXCEPT ![ReaderThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, stopRequested,
terminateRequested, cancelIORequested,
readerThreadSpawned, readTicket >>
ReaderThread == R_NotStarted \/ R_LoopCT \/ R_Loop \/ R_AllowTerminateCT
\/ R_AllowTerminate \/ R_CheckStopRequestedBeforeReadCT
\/ R_CheckStopRequestedBeforeRead \/ R_InReadCT
\/ R_InRead \/ R_InFinishingRead \/ R_FinishedRead
\/ R_InBlockingRead \/ R_DisallowTerminateCT
\/ R_DisallowTerminate \/ R_BeforeCallbackCT
\/ R_BeforeCallback \/ R_InCallbackCT \/ R_InCallback
\/ R_CheckReadEOFCT \/ R_CheckReadEOF
O_RequestingStop == /\ pc[OtherThreadID] = "O_RequestingStop"
/\ stopRequested' = TRUE
/\ pc' = [pc EXCEPT ![OtherThreadID] = "Done"]
/\ UNCHANGED << allowTerminate, terminateRequested,
cancelIORequested, readerThreadSpawned,
readTicket >>
OtherThread == O_RequestingStop
(* Allow infinite stuttering to prevent deadlock on termination. *)
Terminating == /\ \A self \in ProcSet: pc[self] = "Done"
/\ UNCHANGED vars
Next == MainThread \/ ReaderThread \/ OtherThread
\/ Terminating
Spec == /\ Init /\ [][Next]_vars
/\ WF_vars(Next)
Termination == <>(\A self \in ProcSet: pc[self] = "Done")
\* END TRANSLATION
(* Type check for all variables. *)
TypeOK ==
/\ allowTerminate \in {TRUE, FALSE}
/\ cancelIORequested \in {TRUE, FALSE}
/\ terminateRequested \in {TRUE, FALSE}
/\ readerThreadSpawned \in {TRUE, FALSE}
/\ stopRequested \in {TRUE, FALSE}
/\ readTicket \in (LegalReadTickets \union {InvalidReadTicket})
ReaderThreadIsDoneIfMainThreadStopped ==
pc[MainThreadID] = "Done" => pc[ReaderThreadID] \in {"R_NotStarted", "Done"}
ReaderThreadCanOnlyRunIfMainThreadRequests ==
pc[MainThreadID] = "M_Idle" => pc[ReaderThreadID] = "R_NotStarted"
(* See NOTE[Event_Loop_Windows-Registered_Pipe_Read-terminate]. *)
ReaderThreadCannotBeTerminatedDuringCallback ==
terminateRequested => pc[ReaderThreadID] /= "R_InCallback"
ReaderThreadCannotBeTerminatedBeforeStarting ==
terminateRequested => pc[ReaderThreadID] /= "R_NotStarted"
(* Invariant check. *)
Consistent ==
/\ ReaderThreadIsDoneIfMainThreadStopped
/\ ReaderThreadCanOnlyRunIfMainThreadRequests
/\ ReaderThreadCannotBeTerminatedDuringCallback
/\ ReaderThreadCannotBeTerminatedBeforeStarting
----
(* Liveness property. *)
ReaderThreadFinishesIfStopped ==
stopRequested
~> (pc[ReaderThreadID] \in {"R_NotStarted", "Done"})
(* Liveness property. *)
MainThreadFinishesIfStopped ==
(pc[MainThreadID] = "M_MaybeTerminate")
~> (pc[MainThreadID] = "Done")
(* Liveness property. *)
(* FIXME(strager): I think this property is incorrectly expressed. It does not
guarantee that some sequence of steps leads to the callback being called. It
may as well say that stopRequested will eventually be true, but that's not
useful to say. *)
CallbackIsCalledForReadIfNotStopped ==
\A ticket \in LegalReadTickets
: (pc[ReaderThreadID] = "R_FinishedRead" /\ readTicket = ticket)
~> \/ pc[ReaderThreadID] = "R_InCallback" /\ readTicket = ticket
\/ stopRequested
(* Liveness property. *)
(* FIXME(strager): I think this property holds, but TLC disagrees. TLC says that
the property does not hold, but it shows me a state where
(pc[MainThreadID] = "M_StartedReader") and a later state where
(pc[ReaderThreadID] = "R_Loop"). I think that perhaps TLC has a bug. *)
ReaderThreadRunsIfMainThreadSpawnsReaderThread ==
(pc[MainThreadID] = "M_StartedReader")
~> (pc[ReaderThreadID] = "R_Loop")
(* Liveness property. This property does *not* hold. See
NOTE[Event_Loop_Windows-Registered_Pipe_Read-data-loss]. *)
ReadDataIsNotDropped ==
\A ticket \in LegalReadTickets
: (pc[ReaderThreadID] = "R_FinishedRead" /\ readTicket = ticket)
~> (pc[ReaderThreadID] = "R_InCallback" /\ readTicket = ticket)
=============================================================================