This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Seeking Thread join / waitpid equivalent.
- From: sandeep <sandeep at codito dot com>
- To: John Carter <john dot carter at tait dot co dot nz>
- Cc: ecos-discuss at ecos dot sourceware dot org
- Date: Fri, 03 Sep 2004 11:15:45 +0530
- Subject: Re: [ECOS] Seeking Thread join / waitpid equivalent.
- References: <Pine.LNX.4.61.0408271154320.9153@parore.tait.co.nz> <20040827004729.GA24331@mail.dadadada.net> <Pine.LNX.4.61.0408271339420.24274@parore.tait.co.nz> <Pine.LNX.4.61.0408271522040.25016@parore.tait.co.nz>
John Carter wrote:
I have just found this rather ugly code in the tftp_server.c
So it kills the tftp server thread...
cyg_thread_kill(server->thread_handle);
whangs the priority of the thread it killed as high as possible.
cyg_thread_set_priority(server->thread_handle, 0);
Waits a random period for it to die
cyg_thread_delay(1); // Make sure it gets to die...
how can you ensure that delay of 1 or N ticks that you put here, makes sure that
it gets to die??? unless ofcourse you never have any thread in your system that
runs at priority 0 (highest) apart from these cases where you boost priority of
thread you killed, to 0.
for, if you have some threads running at priority 0 already, you need to know
the maximum no. of them that can be there in runqueue at any point of time, that
will be before your boosted-priority thread (considering round robin scheduling
and no-SMP) to find a sure-value that can be given to above cyg_thread_delay.
Deletes the thread...
if (cyg_thread_delete(server->thread_handle)) {
If deleting the thread actually worked...
// Success shutting down the thread
Frees the memory associated with the thread..
free(server); // Give up memory
return 1;
}
Else ... we have a memory leak.
--
sandeep
--------------------------------------------------------------------------
"I do not know myself, and God forbid that I should."
--------------------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss