Linux kernel design and implement a kernel synchronization method summary notes (Chapter 10)

One, atomic operation

 It ensures that atomic instructions are executed atomically ---- execution process is not interrupted.

1.1 atom integer operation

Atomic_t type can only process data for the integers atomic operation.

  • First, let only atomic function receives the operand type atomic_t, atomic operations can be ensured only with this particular type of data, and will not be used by others.
  • Use atomic_t type ensure that the compiler does not, the corresponding values ​​access optimization.
  • When implementing atomic operations on different architectures, use can mask the differences therebetween atomic_t

atomic_t type defined in the file <linux / types.h> in

typedef struct {
    volatile int counter;
} atomic_t;

 

Second, the spin lock

 

Third, read - write spinlock

 

Fourth, the semaphore

 

Fifth, read - write semaphores

 

Sixth, mutex

 

Seven, complete variable

 

Eight, BLK: big kernel lock

 

Nine, order lock

 

Ten, disable preemption

 

Eleven, the order and the barrier

 

Guess you like

Origin www.cnblogs.com/ch122633/p/11029008.html