static int psos_init(void) { int ret; registry_add_dir("/psos"); registry_add_dir("/psos/tasks"); registry_add_dir("/psos/semaphores"); registry_add_dir("/psos/queues"); registry_add_dir("/psos/timers"); registry_add_dir("/psos/partitions"); registry_add_dir("/psos/regions"); cluster_init(&psos_task_table, "psos.task"); cluster_init(&psos_sem_table, "psos.sema4"); cluster_init(&psos_queue_table, "psos.queue"); pvcluster_init(&psos_pt_table, "psos.pt"); pvcluster_init(&psos_rn_table, "psos.rn"); ret = clockobj_init(&psos_clock, "psos", clock_resolution); if (ret) { warning("%s: failed to initialize pSOS clock (res=%u ns)", __FUNCTION__, clock_resolution); return __bt(ret); } /* Convert pSOS ticks to timespec. */ clockobj_ticks_to_timespec(&psos_clock, time_slice_in_ticks, &psos_rrperiod); return 0; }
u_long tm_evevery(u_long ticks, u_long events, u_long *tmid_r) { struct itimerspec it; struct service svc; int ret; COPPERPLATE_PROTECT(svc); clockobj_ticks_to_timeout(&psos_clock, ticks, &it.it_value); clockobj_ticks_to_timespec(&psos_clock, ticks, &it.it_interval); ret = start_evtimer(events, &it, tmid_r); COPPERPLATE_UNPROTECT(svc); return ret; }
STATUS kernelTimeSlice(int ticks) { struct timespec quantum; struct wind_task *task; /* Convert VxWorks ticks to timespec. */ clockobj_ticks_to_timespec(&wind_clock, ticks, &quantum); /* * XXX: Enable/disable round-robin for all threads known by * the current process. Round-robin is most commonly about * having multiple threads getting an equal share of time for * running the same bulk of code, so applying this policy * session-wide to multiple Xenomai processes would not make * much sense. I.e. one is better off having all those threads * running within a single process. */ wind_time_slice = ticks; do_each_wind_task(task, threadobj_set_rr(&task->thobj, &quantum)); return OK; }