프로세서를 wait 시킨 후 조건이 충족되면 다시 실행 시킬때 waitqeue를 사용한다
wait_event(wq, condition);
wait_event_timeout(wq, condition, timeout);
wait_event_cmd(wq, condition, cmd1, cmd2);
wait_event_interruptible(wq, condition);
wait_event_interruptible_timeout(wq, condition, timeout);
wait_event_killable(wq, condition);
wait_event(wq, condition);
프로세스가 wake up이 되면 condition을 확인 후 true가 되면 process를 다시 실행시킨다.
wait_event_timeout(wq, condition, timeout);
timeout시간마다 wake up 후 condition을 확인 후 true가 되거나 timeout이 끝나면 process를 다시 실행시킨다.
time은 jiffies 시간으로 계산한다.
wait_event_cmd(wq, condition, cmd1, cmd2);
condition이 true가 되면 깨어난다.
cmd1은 잠들기 전에 실행될 명령어
cmd2은 깨어난 후 실행 될 명렁어
wait_event_interruptible(wq, condition);
인터럽트를 받아서 condition이 true인지 확인하고 true면 wake up 한다.
wait_event_interruptible_timeout(wq, condition, timeout);
timeout이 끝나거나 인터럽트를 받아서 condition을 확인 후 true이면 wake up 한다.
wait_event_killable(wq, condition);
wake up api list
wake_up(&wq);
wake_up_all(&wq);
wake_up_interruptible(&wq);
wake_up_sync(&wq);
wake_up_interruptible_sync(&wq);
wake_up(&wq);
waitqueue에서 대기중인 것 하나를 꺼내 깨운다.
wake_up_all(&wq);
waitqueue에서 대기중인 모든것을 깨운다.
wake_up_interruptible(&wq);
waitqueue에서 interruptible로 깨울 수 있는 모든것들을 깨운다.
wake_up_sync(&wq);
wake_up_interruptible_sync(&wq);
waitqueue를 초기화 하는방법
1. 정적 초기화
DECLARE_WAIT_QUEUE_HEAD(wait_queue_etx);
#define DECLARE_WAIT_QUEUE_HEAD(name) \
struct wait_queue_head name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
2. 동적 초기화
wait_queue_head_t wait_queue_etx;
init_waitqueue_head(&wait_queue_etx);
#define init_waitqueue_head(wq_head) \
do { \
static struct lock_class_key __key; \
\
__init_waitqueue_head((wq_head), #wq_head, &__key); \
} while (0)
'device driver' 카테고리의 다른 글
charter device driver - 9. expander device moudle 만들기 (0) | 2023.06.19 |
---|---|
gpio contorl 전반적인 내용 (0) | 2023.06.15 |
kernel linked list api 사용법 (0) | 2023.06.01 |
Waiting queues (0) | 2023.06.01 |
charter device driver - 8. interrupt platform driver 만들기 (0) | 2023.05.30 |
댓글