c - Mutex | Spinlock | ??? in LKM -


what should using if (on multicore system) wanted make kernel module function ran 1 core @ time? said in other words, avoid 2 cores running same function @ same time; aka, 1 of cores should wait other 1 finish running function.

mutex? spinlock? else?

you need use variants of spinlock() i.e raw_spin_lock_irqsave(), raw_spin_lock_irqrestore() (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/spinlock.h#n188), not mutex() cause they're sleep-able, might wake on other cpus. , spinlock make sure code won't executed other cores. it's been documented in linux kernel tree @ documentation/spinlock.txt (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/documentation/spinlocks.txt).


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -