void prh1(unsigned long data) { if (prtloops++ < LOOPS) { rt_printk("\nFIRED NEW PERIODIC: %3d, %lx", prtloops, data); } else { rt_printk("\n"); rt_remove_timer(&prt); } }
void osh(unsigned long data) { if (ostloops++ < LOOPS) { rt_printk("\nFIRED BUDDY: %3d, %lx", ostloops, data); #if PERIODIC_BUDDY == 0 rt_insert_timer(&ost, 0, firing_time += nano2count(TICK_PERIOD/2), 0, osh, 0xBBBBBBBB, 0); #endif } else { rt_printk("\n"); rt_remove_timer(&ost); } }
void prh(unsigned long data) { int i; double a[100], s; if (prtloops++ < LOOPS) { if (prtloops == 1) { rt_printk("+ PERIODIC COMPUTATIONAL TASKLET FIRED\n"); } for (i = 0; i < 100; i++) { a[i] = i + 1; } s = 0; for (i = 1; i < 100; i++) { s += (a[i - 1]*a[i]); } } else { rt_printk("+ PERIODIC COMPUTATIONAL TASKLET ENDED\n"); rt_remove_timer(prt); endp = 1; } }
void seqh(unsigned long data) { switch (opcod) { case 0: { rt_printk("- SEQUENCER FIRED FOR A FAST POLLING\n"); rt_insert_timer(seqt, 10, rt_get_time() + nano2count(500000), nano2count(500000), seqh, 0, 1); opcod = 1; } break; case 1: { if (poloops++ < LOOPS) { if (poloops == 1) { rt_printk("- SEQUENCER BEGINS FAST POLLING\n"); } } else { rt_printk("- SEQUENCER FAST POLLING ENDED, TIMED FOR A LATER FINAL OPERATION\n"); rt_set_timer_firing_time(seqt, rt_get_time() + nano2count(50000000)); opcod = 2; } } break; case 2: { rt_printk("- SEQUENCER EXECUTES FINAL OPERATION, ... THEN\n SLOWLY POLLS WAITING FOR THE END OF THE PERIODIC COMPUTATIONAL TASKLET\n"); opcod = 3; } break; case 3: { if (endp) { rt_printk("- PERIODIC COMPUTATIONAL TASKLET GONE, SEQUENCER ENDS IT ALL\n"); rt_remove_timer(seqt); end = 1; } else { // rt_printk("\nSEQUENCER WAITING FOR PERIODIC TIMER END"); } } break; } }
RTAI_SYSCALL_MODE void rt_ptimer_settime(timer_t timer, const struct itimerspec *value, unsigned long data, long flags) { struct rt_tasklet_struct *tasklet; RTIME now; tasklet = posix_timer[timer].timer; rt_remove_timer(tasklet); now = rt_get_time(); if (flags == TIMER_ABSTIME) { if (timespec2count(&(value->it_value)) < now) { now -= timespec2count (&(value->it_value)); }else { now = 0; } } if (timespec2count ( &(value->it_value)) > 0) { if (data) { rt_insert_timer(tasklet, 0, now + timespec2count ( &(value->it_value) ), timespec2count ( &(value->it_interval) ), NULL, data, -1); } else { rt_insert_timer(tasklet, 0, now + timespec2count ( &(value->it_value) ), timespec2count ( &(value->it_interval) ), tasklet->handler, tasklet->data, 0); } } }