Back to Index

linux kernel development, 3rd edition

robert love2010

Link

+

2017-10-25

concurrent access

continuing in linux kernel development, 3rd edition by robert love, we come to the problem of concurrency. in the linux kernel, you can have multiple cores executing code and interrupts disrupting the code on any given processor.

let's say you want to increment a number and read the result. to be sure the number was one minus the number read, you have to be sure no other programmed changed it between the increment and read. the linux kernel allows some simple sets of instructions to be executed atomically for that purpose.

alternately, if you want to lock data while you're using it, you can implement a spin lock. other processes that want the value will spin (loop) until you free the resource.

or, to make better use of processor time, worker processes can be called when the resource becomes free. then there are all sorts of variants on those themes.