?????????Linux?豸?????е????????
???????????? ???????[ 2015/5/7 13:34:54 ] ??????????????
???????????????????????????У?
??????????????SMP??????CPU
??????????????CPU??
????????????????????????????????critical sections??????????????????????????????????????????У?????????????????????????critical sections??????????????е???????????????????????????????????”???”??????????????????????в????????Linux????н?????????????????ж????Ρ???????????????????????????????????????
?????ж????Σ?
??????÷???
????local_irq_disable() //?????ж?
????...
????critical section //?????
????...
????local_irq_enable() //???ж?
????local_irq_disable/enable?????/????CPU????ж????????SMP??CPU????????????????????????????????????????á?
????????????
???????????????е??????????????linux??????????е?????????????е???????????Щ???????2????????λ?????????????????????
?????????????????????????£?
????1.????????????????????
????void atomic_set(atomic_t *v ?? int i); //????????????i
????atomic_t v = ATOMIC_INIT(0); //??????????v????????0
????2.????????????
????atomic_read(atomic_t *v);
????3.?????????????
????void atomic_add(int i??atomic_t *v);//????????i
????void atomic_sub(int i ??atomic_t *v);//????????i
????4.??????????/???
????void atomic_inc(atomic_t *v);//????1
????void atomic_dec(atomic_t *v);//???1
????5.???????????????????????????????????м????????????0??????0????true????????false??
????int atomic_inc_and_test(atomic_t *v);
????int atomic_dec_and_test(atomic_t *v);
????int atomic_sub_and_test(int i ??atomic_t *v);
????6.??????????
????int atomic_add_return(int i ?? atomic_t *v);
????int atomic_sub_return(int i ?? atomic_t *v);
????int atomic_inc_return(atomic_t * v);
????int atomic_dec_return(atomic_t * v)??
??????? λ?????????£?
????// ????λ
????void set_bit(nr?? void *addr); // ????addr??????nrλ??????λд1
????// ???λ
????void clear_bit(nr?? void *addr); // ???addr??????nrλ??????λд0
????// ???λ
????void change_bit(nr?? void *addr); // ??addr??????nrλ???
????// ????λ
????test_bit(nr?? void *addr); // ????addr??????nrλ
????// ???????????????????test_bit(nr?? void *addr)???????xxx_bit(nr?? void *addr)
????int test_and_set_bit(nr?? void *addr);
????int test_and_clear_bit(nr?? void *addr);
????int test_and_change_bit(nr?? void *addr)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11