示例#1
0
文件: main.c 项目: kringle/sannsys15
void print_pri(RT_TASK *task, char *s)
{ 
	struct rt_task_info temp;
	rt_task_inquire(task, &temp);
	rt_printf("b:%i c:%i ", temp.bprio, temp.cprio);
	rt_printf(s);
}
示例#2
0
文件: ex01b.c 项目: natanaeladit/des
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  int retval;

  // hello world
  rt_printf("Hello World!\n");

  // inquire current task
  // below is commented and makes error
  // curtask=rt_task_self();
  retval = rt_task_inquire(curtask,&curtaskinfo);

  /* send error message */	    
  if (retval < 0 ) 
  {
      rt_printf("Sending error %d : %s\n",-retval,strerror(-retval));
  } else {
      rt_printf("taskOne sent message to taskTwo\n");
  }
  
  // print task name
  rt_printf("Task name : %s \n", curtaskinfo.name);
  
}
示例#3
0
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
 
  // hello world
  rt_printf("Hello World!\n");
 
  // inquire current task

/* Exercise 1B:
 * Comment out the below line: */  
  //curtask=rt_task_self();
 /* Result: nothing too exciting, the taskname can no longer be provided */
  int retval;
  retval = rt_task_inquire(curtask,&curtaskinfo);

  if (retval < 0 ) 
  {
      rt_printf("Error %d : %s\n",-retval,strerror(-retval));
  } else {
      rt_printf("Task name : %s \n", curtaskinfo.name);
  }
  
}
示例#4
0
int _rtapi_task_update_stats_hook(void)
{
    int task_id = _rtapi_task_self();

    // paranoia
    if ((task_id < 0) || (task_id > RTAPI_MAX_TASKS)) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"_rtapi_task_update_stats_hook: BUG -"
			" task_id out of range: %d\n",
			task_id);
	return -ENOENT;
    }

    RT_TASK_INFO rtinfo;
    int retval = rt_task_inquire(ostask_array[task_id], &rtinfo);
    if (retval) {
	rtapi_print_msg(RTAPI_MSG_ERR,
			"rt_task_inquire() failed: %d\n",
			retval);
	return -ESRCH;
    }

    rtapi_threadstatus_t *ts = &global_data->thread_status[task_id];

    ts->flavor.xeno.modeswitches = rtinfo.modeswitches;
    ts->flavor.xeno.ctxswitches = rtinfo.ctxswitches;
    ts->flavor.xeno.pagefaults = rtinfo.pagefaults;
    ts->flavor.xeno.exectime = rtinfo.exectime;
    ts->flavor.xeno.modeswitches = rtinfo.modeswitches;
    ts->flavor.xeno.status = rtinfo.status;

    ts->num_updates++;

    return task_id;
}
void task_body(void *cookie) {

  RT_TASK *current_task;
  RT_TASK_INFO current_task_info;

  current_task = rt_task_self();
  rt_task_inquire(current_task, &current_task_info);

  rt_printf("Task name: %s started with priority %d\n",
    current_task_info.name,
    current_task_info.cprio
  );
  
  for (int i = 0; i < ITERATIONS; i++) {
    rt_mutex_bind(&mutex, "mutex", TM_NONBLOCK);
	long int r = shared_resource;
    r = r + 1;
    shared_resource = r;
	rt_mutex_unbind(&mutex);
    rt_task_sleep(DELAY);
  }

  rt_printf("Task name: %s is shutting down\n", current_task_info.name);

}
示例#6
0
文件: main.c 项目: eirikpre/TTK4147
void print_pri(RT_TASK *task, char s)
{
	struct rt_task_info temp;
	rt_task_inquire(task, &temp);
	rt_printf("b:%i c:%i ", temp.bprio, temp.cprio);
	rt_printf("Task is done: %c\n",s );
}
示例#7
0
文件: ex02a.c 项目: dopefishh/des2015
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  curtask=rt_task_self();
  rt_task_inquire(curtask, &curtaskinfo);
  rt_printf("Task name : %s\n", curtaskinfo.name);
}
示例#8
0
 	INTERNAL_QUAL int rtos_task_get_priority(const RTOS_TASK* mytask) {
         RT_TASK_INFO info;
         // WORK AROUND constness: (need non-const mytask)
         RT_TASK* tt = mytask->xenoptr;
         if ( tt )
             if ( rt_task_inquire ( tt, &info) == 0 )
                 return info.bprio;
         return -1;
     }
示例#9
0
文件: ex02c.c 项目: dopefishh/des2015
void demo(void *arg)
{
	int num = *(int *)arg;
	RT_TASK *curtask;
	RT_TASK_INFO curtaskinfo;
	curtask=rt_task_self();
	rt_task_inquire(curtask,&curtaskinfo);
	rt_printf("Task name: %s with num %d \n",
		curtaskinfo.name, num);
}
示例#10
0
void task(void *arg)
{
  int a = * (int *) arg;

  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  curtask=rt_task_self();
  rt_task_inquire(curtask,&curtaskinfo);
  rt_printf("Task name: %s arg: %d \n", curtaskinfo.name, a);
  
}
示例#11
0
文件: ex03c.c 项目: dopefishh/des2015
void demo(void *arg)
{
	int num = * (int *)arg;
	RT_TASK *curtask;
	RT_TASK_INFO curtaskinfo;
	curtask=rt_task_self();
	rt_task_inquire(curtask, &curtaskinfo);
	rt_sem_p(&sem, TM_INFINITE);
	rt_printf("Task name: %s - Argument %d\n", curtaskinfo.name, num);
	rt_sem_v(&sem);
}
示例#12
0
void fonction_thread (void * arg)
{
	int err;
	int numero = (int) arg;
	RT_TASK_INFO rtinfo;

	rt_task_inquire(NULL, & rtinfo);
	rt_printf("[%d] Priorite initiale %d\n", numero, rtinfo.cprio);

	while(1) {
		
		if ((err = rt_alarm_wait(& alarme)) != 0) {
			fprintf(stderr, "rt_alarm_wait(): %s\n",
			                strerror(-err));
			exit(EXIT_FAILURE);
		}
		rt_task_inquire(NULL, & rtinfo);
		rt_printf("[%d] priorite : %d, heure : %llu\n", numero, rtinfo.cprio, rt_timer_read());
	}	
}
// function to be executed by task
void helloWorld(void *arg)
{
  RT_TASK_INFO curtaskinfo;

  printf("Hello World!\n");

  // inquire current task
  rt_task_inquire(NULL,&curtaskinfo);

  // print task name
  printf("Task name : %s \n", curtaskinfo.name);
}
示例#14
0
void task(void *arg)
{
  rt_sem_p(&semGlobal, TM_INFINITE);

  int a = * (int *) arg;

  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  curtask=rt_task_self();
  rt_task_inquire(curtask,&curtaskinfo);
  rt_printf("Task name: %s arg: %d \n", curtaskinfo.name, a);
  
}
示例#15
0
static void taskPrintInfo(
    void) {

    RT_TASK_INFO thisTask;

    rt_task_inquire(
        rt_task_self(),
        &thisTask);

    LOG_INFO("task %s, has bprio %d, cprio %d",
        thisTask.name,
        thisTask.bprio,
        thisTask.cprio);
}
示例#16
0
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;

  // hello world
  rt_printf("Hello World!\n");

  // inquire current task
  curtask=rt_task_self();
  rt_task_inquire(curtask,&curtaskinfo);

  // print task name
  rt_printf("Task name : %s \n", curtaskinfo.name);
}
示例#17
0
void demo (void *arg){
	RT_TASK *curtask;
	RT_TASK_INFO curtaskinfo;
	//inquire current task
	curtask = rt_task_self();
	int retval;
	retval = rt_task_inquire(curtask,&curtaskinfo);
	if(retval<0){
		rt_printf("inquiring error %d:%s\n",-retval,strerror(-retval));
		return;
	}
	//print task name
	retval = * (int *)arg;
	rt_printf("Task name: %s. Has param: %d\n", curtaskinfo.name,retval);
}
示例#18
0
文件: ex02c.c 项目: johannajung/des
void demo(void *arg)
{
  RT_TASK *curtask;
  RT_TASK_INFO curtaskinfo;
  int num = *(int *) arg;

  // inquire current task
  curtask=rt_task_self();
  rt_task_inquire(curtask,&curtaskinfo);

  // print task name
  rt_printf("Task name : %s \n", curtaskinfo.name);
  // print argument
  rt_printf("Task argument : %d \n", num);
}
示例#19
0
void demo(void *arg)
{
    RT_TASK *curtask;
    RT_TASK_INFO curtaskinfo;

    // inquire current task
    curtask=rt_task_self();
    rt_task_inquire(curtask,&curtaskinfo);

    rt_sem_p(&semGlobal,TM_INFINITE);

    // print task name
    int num = * (int *)arg;
    rt_printf("Task name : %s \n", curtaskinfo.name);
}
示例#20
0
        INTERNAL_QUAL int rtos_task_get_scheduler(const RTOS_TASK* mytask) {
#if 0
            // WORK AROUND constness: (need non-const mytask)
            RT_TASK* tt = mytask->xenoptr;
            RT_TASK_INFO info;
            if ( tt )
                if ( rt_task_inquire( tt, &info) == 0 )
                    if ( info.status & XNRELAX )
                        return SCHED_XENOMAI_SOFT;
                    else
                        return SCHED_XENOMAI_HARD;
            return -1;
#else
            return mytask->sched_type;
#endif
        }
示例#21
0
static void taskValidatePrio(
    void) {

    RT_TASK_INFO thisTask;

    rt_task_inquire(
        rt_task_self(),
        &thisTask);

    if (thisTask.cprio > thisTask.bprio) {
        LOG_ERR("task %s, has raised prio from %d to %d",
            thisTask.name,
            thisTask.bprio,
            thisTask.cprio);
    }
}
示例#22
0
void key_handler(void *arg)
{
	int count = 0;
	int nr_interrupts_waiting;
	
    RT_TASK *curtask;
    RT_TASK_INFO curtaskinfo;

	while(1) {
		//rt_printf("%d\n",count++);
		nr_interrupts_waiting = rt_intr_wait(&keypress,TM_INFINITE);
		if (nr_interrupts_waiting>0)
		{
			// inquire current task
			curtask=rt_task_self();
			rt_task_inquire(curtask,&curtaskinfo);
			rt_printf("Current priority of handler task: %d \n", curtaskinfo.cprio);
		}
	}
}
void task_body(void *cookie) {

  rt_sem_p(&sem, TM_INFINITE);

  RT_TASK *current_task;
  RT_TASK_INFO current_task_info;

  current_task = rt_task_self();
  rt_task_inquire(current_task, &current_task_info);

  rt_printf("Task name: %s started with priority %d\n",
    current_task_info.name,
    current_task_info.cprio
  );

  rt_task_sleep(DELAY * 1000000L); // delay for 1 second

  rt_printf("Task name: %s is shutting down\n", current_task_info.name);

}
void task_body(void *cookie) {

  RT_TASK *current_task;
  RT_TASK_INFO current_task_info;

  current_task = rt_task_self();
  //получаем информацию о таске
  rt_task_inquire(current_task, &current_task_info);

  rt_printf("Task name: %s started with priority %d\n",
      current_task_info.name,
    current_task_info.cprio
  );
  for (int i = 0; i < ITERATIONS; i++) {
    __sync_fetch_and_add(&shared_resource, 1);
    rt_task_sleep(DELAY);
  }
 // pthread_mutex_unlock(&my_gasu_mutex);
  rt_printf("Task name: %s is shutting down\n", current_task_info.name);
}
示例#25
0
void demo (void *arg){
	sleep(1);
	RT_TASK *curtask;
	RT_TASK_INFO curtaskinfo;
	//inquire current task
	curtask = rt_task_self();
	int retval;
	retval = rt_task_inquire(curtask,&curtaskinfo);
	if(retval<0){
		rt_printf("inquiring error %d:%s\n",-retval,strerror(-retval));
	}
	//print task name
	retval = * (int *)arg;
	RTIME p = 1e9;
	p*=retval;
	rt_task_set_periodic(NULL,TM_NOW,p);
	while(1){
		rt_printf("[%s] %d s periodic\n", curtaskinfo.name,retval);
		rt_task_wait_period(NULL);
	}
}