user29892: I am using an Arduino due and have multiple schedules running at the same time. I am using this Library. 
I have a function that 3 different loops use. Two of the loops are driven by user interaction so timing is not possible. The function does reset global variables and I would have no issue with the variables being reset multiple times as it wouldn't cause any problems for me. 
What I was wondering, on the very slim chance that two loops called the function at the same time, is it possible for the loops to modify the same variable at identical times?
My understanding of the scheduler would lead me to believe that the scheduler will only yield to another loop after it has completed a line of code and thus the to instructions to reset the global variable could not happen at the very same time, just extremely quickly one after the other. 
Would this be a correct assumption? 

user313: From the [Arduino Reference][1] pages:

This is a cooperative scheduler in that the CPU switches from one task
  to another. The library includes methods for passing control between
  tasks.

[emphasis mine]
Which means that your code decides when it yields control to another scheduled loop (by calling yield(). At a quick glance, it appears that it also yields by returning. So yes, your assumption is correct.

29892: <p>I am using an Arduino due and have multiple schedules running at the same time. I am using this <a href="https://github.com/arduino-libraries/Scheduler" rel="nofollow noreferrer">Library</a>. </p>

<p>I have a function that 3 different loops use. Two of the loops are driven by user interaction so timing is not possible. The function does reset global variables and I would have no issue with the variables being reset multiple times as it wouldn't cause any problems for me. </p>

<p>What I was wondering, on the very slim chance that two loops called the function at the same time, is it possible for the loops to modify the same variable at identical times?</p>

<p>My understanding of the scheduler would lead me to believe that the scheduler will only yield to another loop after it has completed a line of code and thus the to instructions to reset the global variable could not happen at the very same time, just extremely quickly one after the other. </p>

<p>Would this be a correct assumption? </p>
 313: <p>From the [Arduino Reference][1] pages:</p>

<blockquote>
  <p>This is a cooperative scheduler in that the CPU switches from one task
  to another. <em>The library includes methods for passing control between
  tasks.</em></p>
</blockquote>

<p>[emphasis mine]</p>

<p>Which means that your code decides when it yields control to another scheduled loop (by calling <code>yield()</code>. At a quick glance, it appears that it also yields by returning. So yes, your assumption is correct.</p>
