Rev 2292 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2292 | Rev 2307 | ||
---|---|---|---|
Line 106... | Line 106... | ||
106 | tv->tv_sec = s1; |
106 | tv->tv_sec = s1; |
107 | 107 | ||
108 | return 0; |
108 | return 0; |
109 | } |
109 | } |
110 | 110 | ||
111 | /** Wait unconditionally for specified microseconds */ |
111 | /** Wait unconditionally for specified number of microseconds */ |
112 | void usleep(unsigned long usec) |
112 | void usleep(unsigned long usec) |
113 | { |
113 | { |
114 | atomic_t futex = FUTEX_INITIALIZER; |
114 | atomic_t futex = FUTEX_INITIALIZER; |
115 | 115 | ||
116 | futex_initialize(&futex,0); |
116 | futex_initialize(&futex, 0); |
117 | futex_down_timeout(&futex, usec, 0); |
117 | futex_down_timeout(&futex, usec, 0); |
118 | } |
118 | } |
119 | 119 | ||
- | 120 | /** Wait unconditionally for specified number of seconds */ |
|
- | 121 | unsigned int sleep(unsigned int seconds) |
|
- | 122 | { |
|
- | 123 | atomic_t futex = FUTEX_INITIALIZER; |
|
- | 124 | ||
- | 125 | futex_initialize(&futex, 0); |
|
- | 126 | ||
- | 127 | /* Sleep in 1000 second steps to support |
|
- | 128 | full argument range */ |
|
- | 129 | while (seconds > 0) { |
|
- | 130 | unsigned int period = (seconds > 1000) ? 1000 : seconds; |
|
- | 131 | ||
- | 132 | futex_down_timeout(&futex, period * 1000000, 0); |
|
- | 133 | seconds -= period; |
|
- | 134 | } |
|
- | 135 | } |
|
- | 136 | ||
120 | /** @} |
137 | /** @} |
121 | */ |
138 | */ |