How to sync linux counter

http://lxr.linux.no/linux+v2.6.35/include/linux/preempt.h#L21

I am just trying to get linux source. I saw this number of predicates, and how does linux guarantee that the number of preemptive calculations is atomic? The code just increments the value.

Also I have one more question. why interrupt handles should support mutual exclusion. Because only one can do it right away?

Also, when interrupts are disabled, what does the OS do? Ignore interrupts or maintain a queue?

+5
source share
3 answers

It enlarges preempt_count()- notices ()- which is a macro, defined as:

#define preempt_count() (current_thread_info()->preempt_count)

, per-thread, .


, :

  • ;
  • , ;
  • . , , , .
+6

preempt_count . inc dec preempt_count . . inc , , . , inc , , , .

: - " - , " . "Read-Modify-Write" preempt_count , , . , , preempt_count . R-M-W ( ), , . , R-M-W , dec (s) .

+1

All Articles