This is the mail archive of the
ecos-devel@sourceware.org
mailing list for the eCos project.
Re: exception rises calling cyg_thread_delete()
- From: "Mik Prog" <mikprog at gmail dot com>
- To: ecos-devel at ecos dot sourceware dot org
- Date: Sat, 23 Jun 2007 11:21:20 +0100
- Subject: Re: exception rises calling cyg_thread_delete()
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=suFECYN9Z9EJrGkRvzvPuRPKt0HMDzXNT4HTaitzEjKIiVApFnOec1/5fvIXUCLen6LzT5SM1bQu9eSgrUoYsc+tXniQMNir0ZUO2IcacrmedUr6InBFDge29k1Sy9r34g73ynMk3OX8XxfLW9ErJYKjp4ifNz4DybhPAYbSHEc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=IToRyqm/SFHwwPRVg8HfYZte5H3RA6R5iHUy7g44lEfWx8HMbXrKOl4TNVZlaDncbVHjFUZi4X7OJcWXSt5yUl3LV3RRAIPrDvVmWNiLo+Z90QUxa11jHc5Q4wqp9nFBRWmISuSO+QiKMiFlo1r4n0nOcLCWiqhifeQxKaJiGzo=
- References: <6a7f58da0706210732q1c7f9692sab5e1cb39499f003@mail.gmail.com> <467A8D00.6060705@mlbassoc.com>
On 6/21/07, Gary Thomas <gary@mlbassoc.com> wrote:
[..]
Are you sure your handle is correct? I think you may be
dereferencing it improperly.
Thank you Gary.
I've been through the pointers over and over again.
At the end I've decided to use a static array of cyg_handle_t for
thread creation/deletion... where my starting pointer points to (I
can't get rid of it).
So:
#define MAX_NUM_THREADS 10
static cyg_thread ThreadsHolder[MAX_NUM_THREADS];
static cyg_handle_t HandlesHolder[MAX_NUM_THREADS];
static I2 threadCounter = 0; //number of allocated threads
// Threads creation
{
[..]
HandlesHolder[threadCounter] = 0;
cyg_thread_create ((cyg_addrword_t)prio,
(cyg_thread_entry_t*)pd,
(cyg_addrword_t)pData,
(char*)pName,
(void*)pbos,
(cyg_ucount32)stksize,
&HandlesHolder[threadCounter],
&ThreadsHolder[threadCounter]
);
*pHandle = &(HandlesHolder[threadCounter]);
threadCounter++;
cyg_thread_resume ( HandlesHolder[threadCounter-1] );
[..]
}
//****************************************
// Threads deletion
int pTask_Delete (TaskHandle_t **pHandle)
{
threadCounter--;
// I search for the index of the handle of the thread to be deleted
for ( i=0; i<MAX_NUM_THREADS; i++)
{
if ( **pHandle == &(HandlesHolder[i]) )
break;
}
while ( ! cyg_thread_delete ( HandlesHolder[i] ) )
{
diag_printf("\nERROR: Thread deletion failed! sleep... "); //I
NEVER GET THIS
cyg_thread_delay(1);
}
diag_printf("\n\n\n _OK_ "); //NEVER GET THIS
HandlesHolder[i] = 0;
[..]
}
So what happens is that the cyg_thread_delete() call happens with the
proper handle (checked using debugger), but the call never returns!
The same happens with cyg_thread_kill.
Also, adding a cyg_thread_release() before the kill/delete call...
doesn' t help: but it does return.
To resume all threads go to deletion procedure, but none of the
returns... the process execution goes on and then when it tries to
allocate some memory in the thread heap crashes. And I start crying.
Any idea guys?
Thanks for your help!
Mik