This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: timed restart of a thread from within a thread
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Aaron Case <aaron dot case at dynazign dot com>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Fri, 1 Aug 2003 19:09:51 +0200
- Subject: Re: [ECOS] timed restart of a thread from within a thread
- References: <GBEOKKOEOGFDMKDFCHIMAECKCAAA.aaron.case@dynazign.com>
> The MTOS call, ENDR, is called within the task, the task is removed from the
> scheduler, and restarted after a given amount of time specified to the ENDR
> call.
Sound dangerous to me. What happens about locked mutex, memory that
has been allocated, timers that are active, open files etc.
Also what about initialised variables? I could imaging code like:
my_func(cyg_addrword data) {
static int init=0;
if (!init) {
init++;
do_init_func();
}
This will obviously go wrong since init will != 0.
Seems like a good way to shoot yourself in the foot.
Having said that, if you do want to shoot yourself in the foot you
could use setjmp() longjump(). The first thing the thread does is do a
setjmp. Then put a pointer to it into a thread data variable. You
ENDR function can then do a cyg_thread_delay() followed by a longjump(),
using the thread data pointer.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss