This is the mail archive of the
ecos-discuss@sourceware.cygnus.com
mailing list for the eCos project.
Re: Creating workers threads dynamically
- To: ecos-discuss at sourceware dot cygnus dot com
- Subject: Re: [ECOS] Creating workers threads dynamically
- From: "Rosimildo daSilva" <rosimildo at hotmail dot com>
- Date: Wed, 17 May 2000 16:24:31 CDT
>From: Nick Garnett <nickg@cygnus.co.uk>
>To: ecos-discuss@sourceware.cygnus.com
>Subject: Re: [ECOS] Creating workers threads dynamically
>Date: 16 May 2000 15:22:17 +0100
>
>There is no mechanism in eCos for a thread to delete itself. This is
>because dealing with the case where the currently running thread has
>destroyed its own data structures could become very complex and is
>very prone to being broken. Instead, we expect another thread to call
>cyg_thread_delete() on an exited thread to finish off its destruction.
>
>
>I can think of at least three alternative ways of implementing what you
>want to do:
>
>1. The simplest is to not exit your worker threads but to simply halt
> them on a mailbox when they are idle. When you want a thread to do
> something you send a message to the mailbox indicating the task to
> be done and the first worker thread will simply wake up and do it.
>
>2. Have a "reaper" thread that waits on a mailbox. When a worker
> thread is about to exit it posts it handle to the mailbox and calls
> cyg_thread_exit(). The reaper simply wakes up and calls
> cyg_thread_delete() on the handle it receives.
>
>3. Allow each thread to call cyg_thread_exit() when it is
> finished. When a new worker is required, call cyg_thread_resume()
> on an exited thread, and allow it to find out what it is meant to
> do from some static variables.
>
>There are lots of alternative variants of these basic models - I would
>prefer option 1 as being the cleanest of the three.
>
Thanks to all that replied.
Ok, now I have a few options to select from....
Rosimildo.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com