コード例 #1
3
ファイル: ex07c.c プロジェクト: jd7h/des
void demo(void *arg)
{
    //Round Robin
    rt_task_set_mode(0,T_RRB,NULL);
    rt_task_slice(NULL,15); //time slice in jiffies

    RTIME starttime, runtime;
    int num=*(int *)arg;
    RT_TASK *curtask;
    RT_TASK_INFO curtaskinfo;

    rt_printf("Task  : %d\n",num);

    rt_sem_p(&mysync,TM_INFINITE);

    // let the task run RUNTIME(=200) jiffies in steps of SPINTIME(=20) jiffies
    runtime = 0;
    while(runtime < EXECTIME) {
      rt_timer_spin(SPINTIME*BASEPERIOD);  // spin cpu doing nothing
      // note: rt_timer_spin function does not accept jiffies only nanoseconds
      //       deviates from timing conventions throughout the Xenomai API

      runtime = runtime + SPINTIME;

      rt_printf("Running Task  : %d  at time : %d\n",num,runtime);
    }
    rt_printf("End Task  : %d\n",num);
}
コード例 #2
0
ファイル: main.c プロジェクト: kringle/sannsys15
void busy_wait_ms(unsigned long delay){
	unsigned long count = 0;
	while (count <= delay*10){
		rt_timer_spin(1000*100);
		count++;
	}
}
コード例 #3
0
ファイル: ex08a.c プロジェクト: PimJager/SoftwaredesignEmSys
void prioHigh(void *arg){
    int err = 0;

    rt_task_sleep(WAIT);

    int i = 0;
    while(i<3) {
      
      rt_printf("High priority task tries to lock semaphore\n");
      err = rt_sem_p(&mysync,TM_INFINITE);
      if(err < 0) rt_printf("Failed pending semaphore; error: %d: %s", err, strerror(-err)); 
        err = 0;
      rt_printf("High priority task locks semaphore\n");

      rt_timer_spin(SPINTIME);  // spin cpu doing nothing

      i++;

      rt_printf("High priority task unlocks semaphore\n");
      err = rt_sem_v(&mysync);
      if(err < 0) rt_printf("Failed signaling semaphore; error: %d: %s", err, strerror(-err)); 
        err = 0;
    }
    rt_printf("..........................................High priority task ends\n");
}
コード例 #4
0
ファイル: ex06c.c プロジェクト: dopefishh/des2015
void demo(void *arg)
{
	RTIME starttime, runtime;
    int num=*(int *)arg;
    RT_TASK *curtask;
    RT_TASK_INFO curtaskinfo;

	curtask=rt_task_self();
    rt_printf("Task  : %d\n",num);

    rt_sem_p(&mysync,TM_INFINITE);

    runtime = 0;
    while(runtime < EXECTIME) {
      rt_timer_spin(SPINTIME);  // spin cpu doing nothing

      runtime = runtime + SPINTIME;

      rt_printf("Running Task  : %d  at ms : %d\n",num,runtime/1000000);
	  if(runtime == (EXECTIME/2)){
		  if(num == 2){
			  rt_task_set_priority(&demo_task[1],MID+10);
			  rt_task_set_priority(&demo_task[0],LOW+10);
		  }
	  }
    }
    rt_printf("End Task  : %d\n",num);
}
コード例 #5
0
ファイル: ex09a2.c プロジェクト: dopefishh/des2015
void dummy_task(void *arg) {
	while(1) { rt_printf("Sleeping\n");
		rt_task_sleep(2e9);
		rt_printf("Spinning\n");
		rt_timer_spin(3e9);
	}
}
コード例 #6
0
void RT::OS::sleepTimestep(RT::OS::Task task)
{
	xenomai_task_t *t = reinterpret_cast<xenomai_task_t *>(task);

	// Prevent significant early wake up from happening and drying the Linux system
	rt_task_sleep_until(t->next_t - t->wakeup_t);

	// Busy sleep until ready for the next cycle
	rt_timer_spin(rt_timer_ticks2ns(t->next_t - rt_timer_read()));

	// Update next interrupt time
	t->next_t += t->period;
}
コード例 #7
0
ファイル: ex08a.c プロジェクト: PimJager/SoftwaredesignEmSys
void prioMid(void *arg){
    RTIME runtime;

    rt_task_sleep(WAIT);
  
    runtime = 0;
    while(runtime < EXECTIMEMID) {
      rt_timer_spin(SPINTIME);  // spin cpu doing nothing

      runtime = runtime + SPINTIME;

      rt_printf("Medium task running\n");
      
    }
    rt_printf("..........................................Medium priority task ends\n");
}
コード例 #8
0
ファイル: ex06b.c プロジェクト: PimJager/SoftwaredesignEmSys
void demo(void *arg)
{
    RTIME starttime, runtime;
    int num=*(int *)arg;
    RT_TASK *curtask;
    RT_TASK_INFO curtaskinfo;

    rt_printf("Task  : %d\n",num);

    rt_sem_p(&mysync,TM_INFINITE);

    runtime = 0;
    while(runtime < EXECTIME) {
      rt_timer_spin(SPINTIME);  // spin cpu doing nothing

      runtime = runtime + SPINTIME;

      rt_printf("Running Task  : %d  at ms : %d\n",num,runtime/1000000);
    }
    rt_printf("End Task  : %d\n",num);
}
コード例 #9
0
ファイル: ex08a.c プロジェクト: PimJager/SoftwaredesignEmSys
void prioLow(void *arg)
{
    int err = 0;
    RTIME runtime;

    runtime = 0;
    while(runtime < EXECTIMELOW) {
      
      err = rt_sem_p(&mysync,TM_INFINITE);
      if(err < 0) rt_printf("Failed pending semaphore; error: %d: %s", err, strerror(-err)); 
        err = 0;
      rt_printf("Low priority task locks semaphore\n");

      rt_timer_spin(SPINTIME);  // spin cpu doing nothing

      runtime = runtime + SPINTIME;

      rt_printf("Low priority task unlocks semaphore\n");
      err = rt_sem_v(&mysync);
      if(err < 0) rt_printf("Failed signaling semaphore; error: %d: %s", err, strerror(-err)); 
        err = 0;
    }
    rt_printf("..........................................Low priority task ends\n");
}
コード例 #10
0
int spin_timer(RTIME* ct) {
	rt_timer_spin(*ct);
	return 1;
}
コード例 #11
0
int wait_blink() {
	rt_timer_spin(200000);
	return 1;
}