<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div style="RIGHT: auto"><SPAN style="RIGHT: auto">Hi,</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">I am not sure, what does it wait for as i cannot see the task in the OS. There is a call to fwalk (which is called from _reclaim_reent) from the newlib_delete_hook which never returns. There is no crash of the system. </SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">I also noticed that further dynamic memory allocations are blocked for the tasks which are already launched. </SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">I see if there is an fprintf call from this task, only then we see the problem. If there is no fprintf, then everything works fine. This could be the clue to find the problem. </SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">Below is the code which you can look at. I have not shown launch of other tasks which are launched in the context of the InitMainTask. These are basically network daemons, ramdisk, flashdisk initializations. But as i said, if we remove the fprintf, then the newlib_delete_hook will return back. The delete of the Init however works fine.</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"></SPAN> </div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">Init(rtems_task_argument ignored)<BR>{<BR>    rtems_mode old_mode;<BR>    rtems_task_mode( RTEMS_INTERRUPT_LEVEL(6),RTEMS_INTERRUPT_MASK, &old_mode);<BR>    /* This function does the initialization of the hardware and launching of the application's main thread */<BR>    init_main();<BR>    rtems_task_mode( RTEMS_INTERRUPT_LEVEL(0),RTEMS_INTERRUPT_MASK, &old_mode);<BR>    rtems_task_delete( RTEMS_SELF );<BR>}</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">init_main()<BR>{<BR> const char namestring[] = "Tsk1";<BR> rtems_status_code    status;<BR>        rtems_name name = rtems_build_name(<BR>          namestring[0],<BR>          namestring[1],<BR>          namestring[2],<BR>          namestring[3]);</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"> rtems_id            rtos_task_id;</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">        status = rtems_task_create( name, 1,<BR>            4096,<BR>            RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |RTEMS_INTERRUPT_LEVEL(0),<BR>            RTEMS_FLOATING_POINT | RTEMS_LOCAL,<BR>            &rtos_task_id);</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"> rtems_task_mode(RTEMS_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode);<BR> status = rtems_task_start(rtos_task_id, (rtems_task_entry)InitMainTask, 0);<BR>}</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto">InitMainTask()<BR>{<BR>        freopen ("/dev/ttyS0","r",stdin);<BR>        freopen ("/dev/ttyS0","w",stdout);<BR>        freopen ("/dev/ttyS0","w",stderr);<BR> fprintf(stdout, "This is INit Main Task");</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><SPAN style="RIGHT: auto"> rtems_task_delete(RTEMS_SELF);<BR>}</SPAN></div>
<div style="BACKGROUND-COLOR: transparent; FONT-STYLE: normal; FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; COLOR: rgb(0,0,0); FONT-SIZE: 16px"><BR style="RIGHT: auto"></div>
<DIV style="FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; FONT-SIZE: 12pt">
<DIV style="FONT-FAMILY: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; FONT-SIZE: 12pt">
<DIV style="RIGHT: auto" dir=ltr>
<DIV style="LINE-HEIGHT: 0; MARGIN: 5px 0px; HEIGHT: 0px; FONT-SIZE: 0px" contentEditable=false readonly="true"></DIV><FONT size=2 face=Arial><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Sebastian Huber <sebastian.huber@embedded-brains.de><BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> rtems-users@rtems.org <BR><B><SPAN style="FONT-WEIGHT: bold">Sent:</SPAN></B> Wednesday, April 23, 2014 11:49 AM<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: Issue with Task delete<BR></FONT></DIV>
<DIV><BR>Hello Ali,<BR clear=none><BR clear=none>On 2014-04-23 07:41, ali nasir wrote:<BR clear=none>> Hi,<BR clear=none>> In the RTEMS4.11 i notice one of the task does not delete itself cleanly via a<BR clear=none>> call to the rtems_task_delete. On further investigation i found that the<BR clear=none>> newlib_delete_hook does not return. The newlib_delete_hook calls a fclose and<BR clear=none>> from this fclose, there is no return.<BR clear=none><BR clear=none>what do you mean with "no return".  Waits the task on a resource forever, does <BR clear=none>it busy wait or does the system crash (e.g. call to _Terminate())?<BR clear=none><BR clear=none>There is a test case for this in:<BR clear=none><BR clear=none>testsuites/libtests/newlib01/init.c 
<DIV id=yqtfd58654><BR clear=none><BR clear=none>>  From this particular task, we have called the frepon to redirect the to<BR clear=none>> stdout, stdin and stderr to dev/tty0<BR clear=none>>          freopen ("/dev/ttyS0","r",stdin);<BR clear=none>>          freopen ("/dev/ttyS0","w",stdout);<BR clear=none>>          freopen ("/dev/ttyS0","w",stderr);<BR clear=none>> With the same code, the task used to get deleted cleanly with the RTEMS4.10.2<BR clear=none>> version.<BR clear=none>> If i remove the above lines of code from the task (with the RTEMS4.11), then<BR clear=none>> the task gets deleted cleanly.<BR clear=none>> This task is a higher priority task, and all further task scheduling gets<BR clear=none>> affected if the task does not get deleted cleanly.<BR clear=none>> Any idea what wrong do i do?</DIV><BR clear=none><BR
 clear=none>If you can send me a self contained test case, then I can try to look at it.<BR clear=none><BR clear=none>-- <BR clear=none>Sebastian Huber, embedded brains GmbH<BR clear=none><BR clear=none>Address : Dornierstr. 4, D-82178 Puchheim, Germany<BR clear=none>Phone  : +49 89 189 47 41-16<BR clear=none>Fax    : +49 89 189 47 41-09<BR clear=none>E-Mail  : <A href="mailto:sebastian.huber@embedded-brains.de" shape=rect ymailto="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</A><BR clear=none>PGP    : Public key available on request.<BR clear=none><BR clear=none>Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<BR clear=none>_______________________________________________<BR clear=none>rtems-users mailing list<BR clear=none><A href="mailto:rtems-users@rtems.org" shape=rect ymailto="mailto:rtems-users@rtems.org">rtems-users@rtems.org</A><BR clear=none><A
 href="http://www.rtems.org/mailman/listinfo/rtems-users" shape=rect target=_blank>http://www.rtems.org/mailman/listinfo/rtems-users</A><BR><BR></DIV></DIV></DIV></div></body></html>