This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: cyg_thread_delete
- From: Bart Veer <bartv at redhat dot com>
- To: tom dot coremans at acunia dot com
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Mon, 11 Mar 2002 18:59:18 GMT
- Subject: Re: [ECOS] cyg_thread_delete
- References: <3C88D292.C847D715@acunia.com>
- Reply-to: bartv at redhat dot com
>>>>> "Tom" == Tom Coremans <tom.coremans@acunia.com> writes:
Tom> in my program I`m using cyg_thread_delete on a thread that is
Tom> finished. The strange thing is that cyg_thread_delete returns
Tom> false, indicating failure.
Tom> Does anybody has an explanation for this?
Possibly. Assuming this is the same application mentioned in
http://sources.redhat.com/ml/ecos-discuss/2002-03/msg00103.html
You have a low-priority thread which wants to inform the reaper that
it is exiting and can be deleted, so it will do something like:
cyg_mbox_put(reaper_mbox, (void*) cyg_thread_self());
cyg_thread_exit();
The reaper thread is doing something like:
exited_thread = (cyg_handle_t) cyg_mbox_get(reaper_mbox);
cyg_thread_delete(exited_thread);
The put operation will wake up the reaper, which runs at a higher
priority thread, so the exiting thread will be preempted before it
can call cyg_thread_exit(). The reaper now tries to call
cyg_thread_delete() on a thread which has not actually exited yet, so
this call fails.
Bart
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss