Skip to content

Instantly share code, notes, and snippets.

@onesuper
Last active December 15, 2015 03:29
Show Gist options
  • Select an option

  • Save onesuper/5194775 to your computer and use it in GitHub Desktop.

Select an option

Save onesuper/5194775 to your computer and use it in GitHub Desktop.
struct foo {
int x;
int y;
};
static struct foo f;
/* The two following functions are running concurrently: */
int sum_a(void)
{
int s = 0;
int i;
for (i = 0; i < 1000000; ++i)
s += f.x;
return s;
}
void inc_b(void)
{
int i;
for (i = 0; i < 1000000; ++i)
++f.y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment