This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: mutex and mailbox query
- From: Savin Zlobec <savin at torina dot fe dot uni-lj dot si>
- To: <hans dot doran at ibhdoran dot com>
- Cc: <ecos-discuss at sources dot redhat dot com>
- Date: Sat, 20 Sep 2003 21:18:18 +0200 (CEST)
- Subject: [ECOS] Re: mutex and mailbox query
Hans Dermot Doran wrote:
> Hello all,
>
> is it possible for a thread to destroy a mutex it has previously locked ?
> or does it have to be unlocked first ?
>
>As part of a thread-shutdown routine, I want to destroy a mailbox whose
>messages are in shared memory, therefore I mutex the messages, destroy the
>mailbox, destroy the shared memory and release threads waiting on the mutex
>and then destroy it ... all in one go ...
If you destroy the mutex, it should not be locked and have no threads
waiting on it. You should do your routine with scheduler locked and
unlock the mutex before you destroy it.
> The second question: I haven't been able to find any documentation on the
> mbox variable, used in initialising a mailbox. If I have to reserve memory
> for it would be nice to know what size it has. any pointers (excuse the
> pun) ?
try sizeof(cyg_mbox) - the size actually depends on the selected mbox
queue size.
savin
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss