2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike{addtoit,linux.intel}.com)
3 * Licensed under the GPL
11 #include "kern_constants.h"
15 int set_interval(int is_virtual)
17 int usec = 1000000/UM_HZ;
18 int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL;
19 struct itimerval interval = ((struct itimerval) { { 0, usec },
22 if (setitimer(timer_type, &interval, NULL) == -1)
28 void disable_timer(void)
30 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
32 if ((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
33 (setitimer(ITIMER_REAL, &disable, NULL) < 0))
34 printk(UM_KERN_ERR "disable_timer - setitimer failed, "
35 "errno = %d\n", errno);
37 /* If there are signals already queued, after unblocking ignore them */
38 signal(SIGALRM, SIG_IGN);
39 signal(SIGVTALRM, SIG_IGN);
42 void switch_timers(int to_real)
44 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
45 struct itimerval enable = ((struct itimerval) { { 0, 1000000/UM_HZ },
46 { 0, 1000000/UM_HZ }});
58 if ((setitimer(old, &disable, NULL) < 0) ||
59 (setitimer(new, &enable, NULL)))
60 printk(UM_KERN_ERR "switch_timers - setitimer failed, "
61 "errno = %d\n", errno);
64 unsigned long long os_nsecs(void)
68 gettimeofday(&tv, NULL);
69 return (unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000;
72 void idle_sleep(int secs)