2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
13 #include "kern_util.h"
16 #include "kern_constants.h"
18 #include "uml-config.h"
20 int set_interval(int is_virtual)
22 int usec = 1000000/hz();
23 int timer_type = is_virtual ? ITIMER_VIRTUAL : ITIMER_REAL;
24 struct itimerval interval = ((struct itimerval) { { 0, usec },
27 if(setitimer(timer_type, &interval, NULL) == -1)
33 void disable_timer(void)
35 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
36 if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
37 (setitimer(ITIMER_REAL, &disable, NULL) < 0))
38 printk("disnable_timer - setitimer failed, errno = %d\n",
40 /* If there are signals already queued, after unblocking ignore them */
41 signal(SIGALRM, SIG_IGN);
42 signal(SIGVTALRM, SIG_IGN);
45 void switch_timers(int to_real)
47 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
48 struct itimerval enable = ((struct itimerval) { { 0, 1000000/hz() },
49 { 0, 1000000/hz() }});
61 if((setitimer(old, &disable, NULL) < 0) ||
62 (setitimer(new, &enable, NULL)))
63 printk("switch_timers - setitimer failed, errno = %d\n",
67 unsigned long long os_nsecs(void)
71 gettimeofday(&tv, NULL);
72 return((unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000);
75 void idle_sleep(int secs)