시스템 프로그래밍(11)

조권휘·2022년 8월 27일
0

시스템 프로그래밍

목록 보기
11/14

Interval Timer

#include <sys/time.h>

int setitimer(int which, const struct itimerval*value, struct itimerval *oval);
int getitimer(int which, struct itimerval *oval);

  • 주기적으로 SIGALRM을 이용해 signal을 전달받을 때 사용한다.
  • which : timer type
  • value : 새로운 interval
  • oval : 현재 timer interval(setitimer같은 경우 NULL)
  • return : 성공 시 0 / 실패 시 -1

POSIX Timer

  • POSIX Timer는 realtime application을 통해 더욱 향상된 timer를 제공한다.
  • SIGALRM 대신 SIGRTMIN~SIGRTMAX 와 같은 구체적인 signal이 사용된다.
  • signal handler 대신에 handler thread가 사용된다.

Signals & Thread

  • multithread 환경에서 thread들은 signal을 상속받는다.
  • signal이 발생하면, group내에서 random thread에 전달이 된다.
  • 만일 해당 thread가 sig block 상태라면 sibling 중 다른 thread에게 전달한다.
  • 만일 signal이 모든 thread에게 block이 된 경우, queue에 들어가 pending 상태가 된다.
profile
안녕하세요 :) Data/AI 공부 중인 한국외대 컴퓨터공학부 조권휘입니다.

0개의 댓글