Linux atomic operation device drivers

Atom integer operation

When the shared resource is a simple integer, the integer type can be used to provide an atomic kernel, called atomic_t, defined in <linux / types.h>, the operations defined in <linux / atomic.h> in;

 

Atomic operations

The kernel provides a set of functions that operate on bits atoms, they are associated with the architecture defined in the file <asm / bitops.h>; even on an SMP computer, all these functions ensure gram atoms, thus providing boast consistency processor;

The real need is an atomic operation - all intermediate results are correct; Suppose there are two bit operation, first for a bit, then cleared, if there is no atomic operations, then this one may indeed be cleared, but it may did not set; the set operation may occur simultaneously with the removal operation, but without success; clearing operation may succeed, this one appears to do so cleared; however, with the atomic operations, the set will actually occur, there may be For a moment, this operation shows all set, then it clears the operation performed, the bit becomes a 0;

This behavior may be important, especially when the start of the sequence to function, or when the register operation;

Guess you like

Origin www.cnblogs.com/wanpengcoder/p/11760734.html