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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -