Two Coding Problems

Aliasgar Nasir aliasgar.nasir at patni.com
Thu Jan 12 07:52:21 UTC 2006


Hi,
Yes u can access the TCBs but onlx through extension routines for eg a
task switch extension routines...and these are mainly used for diagnostics
or storing some task switch information...if u want u can create an
extension for the same...but the extension will be called at every task
switch...and do not try to modify these data as it could be harmful...

Regards
Ali


> Hi,all
>    I have two questions here
>
> 1. How can I get the TCB of a certain task? Is there any directive such
> like "rtems_task_get_tcb"?
>
> 2. I wrote an APP, In Init() I create a new task then start it.The
> function
> of the new task is to create a new task, too.
>    Now the Init Task is named T0, the task created by T0 is named T1, and
> the task created by T1 is named T2.
>    When running my app on SPARC leon2, the ID information is as follows:
> 	T0	ID = a010001
> 	T1	ID = a010002
> 	T2	ID = a010001
>    I don't know why T2's ID is just the same as T0.
>
>    The main functions are here:
>
> rtems_task get_task_info(rtems_task_argument argument)
> {
>     rtems_id              tid;
>     rtems_task_priority   priority;
>     rtems_status_code     status;
>     status = rtems_task_ident(RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid);
>     status =
> rtems_task_set_priority(tid,RTEMS_CURRENT_PRIORITY,&priority);
>     printf("\tTask ID: %x\tpriority: %d\n",tid,priority);
>     status = rtems_task_delete(RTEMS_SELF);
> }
>
> rtems_task create_task(rtems_task_argument argument)
> {
>     rtems_name            name = rtems_build_name('T','S','T',' ');
>     rtems_id              tid;
>     rtems_task_priority   priority;
>     rtems_status_code     status;
>     status = rtems_task_ident(RTEMS_SELF,RTEMS_SEARCH_ALL_NODES,&tid);
>     status =
> rtems_task_set_priority(tid,RTEMS_CURRENT_PRIORITY,&priority);
>     status = rtems_task_create(name,priority,RTEMS_MINIMUM_STACK_SIZE,
> 				RTEMS_PREEMPT,RTEMS_DEFAULT_ATTRIBUTES,&tid);
>     if(status!=RTEMS_SUCCESSFUL)
>       printf("Create task failed with status %d\n",status);
>     else
>       printf("Create Task %x with priority %d
> successfully!\n",tid,priority);
>     status = rtems_task_start(tid,get_task_info,argument);
>     if(status!=RTEMS_SUCCESSFUL)
>       printf("\tTask %x (%d) start failed with status
> %d\n",tid,priority,status);
>     else
>       printf("\tTask %x (%d) start successfully!\n",tid,priority);
>     status = rtems_task_delete(RTEMS_SELF);
> }
>
> rtems_task Init(rtems_task_argument argument)
> {
>   rtems_name            task_name;
>   rtems_status_code     status;
>   rtems_id              tid;
>   rtems_task_priority   priority;
>
>   status = rtems_task_ident(RTEMS_SELF,RTEMS_SEARCH_ALL_NODES,&tid);
>   status = rtems_task_set_priority(tid,RTEMS_CURRENT_PRIORITY,&priority);
>
>   printf("\nInit Task ID = %x\tprioirty = %d\n\n",tid,priority);
>
>   task_name = rtems_build_name( 'T', 'A', '1', ' ' );
>   priority = 1;
>   status = rtems_task_create(task_name, priority,RTEMS_MINIMUM_STACK_SIZE,
> 		RTEMS_INTERRUPT_LEVEL(0),RTEMS_DEFAULT_ATTRIBUTES, &tid);
>
>   if ( status != RTEMS_SUCCESSFUL )
>   {
>     printf("\tTask create failed with the status of %d\n",status);
>     exit(1);
>   }
>   else
>   {
>     printf("\tThe Task just created ID: %x\tpriority: %d\n",tid,priority);
>     status =
> rtems_task_set_priority(tid,RTEMS_CURRENT_PRIORITY,&priority);
>   }
>
>   status = rtems_task_start( tid, create_task, 0);
>
>   if (status != RTEMS_SUCCESSFUL )
>   {
>      printf("\tTask %x start failed with the stauts of %d\n",tid,status);
>      exit(1);
>   }
>   status = rtems_task_delete( RTEMS_SELF );
> }
>
>
>   Thanks a lot !
>   SunPeng
>
> _________________________________________________________________
> ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:  http://messenger.msn.com/cn
>
>




More information about the users mailing list