This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Create a thread (uitron)


Hi all,

I succeded to create a uITRON thread!!!
My options :

"Number of tasks" --> 4
"Start tasks" -> 1
...
...
"Externs for initialization" ->
extern "C" void RTDS_Start( unsigned int ); \
extern "C" void task2( unsigned int ); \
extern "C" void task3( unsigned int ); \
extern "C" void task4( unsigned int ); \
static char stack1[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack2[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack3[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ], \
stack4[ MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ];


"Static initializers" ->
CYG_UIT_TASK( "t1", 1, RTDS_Start, &stack1, MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t2", &stack2, MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t3", &stack3, MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ), \
CYG_UIT_TASK_NOEXS("t4", &stack4, MAX(CYGNUM_UITRON_STACK_SIZE, CYGNUM_HAL_STACK_SIZE_MINIMUM) ),


So with these parameters I can use 3 ID (2,3 and 4) to create a miximum of 3 threads
Then to start the RTDS_Start thread I just have to call the cyg_uitron_start() function (see the main function below)....
But I cannot understand the behavior of my test program... I try to create another task in the main (it work well!!!) but if I do it on RTDS_Start it does not work!!!


This is my program :

#include <cyg/compat/uitron/uit_func.h>
#include <stdio.h>

void task2(unsigned int a)
{
 printf("In function test()\n");
}

void task1(unsigned int b)
{

 printf("Hello from task1\n");
}

void RTDS_Start()
{
 ID tid = 2;
 T_CTSK thread_attr;
 int retval;

printf("Hello from RTDS_Start\n");

 thread_attr.stksz = 1000;
 thread_attr.itskpri = 5;
 thread_attr.task = (FP)&task2;
 retval = cre_tsk(tid, &thread_attr);

if(retval != E_OK)
{
printf("Error in RTDS_Start %d !!!\n",retval);
}
else
{
printf("Good in RTDS_Start! \n");
sta_tsk(tid,NULL);
} }



int main() { ID tid = 3; T_CTSK thread_attr; int retval;

 printf("In main\n");
 cyg_uitron_start();

 thread_attr.stksz = 1000;
 thread_attr.itskpri = 5;
 thread_attr.task = (FP)&task1;
 retval = cre_tsk(tid, &thread_attr);

 if(retval != E_OK)
   {
     printf("Error in main %d !!!\n",retval);
   }
 else
   {
     printf("Good in main! \n");
     sta_tsk(tid,NULL);
   }
 return 0;
}

Some ideas ?
PS : Does someone know the function of the 2nd argument in |*sta_tsk*|(ID tskid, INT stacd) function ?


Thanks a lot.
David


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]