[Haskell-cafe] Atom's `__global_clock' and `__scheduling_clock'.

Jason Dusek jason.dusek at gmail.com
Sun Jan 3 03:15:08 EST 2010


  I am mystified by the relationship between Atom's
  `__global_clock' and the `scheduling_clock'. For example, here
  is some generated code:

    /* Includes omitted. */

    static uint64_t __global_clock = 0;

    /* Subroutine declarations omitted. */

    void main(void) {
      {
        static uint8_t __scheduling_clock = 0;
        if (__scheduling_clock == 0) {
          __r0();  /* main.set_up_pins */
          __r1();  /* main.set_up_timer */
          __scheduling_clock = 0;
        }
        else {
          __scheduling_clock = __scheduling_clock - 1;
        }
      }

      __global_clock = __global_clock + 1;
    }

  Looking at code generated by an older version of Atom, it
  seems like there used not be separate "global" and
  "scheduling" clocks:

    /* From http://code.sw17ch.com/blog/atom/blink_atom.c */

    void blink_atom(void) {
      if (__clock % 1 == 0) {
        r0();  /* blink_atom.decrement */
      }
      if (__clock % 2 == 0) {
        r1();  /* blink_atom.reset */
      }
      if (__clock % 2 == 1) {
        r2();  /* blink_atom.flip */
      }

      __clock = __clock + 1;
    }

  I would like to know how the `__global_clock' influences
  execution in the present system.

--
Jason Dusek


More information about the Haskell-Cafe mailing list