Sequential Perspective

#include <stdio.h>
int r1 = 0, r2 = 0;
int main(void)
{
	do_one_thing(&r1);
	do_another_thing(&r2);
	do_wrap_up(r1, r2);
	return 0;
}

In a serial system, we see this program as a sequence of instructions executed one-by-one.

  • Starts from main()
  • Executes the instructions for do_one_thing()
  • Then do_another_thing()
  • Finally do_wrap_up()

Concurrent perspective

#include <stdio.h>
int r1 = 0, r2 = 0;
int main(void)
{
	do_one_thing(&r1);
	do_another_thing(&r2);
	do_wrap_up(r1, r2);
	return 0;
}

If its possible to execute some of these subtasks at the same time with no change in final result (i.e., correctness), then we can reduce overall time by executing these subtasks concurrently. Exec as ‘threads’ within program.