apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Gross <ChristianGr...@yahoo.de>
Subject Re: [PATCH] RW lock Iteration 2 for Windows
Date Mon, 30 Apr 2001 17:04:58 GMT
On Mon, 30 Apr 2001 12:31:27 -0400, you wrote:
>
>This looks wrong.  An APR_INTRAPROCESS lock should use a critical section, not a mutex.

>
I was wondering about this.  How come the use of a critical section?
The only advantage that critical section offers is speed.  But even
that is debatable.  If there is nothing holding the lock the program
will stay in user mode.  And then acquiring the lock is REALLY fast.
But if most of your time nobody is holding a lock, which the locking
code in the first place.  If something is holding the lock then the
program needs to do a switch to kernel mode.  This makes the critical
section just as slow as a mutex.  

In general I tend to use mutexs because they are more flexible, and
when you abandon them the locks held are released.  I tend to find
that with critical sections I will deadlock code more readily than
with mutexes.  For example the prime problem is getting a lock twice
within the same thread.  A mutex has no problem with this, but a
critical section will perform an automatic deadlock.

Any comments....

Christian Gross

Mime
View raw message