This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: How to "atomize" the end of a thread...
- To: <ecos-discuss at sourceware dot cygnus dot com>, "Fabrice Gautier" <Fabrice_Gautier at sdesigns dot com>
- Subject: Re: [ECOS] How to "atomize" the end of a thread...
- From: "Boris V. Guzhov" <borg at int dot spb dot ru>
- Date: Thu, 4 Oct 2001 11:17:53 +0400
- References: <B1F6452C89AFD411AE0800A0CC734C230150F6@EMAIL1>
Hi,
There is a simple way:
void thread1 ( int arg)
{
...
cyg_thread_set_priority(cyg_thread_self(), 0);
atomic_function();
}
--
Boris Guzhov,
St.Petersburg, Russia
> 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
>