본문
[CODE] #include <stdio.h> #include <time.h> #include <signal.h> struct timespec x; struct itimerspec ispec; struct itimerspec ospec; struct sigaction sa; time_t tid; void alrm_handler(int signo, siginfo_t *info, void *context) { clock_gettime(CLOCK_REALTIME,&x); printf("%ld.%09ld \n",x.tv_sec, x.tv_nsec); } int main() { x.tv_sec=0; x.tv_nsec=100000; tid=1; sa.sa_sigaction = alrm_handler; sa.sa_flags = SIGEV_SIGNAL; sigaction(SIGALRM, &sa, NULL); timer_create(CLOCK_REALTIME,NULL,&tid); ispec.it_value.tv_sec = 0; ispec.it_value.tv_nsec = 100000; ispec.it_interval.tv_sec = 0; ispec.it_interval.tv_nsec = 1; timer_settime(tid, TIMER_ABSTIME, &ispec, &ospec); while(1) sleep(1); } [/CODE]
결과
1141630302.569839000
1141630302.570838000
1141630302.571838000
1141630302.572839000
1141630302.573838000
1141630302.574838000
1141630302.575838000
1141630302.576837000
1141630302.577837000
1141630302.578837000
1141630302.579837000
1141630302.580837000
1141630302.581836000
약간의 오차는 발생하지만 1ms마다 이벤트가 발생한것을 알수있다.
그러나-..ㅡㅜ
난 마이크로 단위의 이벤트를 원한다.ㅡㅜ;;;
혹시나 해결방법 아시는분?...
'컴퓨터 이야기' 카테고리의 다른 글
이틀간의 삽질 결과-.. (0) | 2006.03.26 |
---|---|
[RT] 마이크로세컨드 이벤트 발생-0- (0) | 2006.03.07 |
[프로그래밍문제] 풀어보세요~-0-;; (2) | 2006.02.21 |
[Tool] Microsoft Visual Studio 2005 좋네-0-;;.. (0) | 2006.02.21 |
[TIP] FTP 바로 다운 받을수 있는 주소 만들기;;? (0) | 2006.01.26 |