[ECOS] timed restart of a thread from within a thread

Aaron Case aaron.case@dynazign.com
Fri Aug 1 15:36:00 GMT 2003


Hello eCos Dudes,

I would have thought my following question, or one similar, would have
already be asked and answered on the list. Yet I found no helpful
information.  In the event I botched the search for this topic and it is in
the mail archive, I apologize and request that I be directed to the
solution.

I am porting an embedded product from MTOS, circa 1982, to eCos.  MTOS has a
service ENDR(end task(thread in eCos) with timed restart from within the
task).

This service is critical to the product's operation and I wanted to seek
advice on how to achieve this with the eCos Kernel thread API functions.
The listing in the Massa book has no restart thread and with further
analysis it has been concluded that there is no single function to do this,
explicitly.

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.

Once kill, exit, or delete are called there is obviously no way to execute
anymore code, and therefore restart itself.

The suspend/resume functions don't reset thread execution to the entry
point, so that's obviously not an option.

One possible solution would be to use the thread_delay and recreate the task
for the purpose of setting thread execution to the entry point.  Is it
possible to recreate a thread from within a thread using the same handle, or
will eCos create another thread with the same handle, causing all sorts of
undefined behavior.

Or, do I have to create another task for the sole purpose of restarting
tasks through use of semaphore or flags.

This is where I stop, and ask the eCos experts, before I go making wholesale
task synchronization changes to legacy code with thousands and thousands of
man hours.

So, in conclusion, I am looking for a mechanism in eCos whereby a thread can
say to itself "uh oh, something bad happened, I have to restart in a minute
and try this again" while many others threads continue on their happy way.

Thanks in advance for any help and suggestions,

Aaron Case


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss



More information about the Ecos-discuss mailing list