From: "Rubén Pérez de Aranda Alonso" <rperez@sidsa.es>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] pthread_mutex_unlock when mutex is not locked
Date: Wed, 27 Apr 2005 08:30:00 -0000 [thread overview]
Message-ID: <426F4C4A.4020701@sidsa.es> (raw)
Hi all,
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:
void
Cyg_Mutex::unlock(void)
{
CYG_REPORT_FUNCTION();
// ---------------------
if (!locked)
{
CYG_INSTRUMENT_MUTEX(UNLOCK, this, 0);
CYG_REPORT_RETURN();
return;
}
// ---------------------
[...]
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.
Regards,
Rubén
--
______________________________________________________________
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: rperez@sidsa.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
next reply other threads:[~2005-04-27 8:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-27 8:30 Rubén Pérez de Aranda Alonso [this message]
2005-04-27 9:00 ` Sergei Organov
2005-04-27 9:54 ` Rubén Pérez de Aranda Alonso
2005-04-27 10:18 ` Andrew Lunn
2005-04-27 11:51 ` Nick Garnett
2005-04-27 12:38 ` Rubén Pérez de Aranda Alonso
2005-04-27 13:44 ` Sergei Organov
2005-04-27 14:37 ` Rubén Pérez de Aranda Alonso
2005-04-28 10:15 ` Nick Garnett
2005-04-29 13:49 ` Rubén Pérez de Aranda Alonso
2005-04-27 12:15 ` Sergei Organov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=426F4C4A.4020701@sidsa.es \
--to=rperez@sidsa.es \
--cc=ecos-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).