This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: "Threads on ecos" confirmation needed...
Hello!
In message to "Slawek" <sgp@telsatgp.com.pl>; "ecos-discuss"
<ecos-discuss@sources.redhat.com> sent Fri, 30 Jan 2004 20:56:46 +0100 you wrote:
??>> Im my opinion there is no need to alter eCos behaviour. eCos does
??>> *not* need malloc/free so kernel should not use it. Threads' data can
??>> be allocated in global storage and/or on stacks and *nobody* should
??>> free that. Obviously you can implement auto-free feature if you want.
??>> There is even no need to modify existing eCos code!
IH> I didn't mean to use malloc/free. If I recall well, there is a hard
IH> limit on number of
IH> threads that can be created in ecos (correct me if I'm wrong). So, one
IH> can declare an
IH> array of Cyg_Thread objects (firts thought, also:-):
IH> Cyg_Thread thr_slots[MAX_THREADS];
IH> with number of elements that is equal to maximum number of threads.
IH> Then, changes
IH> are quite simple. For example, cyg_thread_create() could be modified
IH> first to find a
IH> free "slot". Then, instead of placing the object into user supplied
IH> space pointed by
Of course, but you can't do that with stacks (well, you can if you use the
same stack size for each thread).
Even if you could you'd still need per-thread clean-up code.
IH> The stack could be freed/cleaned by the exiting thread before calling
IH> *exit() (I think) and
IH> the above solution would "free" the space for thread object.
You're calling the thread->exit() so the return address is placed on the
stack.
IH> I would like
IH> to have the similar functionality provided by e.g Linux or Solaris; one
IH> can create a
IH> detached thread, and don't have to worry about its completion, as
IH> kernel resources are
IH> automatically cleaned-up.
You can create a wrapper around the 'thread' object and modify "exit"
function.
The "garbage collector" could be included inside the "idle" thread.
--
Slawomir Piotrowski
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss