summaryrefslogtreecommitdiff
path: root/netsvcs/clients/Tokens/rw_lock/README
blob: dabc0a3741d80fe3e89bae5ba9b354dabcea63d9 (plain)
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

test_rw_locks shows how to use ACE_Local_RLock, ACE_Local_WLock,
ACE_Remote_RLock, and ACE_Remote_WLock.

Here are the options to test_rw_locks:
% ./test_rw_lock -u
 -i ignore deadlock
 -n <iterations>
 -r <reads>
 -d debug
 -s sleep during writes
 -t <threads>

test_rw_locks spawns <threads> number of threads which perform the
following algorithm:

for <iterations>
  {
    for <reads>
      acquire read lock
    for <reads>
      release read lock
  
    acquire write lock
    if (sleep during writes)
      sleep for 1 second
    release write lock
  }


The output should show that multiple readers can acquire the lock for
reading simultaneously (note that this also tests recursive
acquisition.)  When a writer lock is acquired, the output should show
that no thread holds a reader lock.

To run a test, simply type:
% ./test_rw_lock

This should show output as described above.