Am Freitag den, 30. August 2002, um 01:47, schrieb Saurabh Desai:
>
> I have a question regarding the following changes in
> pth_mutex_release():
>
> + if (!mutex->mx_shared.pshared && mutex->mx_owner != current) return
> EPERM;
>
> Why this check is not needed for the pshared case? The mx_owner is
> always
> set to current in pth_mutex_acquire() for both normal and pshared
> mutexes.
>
I thought the pointers wouldn't have to be the same in different
processes
and address spaces.
Process A aquires the lock - mutex->mx_owner=0xADDA
Process B tries to release it (which is wrong) - ok, mx_owner is still
NULL in
_this_ address space
I got that wrong.
For EDEADLK we have to test if the lock is already held by the caller -
but
only if the mutex is not PTHREAD_MUTEX_RECURSIVE.
Does the check belongs here?
pth_sync.s:239
wait:
/* already locked by caller? */
if (mutex->mx_count >= 1 && mutex->mx_owner == current &&
mutex->mx_owner_pid==descr->pid &&
mutex->mx_type == PTH_MUTEX_RECURSIVE_NP) {
/* recursive lock */
mutex->mx_count++;
_pth_release_lock(&(mutex->mx_lock), descr->tid);
return 0;
}
/* should we just tryonly? ibm*/
if (tryonly) { /*ibm*/
_pth_release_lock(&(mutex->mx_lock), descr->tid);
return EBUSY; /*ibm*/
! } else
! return EDEADLK;
> Also, if (!(mutex->mx_state & PTH_MUTEX_INITIALIZED)) return EINVAL;
> is not needed, because the caller always check for valid mx_mutex.
>
The caller checks against mx_init. But perhaps I'm still too dazed and
get this
also wrong.. ;-)
pth_mutex_init sets mx_state to PTH_MUTEX_INITIALIZED, but the flag is
also used to check if it's locked or not. I don't know if these tests
are obsolete.
Keep up the good work.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.