[질문] RedHat 9.0 Kernel 2.4에서 timer를 이용해서 인터럽트를 구현하려고 하는데 방법을 모르겠습니다.
리눅스에 처음 이어서 그런지 도무지 감이 잡히질 않습니다.
제가 가지고 있는 책에서는 타이머를 사용하려면
struct timer_list my_timer;
init_timer(&my_timer);
my_timer.expires = jiffies + delay ;
my_timer.data 0 ;
my_timer.function = my_function;
add_timer(&my_timer);
이렇게 하면 쓸수 있다고 설명 되어 있는데 이것을 일반 application에서 쓸수 있는 것인가요?? 다시 말해서 main()에서 위에 부분을 선언을
해주고 그냥 함수 부분만 가저다 쓰면 마이크로 컨트롤러의 타이머 인터럽트 처럼 delay 후 인터럽터 구분으로 뛰는 것인지 알고 싶습니다.
처음 접해봐서 개념이 안잡히니 난감하네요...
이런 개념이 아니라면 어떤 부분 부터 공부를 해야 되는지 대답해 주셨으면 합니다. 매우 난감하네요...ㅎㅎ
제가 쓰려는 의도는 main이 동작하다 일정한 시간이 되면 제가 정해준 인터럽트 함수로 뛰어서 프로그램을 실행하다 다시 main구문으로
돌아오는것입니다. 고수님들의 조언 부탁 드립니다. (- -)(_ _);;
제가 redhat 9.0 kernel 2.4 로 컴파일 했더니
계속 이런 식의 해더 파일에서 에러가 뜨네요....
/usr/include/linux/timer.h:32: field `vec' has incomplete type
/usr/include/linux/timer.h:37: field `vec' has incomplete type
/usr/include/linux/timer.h:45: parse error before "spinlock_t"
/usr/include/linux/timer.h:53: parse error before '}' token
/usr/include/linux/timer.h:63: field `list' has incomplete type
/usr/include/linux/timer.h:67: parse error before "tvec_base_t"
/usr/include/linux/timer.h:101: parse error before "tvec_bases"
/usr/include/linux/timer.h: In function `init_timer':
/usr/include/linux/timer.h:105: dereferencing pointer to incomplete type
/usr/include/linux/timer.h:105: dereferencing pointer to incomplete type
/usr/include/linux/timer.h:105: `NULL' undeclared (first use in this function)
/usr/include/linux/timer.h:105: (Each undeclared identifier is reported only once....
말씀하신 '책'이란
말씀하신 '책'이란 것은 커널 프로그래밍 책을 가리키신 것이겠군요. 커널에서 사용하기 위한 함수(init_timer(), add_timer(), ...)를 사용자 공간의 응용 프로그램에서는 직접 사용할 수 없습니다. 그게 가능하다면 잘못 작성한 응용 프로그램 때문에 시스템이 뻗을 수도 있을 테니까요. 대신 커널은 시스템 호출이라는 형태로 사용자 공간에 여러 '서비스'를 제공합니다. 그리고 glibc 라이브러리가 상당수 시스템 호출에 대한 wrapper 함수를 제공하구요.
말씀하신 기능은 alarm() 함수나 setitimer() 함수를 이용하실 수 있습니다.
----
$PWD `date`
$PWD `date`
댓글 달기