Hello,
> I'm developing a warehouse application with aolserver that will define
> over 5000 read-write locks from the beggining for a database with 5000
> products.
>
> I have tried and it seems it works.
> Is there any problem that could appear?
> Is there any other method in order to define a fine-grained read-write
> lock?
>
One thing to look at is memory usage. Each Mutex contains some overhead
for fields I never use (name, nextPtr). The name field adds up quickly
(33 bytes per Mutex).
Also, the thread code maintains each Mutex on a linked list, so if you
free any of the read-write locks, you may experience slowdown from the
linear lookup (and associated page thrash). This list is only necessary
for TCL access.
> I am using product based lock in order to prevent concurent execution of
> various complicated procedures that change some memory resident lists
> containing the available stock for different products.
>
I would only use r-w locks if the number of readers is much larger than the
number of writers, and the time needed for reads is relatively long. Otherwise,
a simple mutex should be fine.
Lastly, you must ensure that a thread which holds a read lock never attempts
to acquire a write lock, and vice versa. This can happen too easily in
complicated call stacks.
Adam
[EMAIL PROTECTED]