title: How does freeRTOS maintain function variables while switching threads?
body: <p>Recently I have been developing my own RTOS for ARM and PIC devices so I am analysing current RTOS concepts.  I am having some doubts while studying FreeRTOS,</p>
  
  <p>How is it handling function variables? How we can manage the variable inside a function?</p>
  
  <p><strong>Ex-1:</strong></p>
  
  <p>We declared a local variable 'i' in two threads with functions A and B in
  FreeRTOS, but variable 'i' of function A is affected by function B.</p>
  
  <p><strong>Ex-2:</strong></p>
  
  <p>We have two threads A , B and one function like delay. But both threads A and B call the same function <code>delay</code>. How does FreeRTOS allocate a single delay resource to two threads (A and B)?</p>