Example #1
0
void up_idle(void)
{
#ifdef CONFIG_SMP
  /* In the SMP configuration, only one CPU should do these operations.  It
   * should not matter which, however.
   */

  static volatile spinlock_t lock;

  /* The one that gets the lock is the one that executes the IDLE operations */

  if (up_testset(&lock) != SP_UNLOCKED)
    {
      /* We didn't get it... Give other pthreads/CPUs a shot and try again
       * later.
       */

      pthread_yield();
      return;
    }
#endif

#ifdef CONFIG_SCHED_TICKLESS
  /* Driver the simulated interval timer */

  up_timer_update();
#else
  /* If the system is idle, then process "fake" timer interrupts.
   * Hopefully, something will wake up.
   */

  sched_process_timer();
#endif

#if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_SIM_UART_DATAPOST)
  /* Handle UART data availability */

  if (g_uart_data_available)
    {
      g_uart_data_available = 0;
      simuart_post();
    }
#endif


#ifdef CONFIG_NET_ETHERNET
  /* Run the network if enabled */

  netdriver_loop();
#endif

#ifdef CONFIG_PM
  /* Fake some power management stuff for testing purposes */

  {
    static enum pm_state_e state = PM_NORMAL;
    enum pm_state_e newstate;

    newstate = pm_checkstate();
    if (newstate != state)
      {
        if (pm_changestate(newstate) == OK)
          {
            state = newstate;
          }
      }
  }
#endif

#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB)
  /* Wait a bit so that the sched_process_timer() is called close to the
   * correct rate.
   */

  (void)up_hostusleep(1000000 / CLK_TCK);

  /* Handle X11-related events */

#ifdef CONFIG_SIM_X11FB
  if (g_x11initialized)
    {
#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
       /* Drive the X11 event loop */

      if (g_eventloop)
        {
          up_x11events();
        }
#endif

      /* Update the display periodically */

      g_x11refresh += 1000000 / CLK_TCK;
      if (g_x11refresh > 500000)
        {
          up_x11update();
        }
    }
#endif
#endif

#ifdef CONFIG_SMP
  /* Release the spinlock */

  lock = SP_UNLOCKED;

  /* Give other pthreads/CPUs a shot */

  pthread_yield();
#endif
}
Example #2
0
void up_idle(void)
{
  /* If the system is idle, then process "fake" timer interrupts.
   * Hopefully, something will wake up.
   */

  sched_process_timer();

  /* Run the network if enabled */

#ifdef CONFIG_NET
  uipdriver_loop();
#endif

  /* Fake some power management stuff for testing purposes */

#ifdef CONFIG_PM
  {
    static enum pm_state_e state = PM_NORMAL;
    enum pm_state_e newstate;

    newstate = pm_checkstate();
    if (newstate != state)
      {
        if (pm_changestate(newstate) == OK)
          {
            state = newstate;
          }
      }
  }
#endif

  /* Wait a bit so that the sched_process_timer() is called close to the
   * correct rate.
   */

#if defined(CONFIG_SIM_WALLTIME) || defined(CONFIG_SIM_X11FB)
  (void)up_hostusleep(1000000 / CLK_TCK);

  /* Handle X11-related events */

#ifdef CONFIG_SIM_X11FB
  if (g_x11initialized)
    {
       /* Drive the X11 event loop */

#ifdef CONFIG_SIM_TOUCHSCREEN
      if (g_eventloop)
        {
          up_x11events();
        }
#endif

      /* Update the display periodically */

      g_x11refresh += 1000000 / CLK_TCK;
      if (g_x11refresh > 500000)
        {
          up_x11update();
        }
    }
#endif
#endif
}