This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: mutex and mailbox query


On Sun, Sep 21, 2003 at 12:35:57PM +0200, Hans Dermot Doran wrote:
> Thanks for the replies
> 
> the cyg_mutex_release function releases the mutex returning null to all
> those threads waiting on the mutex, without affecting the owner, therefore
> there should be no reason to involve the cyg_thread_release function. The
> question is whether the kernel is robust enough to handle a get operation on
> a mutex which doesn't exist.

I would not say this is a question of robustness. Its a programming
error. How is the kernel supposed to know if the mutex exists or not?

> However, it does not appear to be documented what happens if you delete a
> mailbox on which a thread is blocked. In my case, since I am only
> synchronising two known and named threads,  a cyg_thread_release operation
> should work (previously calling cyg_mailbox_waiting_to_get with the name of
> the other thread). But its is not very elegant and defeats the generic
> purpose of a mailbox.

A better idea would be to perform some signalling between the two
threads. If both have message boxes the 'exiting' thread can send a
message to the other saying "Im about to exit". It should then pass
back a message "Bye Bye" and then stop using the message box. Once you
have received this message you know its safe to delete everything and
exit.

Doing it this way is always safe, no matter what the OS does.

      Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]