operating system - variable sharing between isr and function call -
consider following code
int var; function1() { [cs_start] var++; [cs_end] } function2() { [cs_start] var += 2; [cs_end] } isr() { [cs_start] var--; [cs_end] }
how protect var in multitasking environment? 1 of design understand keep var volatile such safe in multiprocessor scheduling scheme. additionally spin lock (in place of mutex) can implemented protect critical section.
what happens if spinlock acquired function1 , isr occurs (with higher priority scheduler timer) isr keep on polling , function1 never gets chance release lock. solution problem ?
Comments
Post a Comment