| 1 |
|
| 2 |
|
| 3 |
invariants.cpp tests the ACE Token Invariant utilities. The ACE Token |
| 4 |
Invariant utilities allow an application to test the correctness of |
| 5 |
mutex and readers/writer locks. |
| 6 |
|
| 7 |
invariants.cpp takes no command-line arguments. invariants.cpp first |
| 8 |
tests readers/writer locks. This is done by spawning two threads |
| 9 |
which simulate reader and writer acquire/renew/release loops. |
| 10 |
However, the loops are performed without actual locks, so the |
| 11 |
competing threads quickly reach and invalid state. The test should |
| 12 |
report this violation of readers/writer lock invariants and both |
| 13 |
threads should exit. |
| 14 |
|
| 15 |
The second test is for mutexes. Similar to the readers/writer lock |
| 16 |
test, this test spawns two threads which perform acquire/renew/release |
| 17 |
loops. When to two threads reach an invalid mutex state, the error |
| 18 |
should be reported and the threads should exit. |
| 19 |
|
| 20 |
For these two previous tests, it is theoretically possible that the |
| 21 |
threads never reach an invalid token state. However, it is highly |
| 22 |
unlikely since the threads would have to execute the same code |
| 23 |
simultaneously for the duration of the test. Nevertheless, it is |
| 24 |
possible. |
| 25 |
|
| 26 |
The last test hardwires invalid token states. It runs two mutex and |
| 27 |
two readers/writer lock tests. It should report "succeeded" for the |
| 28 |
four tests. |