NVIDIA Interview Question
Software Engineer / DevelopersIts more about how spin locking work in terms of disabling and re-enabling interrupts..
On SMP, spin_lock_irqsave() and spin_unlock_irqrestore is used.. it disables and re-enables the LOCAL interrupts..i.e. interrupts on the same CPU on which lock is help...so
other CPUs can continue serving the interrupts on them..
On Both UP and SMP, it works in the same way since it is global to All the CPUs.
Now we need to decide where to use: like
ISRs and how ur critical section code shared between kernel context code and interuupt context code . where and when to disable interrupts.
But if preemption is selected, it disables preemption.
:::::::::::::
BETTER GO WITH UNDERSTANDING LINUX KERNEL By Oreilly
For a uniprocessor,
- Anonymous January 13, 2010mov eax, 1
lock_loop:
xchg [myLock], eax
jnz lock_loop
For SMP, I guess the interviewer would expect discussion on the MESI protocol for cache coherence and formation of memory hot-spots due to spinlocks. An explanation of false writes could possibly add some value in the interview.