From: "Mik Prog" <mikprog@gmail.com>
To: ecos-devel@ecos.sourceware.org
Subject: Re: exception rises calling cyg_thread_delete()
Date: Sat, 23 Jun 2007 10:21:00 -0000 [thread overview]
Message-ID: <6a7f58da0706230321h1aee61a9j4b7748cac6b98cbb@mail.gmail.com> (raw)
In-Reply-To: <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
prev parent reply other threads:[~2007-06-23 10:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-21 14:32 Mik Prog
2007-06-21 14:36 ` Gary Thomas
2007-06-23 10:21 ` Mik Prog [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a7f58da0706230321h1aee61a9j4b7748cac6b98cbb@mail.gmail.com \
--to=mikprog@gmail.com \
--cc=ecos-devel@ecos.sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).