This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: timed restart of a thread from within a thread


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]