代码改变世界

RTP affinity

2011-08-24 12:59  Jeff  阅读(635)  评论(0编辑  收藏  举报
以下代码证明: RTP affinity inherits from the task that created it. 创建一个RTP,代码:
 
#include "taskLib.h"
int main()
{
   while(1){
	   taskDelay(1);
   }
	taskSuspend(taskIdSelf());
}
创建一个VIP,在usrAppInit.c中调用myroot(). myroot函数定义在文件taskcreate.c中,具体代码如下方法:
 
#include 
#if defined(PRJ_BUILD)
#include "prjParams.h"
#endif /* defined PRJ_BUILD */
#include 
#include 
#include "taskLib.h"
int task_parent;
RTP_ID rtpdemoid;
int entrycl();
char *argv1;
int result;
void myroot (void)
    {
	char * argv1[] = {"/romfs/demo_rtp.vxe","0",NULL};
	 cpuset_t affinity;
	 printf("1");
	 task_parent = taskCreate("jeffchen",60,0,200,&entrycl,0,0,
         0,0,0,0,0,0,0,0);
	 printf("2");
	 if (task_parent == NULL)
	 return (ERROR);	 		 	
	 CPUSET_ZERO (affinity);
	 CPUSET_SET (affinity, 2);	   
	 printf("8");
	 if (taskCpuAffinitySet (task_parent, affinity) == ERROR)
	 {
	 printf("30");
	 return (ERROR);
	 }
	 printf("4");
	 result =taskActivate (task_parent);
	 printf("%d", result);
	 printf("5");
    }

int entrycl(){
	
    char * argv1[] = {"/romfs/demo_rtp.vxe","0",NULL};
    printf("6");
    if((rtpdemoid=rtpSpawn(argv1[0], argv1, NULL, 96, 0x5000, 0, 0))==
 NULL){
	};
	
	printf("7");
	while(1){
		taskDelay(100);
	}
return 0;
}