rtems_task_delete does not remove thread (rtems 4.6.0pre5)

Joel Sherrill <joel@OARcorp.com> joel.sherrill at OARcorp.com
Sat Sep 18 12:38:34 UTC 2004


Valery Pykhtin wrote:
> Hi All,
> 
> Currently I'm trying to accomplish this test:
> 
> rtems_task ThreadFx(rtems_task_argument)
> {
>       printf("starting\n");  printf("exiting\n");
> }
> 
> int Cycle()
> {
>     rtems_status_code rv; rtems_id tr;
>     rv =
> rtems_task_create(rtems_build_name('t','e','s','t'),120,4096,0,0,&tr);
>     if (rv!=RTEMS_SUCCESSFUL) { printf("create failure %d\n",rv);  return
> ;  }
>    rtems_task_start(tr,ThreadFx,0);
>    rtems_task_wake_after(2000);
>    rv = rtems_task_delete(tr);
>    if (rv!=RTEMS_SUCCESSFUL) { printf("delete failure %d\n",rv); }
>    return 1;
> }
> void ThreadTest()
> {
>     while(Cycle());
> }
> 
> The problem is that rtems_task_delete does not remove the task reporing
> RTEMS_INVALID_ID.

This isn't a complete program but I have some guesses.  The ThreadFx is
voluntarily falling off the bottom of the task.  For a classic API
task, this is a fatal error.

> The worst thing in this case is that the space allocated to the task isn't
> freed too. After a few Cycles
> rtems_task_create reports RTEMS_TOO_MANY.
 >
> If I remove rtems_task_wake_after(2000) - all goes well... but this is not
> what I want.

If you delete that, the thread created is probably never running.  If it
doesn't run, it can't fall out of the function and the system doesn't
generate a fatal error.

> Is the idea I should put rtem_task_delete into the ThreadFx() ? I've tried
> it and all goes well...

Makes sense given my first statement above.

> 
> Best regards,
> Valery
> 
> 


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985




More information about the users mailing list