I’ve been trying to implement a linux system_call that has been giving me problems and I suspect it’s because there is no locking(or maybe preemption) going on with my code.
There is a critical section I have in a very frequently called function(this custom function gets called every time a system_call is made), and it gets started/stopped by system_calls as well. Is there any way to ensure that a this critical segment that happens every time any system call is made in the linux kernel is non-preemptable and must finish execution before anything else can happen?
If I understand the question correctly, the simplest way is to use a spin-lock:
Such critical section will be non-preemptable and concurrent executions of critical section won’t overlap.