| 1 |
|
| 2 |
|
| 3 |
test_rw_locks shows how to use ACE_Local_RLock, ACE_Local_WLock, |
| 4 |
ACE_Remote_RLock, and ACE_Remote_WLock. |
| 5 |
|
| 6 |
Here are the options to test_rw_locks: |
| 7 |
% ./test_rw_lock -u |
| 8 |
-i ignore deadlock |
| 9 |
-n <iterations> |
| 10 |
-r <reads> |
| 11 |
-d debug |
| 12 |
-s sleep during writes |
| 13 |
-t <threads> |
| 14 |
|
| 15 |
test_rw_locks spawns <threads> number of threads which perform the |
| 16 |
following algorithm: |
| 17 |
|
| 18 |
for <iterations> |
| 19 |
{ |
| 20 |
for <reads> |
| 21 |
acquire read lock |
| 22 |
for <reads> |
| 23 |
release read lock |
| 24 |
|
| 25 |
acquire write lock |
| 26 |
if (sleep during writes) |
| 27 |
sleep for 1 second |
| 28 |
release write lock |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
The output should show that multiple readers can acquire the lock for |
| 33 |
reading simultaneously (note that this also tests recursive |
| 34 |
acquisition.) When a writer lock is acquired, the output should show |
| 35 |
that no thread holds a reader lock. |
| 36 |
|
| 37 |
To run a test, simply type: |
| 38 |
% ./test_rw_lock |
| 39 |
|
| 40 |
This should show output as described above. |
| 41 |
|