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]

Re: newbie thread question


> Does the thread remain registered with the scheduler ? What I want to avoid
> is the scheduler scheduling thousands of exited threads. As far as I can see
> from the docs, to remove a thread from the scheduler you need
> cyg_thread_kill.


Here is what the manual says.....

void cyg_thread_kill( 
    cyg_handle_t thread )

Kills thread. 

cyg_bool_t cyg_thread_delete( 
    cyg_handle_t thread


Kills thread and deletes it from the scheduler. If necessary, it will
kill thread first using cyg_thread_kill(thread).  If thread does not
terminate in response to the kill message, this function returns
false, indicating failure.

This function differs from cyg_thread_kill() (or calling
cyg_thread_exit() for the current thread) by deregistering the thread
from the scheduler. As a result, the thread handle, thread stack and
space passed for the thread housekeeping information can then be
reused.  This is not the case if just cyg_thread_kill()or
cyg_thread_exit()is invoked for the thread.

NOTE

cyg_thread_delete() only deregisters the thread from the scheduler, it
does not free up any resources that had been allocated by the thread
such as dynamic memory, nor does it unlock any synchronization objects
owned by the thread. This is the responsibility of the
programmer. Additionally, unlike cyg_thread_kill(), the
cyg_thread_delete() function cannot be self-referencing.

EXAMPLE

// Delete another thread. This must be done in a loop, waiting for
// the call to return true. If it returns false, go to sleep for a
// while, so that the killed thread gets a chance to run and 
// complete its business.
while (!cyg_thread_delete(<tyhread_handle>) {
cyg_thread_delay(1);
} 


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