This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
How to "atomize" the end of a thread...
- To: "Ecos-List (E-mail)" <ecos-discuss at sourceware dot cygnus dot com>
- Subject: [ECOS] How to "atomize" the end of a thread...
- From: Fabrice Gautier <Fabrice_Gautier at sdesigns dot com>
- Date: Wed, 3 Oct 2001 21:53:53 -0700
Hi,
Let's say i have a thread, past a certain point in this thread I want to
lock the scheduler so that the thread will go to the end uninterrupted (I
want to atomize the last few lines of this thread).
I don't want to do :
void thread1 ( int arg)
{
...
cyg_sched_lock();
atomic_function();
cyg_sched_unlock();
}
because I really want the thread to really return end before any other do
anything.
What happen if I do that with
void thread1 ( int arg)
{
...
cyg_sched_lock();
atomic_function();
}
?
You may have guessed that i'm trying to do a very bad thing. In this case i
want to free the stack used by the thread at the end of the thread, and this
would go bad if someone were reusing this memory before the last function
returned and the thread was deleted from the scheduler.
--
Fabrice Gautier
Software Engineer, Sigma Designs
Fabrice_Gautier@sdesigns.com