[완료] hrtimer(고해상도 타이머) API 사용하는 방법을 알고 싶습니다. ㅠㅠ

imleemin의 이미지

현재 리눅스 상에서 주기적으로 패킷을 보내는 작업을 하는데,
그 주기가 1ms 이하 입니다.

그래서 리눅스 커널 2.6.21 부터 커널에 포함 되어 나온다던
고해상도 타이머 기능을 사용해 볼려고 했는데요..

도통 어떻게 사용하는 건지 모르겠네요.;;

자료를 뒤적이던 중, 우연히 관련 API를 설명해 놓은 글을 보고,
컴파일 할려고 돌려보니, 헤더 파일을 찾을 수가 없다는 에러가 떴습니다.
관련 헤더 파일(hrtimer.h, ktime.h)이 있는 폴더(/usr/src/kernels/설치된리눅스버전/include)를 경로 지정해주고,
컴파일 했더니 이번엔 또 에러가 잔뜩 올라오더라구요. ;ㅠㅠ

제가 가입했던 리눅스 관련 카페에도 문의를 했었는데,
kernel-devel? 설치 한 번 해보라고 해서 해봤는데
이미 설치되어 있다고 하면서, 안되더라구요..

어떻게 하면 고해상도 타이머 기능을 쓸 수 있는 거죠??

리눅스 관련 개발이 초짜인지라.. 정말 막막하네요 ㅠ

아래 소스와 원문, 에러 내용들 올려봅니다.
많은 도움 부탁드립니다. ㅠ

원문 : http://www.ibm.com/developerworks/kr/library/l-timers-list/index.html

소스 :
//헤더파일을 '<' '>'로 묶으니까 보이질 않네요;; 그래서 ""로 바꿨습니다. ㅎㅎ;;

#include "linux/kernel.h"
#include "linux/module.h"
#include "linux/hrtimer.h"
#include "linux/ktime.h"

MODULE_LICENSE( "GPL" );

#define MS_TO_NS(x) (x * 1E6L)

static struct hrtimer hr_timer;

enum hrtimer_restart my_hrtimer_callback( struct hrtimer *timer )
{
printk( "my_hrtimer_callback called (%ld).\n", jiffies );

return HRTIMER_NORESTART;
}

int init_module( void )
{
ktime_t ktime;
unsigned long delay_in_ms = 200L;

printk("HR Timer module installing\n");

ktime = ktime_set( 0, MS_TO_NS(delay_in_ms) );

hrtimer_init( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL );

hr_timer.function = &my_hrtimer_callback;

printk( "Starting timer to fire in %ldms (%ld)\n", delay_in_ms, jiffies );

hrtimer_start( &hr_timer, ktime, HRTIMER_MODE_REL );

return 0;
}

void cleanup_module( void )
{
int ret;

ret = hrtimer_cancel( &hr_timer );
if (ret) printk("The timer was still in use...\n");

printk("HR Timer module uninstalling\n");

return;
}

에러는 너무 길어서;; 이미지 파일로 첨부하였습니다. ;; ㅠ

File attachments: 
첨부파일 크기
Image icon 1_imleemin.jpg174.97 KB
Image icon 2_imleemin.jpg132.12 KB
Image icon 3_imleemin.jpg169.03 KB
imleemin의 이미지

커널 2.6.21 부터 hrtimer가 포함되어 나오게 되었는데,
커널 설정에서 관련 기능을 활성화 시킨 후(CONFIG_HIGH_RES_TIMER)
커널 컴파일을 다시 하고,
itimers나 POSIX 타이머 인터페이스(clock_gettime, clock_settime 등)를 쓰면 되는 것이 더군요;;

이걸 몰랐다니...흐흐흐;

익명 사용자의 이미지

멋지심!

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.