--- a/drivers/timers_xeno/timers_xeno.c Thu Aug 10 17:57:33 2006 +0200
+++ b/drivers/timers_xeno/timers_xeno.c Thu Aug 31 10:28:53 2006 +0200
@@ -1,5 +1,6 @@
#include <stdlib.h>
-#include <unistd.h>
+#include <unistd.h>
+#include <sys/mman.h>
#include <native/task.h>
#include <native/timer.h>
@@ -14,7 +15,6 @@
RT_MUTEX CanFestival_mutex;
RT_TASK timerloop_task;
-RT_ALARM timerloop_alarm;
RTIME last_time_read;
RTIME last_occured_alarm;
RTIME last_alarm_set;
@@ -24,7 +24,6 @@
void cleanup_all(void)
{
rt_task_delete(&timerloop_task);
- rt_alarm_delete(&timerloop_alarm);
}
void StopTimerLoop(void)
{
@@ -62,15 +61,13 @@
{
int ret;
stop_timer = 0;
+ char taskname[32];
+ snprintf(taskname, sizeof(taskname), "timerloop-%d", getpid());
- ret = rt_alarm_create( &timerloop_alarm, NULL);
- if (ret) {
- printf("Failed to create timerloop_alarm, code %d\n",errno);
- goto error;
- }
-
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+
//create timerloop_task
- ret = rt_task_create(&timerloop_task,"timerloop",0,50,0);
+ ret = rt_task_create(&timerloop_task, taskname, 0, 50, 0);
if (ret) {
printf("Failed to create timerloop_task, code %d\n",errno);
return;
@@ -102,10 +99,12 @@
{
int ret;
static int id = 0;
- char taskname[64];
- sprintf(taskname,"canloop%d",id);
+ char taskname[32];
+ snprintf(taskname, sizeof(taskname), "canloop%d-%d", id, getpid());
id++;
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+
//create timerloop_task
ret = rt_task_create(ReceiveLoop_task,taskname,0,50,0);
if (ret) {
@@ -125,9 +124,8 @@
rt_task_delete(Thread);
}
-//#define max(a,b) a>b?a:b
void setTimer(TIMEVAL value)
-{
+{
last_alarm_set = (value == TIMEVAL_MAX) ? TIMEVAL_MAX : last_time_read + value;
rt_task_unblock(&timerloop_task);
}