Hardware Reference
In-Depth Information
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
Implement a precision "timed wait". The parameter early_usec
3
allows an interrupted select(2) call to consider the wait as
4
completed, when interrupted with only "early_usec" left remaining.
5
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
6 static void
7 timed_wait(long sec,long usec,long early_usec) {
8 fd_set mt;
9 struct timeval timeout;
10 int rc;
11
12 FD_ZERO(&mt);
13 timeout.tv_sec = sec;
14 timeout.tv_usec = usec;
15 do {
16 rc = select (0,&mt,&mt,&mt,&timeout);
17 if ( ! timeout.tv_sec && timeout.tv_usec < early_usec )
18 return; /
/
19 } while ( rc < 0 && timeout.tv_sec && timeout.tv_usec );
20 }
21
22 /
Wait is good enough, exit
End timed_wait.c
/
Search WWH ::




Custom Search