[ECOS] cyg_thread_delete

Bart Veer bartv@redhat.com
Mon Mar 11 14:18:00 GMT 2002


>>>>> "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



More information about the Ecos-discuss mailing list