[ECOS] pthread_mutex_unlock when mutex is not locked
Rubén Pérez de Aranda Alonso
Wed Apr 27 08:30:00 GMT 2005
I have found a problem when I want to unlock a mutex that is not locked
by any thread. This scenario can be needed when we want to signal
a resource in hardware is free from a DSR, that is executed by a
peripheral interrupt, to threads that requires the access to this
resource. The thread will execute a lock before access to resource.
The DSR will be executing an unlock for each HW interrupt although
there aren't threads accessing to the resource.
I think the mutex must verify the lock condition before perform
an unlock operation.
I have added the next code in Cyg_Mutex::unlock(void) method:
CYG_INSTRUMENT_MUTEX(UNLOCK, this, 0);
This scenario can also be solved using message queues or semaphores.
I prefer mutexes because the unlock condition is when their count
is equal to zero, and, in semaphores, the unlock condition is when
their count is > 0.
RubÃ©n Israel PÃ©rez de Aranda Alonso
SIDSA - Semiconductores InvestigaciÃ³n y DiseÃ±o S.A.
Parque TecnolÃ³gico de Madrid Phone : +34 91 803 5052
C/ Torres Quevedo, nÂº 1 Fax: +34 91 803 9557
28760 TRES CANTOS (Madrid) (SPAIN)
e-mail: email@example.com www.sidsa.com
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
More information about the Ecos-discuss