Linux API/linux2015. 10. 13. 16:09


ITIMER_REAL

decrements in real time, and delivers SIGALRM upon expiration.

실시간으로 감소하고 만료시 SIGALRM을 전송한다.


ITIMER_VIRTUAL

decrements only when the process is executing, and delivers SIGVTALRM upon expiration.

프로세스가 실행중잉 동안만 감소하고 만료시 SIGVTALRM을 전송한다.


ITIMER_PROF

decrements both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.

프로세스가 실행중이거나 시스템이 프로세스 대신 작동하는 동안에도 감소한다. ITIMER_VITUAL과 결합하여 유저 시간과 커널 시간을 프로파일링 하는데 사용된다. SIGPROF가 만료시 전송한다.


Timer values are defined by the following structures:

struct itimerval {

    struct timeval it_interval; /* next value */

    struct timeval it_value;    /* current value */

};


struct timeval {

    time_t      tv_sec;         /* seconds */

    suseconds_t tv_usec;        /* microseconds */

};


The function getitimer() fills the structure pointed to by curr_value with the current setting for the timer specified by which (one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value is set to the amount of time remaining on the timer, or zero if the timer is disabled. Similarly, it_interval is set to the reset value.

it_value 값은 타이머의 남은 값을 설정하거나 타이머를 사용하지 않기 위해 0으로 설정한다. 유사하게 it_interval는 초기화 값을 설정한다.

The function setitimer() sets the specified timer to the value in new_value. If old_value is non-NULL, the old value of the timer is stored there.


Timers decrement from it_value to zero, generate a signal, and reset to it_interval. A timer which is set to zero (it_value is zero or the timer expires and it_interval is zero) stops.

it_value로 부터 0으로 타이머가 감소하고, 시그널을 생성하고, it_interval로 초기화 한다. 타이머가 0으로 설정되면 정지한다(it_value가 0이거나 타이머가 만료되고 it_interval이 0일 경우)


Both tv_sec and tv_usec are significant in determining the duration of a timer.


Timers will never expire before the requested time, but may expire some (short) time afterward, which depends on the system timer resolution and on the system load; see time(7). (But see BUGS below.) Upon expiration, a signal will be generated and the timer reset. If the timer expires while the process is active (always true for ITIMER_VIRTUAL) the signal will be delivered immediately when generated. Otherwise the delivery will be offset by a small time dependent on the system loading.

[링크 : http://linux.die.net/man/2/setitimer]


그래서 둘다 설정하지 않으면 멈추는 거구나..

다만. it_value의 값은 초기 1회에 대한 타이머이고

it_interval의 값은 2회 부터의 값에 대한 타이머가 된다.

timer.it_value.tv_sec = 0;

timer.it_value.tv_usec = 250000;

timer.it_interval.tv_sec = 0;

timer.it_interval.tv_usec = 250000;


[링크 : http://linuxspot.tistory.com/28] 


[링크 : https://kldp.org/node/132754]

[링크 : http://manofpro.tistory.com/290]

[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=413903]


[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/Timesr_in_Linux]

'Linux API > linux' 카테고리의 다른 글

select()  (0) 2015.10.26
mmap / ioremap  (0) 2015.10.21
리눅스 모듈 - 세마포어 / 뮤텍스  (0) 2015.10.21
linux kernel module module_init() 매크로  (0) 2015.10.21
clock_gettime  (0) 2015.08.09
Posted by 구차니