__TEST_AND_CLEAR_BIT

Category
아이템: 
포스트 갯수1

[라즈베리파이] 비트 처리 __test_and_set_bit() __test_and_clear_bit() 함수 동작 원리

By Guillermo Austin Kim | 2018년 8월 19일 | 
리눅스 커널과 드라이버에서 __test_and_set_bit()와 __test_and_clear_bit() 함수를 많이 씁니다. 두 함수 중 test_and_set_bit()를 써서 비트를 처리하는 코드를 보겠습니다.다음은 워크를 워크큐에 큐잉하는 queue_work_on() 함수입니다.[kernel/workqueue.c]1 bool queue_work_on(int cpu, struct workqueue_struct *wq,2 struct work_struct *work)3 {4 bool ret = false;5 unsigned long flags;67 local_irq_save(flags);89 if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_dat