[ECOS] How to "atomize" the end of a thread...
Boris V. Guzhov
borg@int.spb.ru
Thu Oct 4 00:27:00 GMT 2001
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
>
More information about the Ecos-discuss
mailing list