I'm pretty new to Linux device drivers and kernel. I basically want to synchronize a workque thread (Lets call it A()) with another function (Lets call it B()). My purpose here is to fail B when A is running.
Currently, what I have done is as follows.
A(){
active = true; // a variable shared b/w both A and B
...
...
...
active = false;
}
B(){
if(active){
return -EBUSY
}
}
Is this the right way to synchronize these 2 functions? Is there any other strategy I should follow?
B()is called from (in which context, process or atomic) and how much code each function has. Please share the actual code with us. - Sam Protsenko