Exemplo n.º 1
0
/* Lock the spin lock object LOCK.  If the lock is held by another
   thread spin until it becomes available.  */
int
_pthread_spin_lock (__pthread_spinlock_t *lock)
{
  int i;

#ifdef USE_L4
  /* Start with a small timeout of 2 microseconds, then back off
     exponentially.  */
  l4_time_t timeout;
  timeout = l4_time_period (2);
#else
# warning Do not know how to sleep on this platform.
#endif

  while (1)
    {
      for (i = 0; i < __pthread_spin_count; i++)
	{
	  if (__pthread_spin_trylock (lock) == 0)
	    return 0;
	}

#ifdef USE_L4
      l4_sleep (timeout);

      timeout = l4_time_mul2 (timeout);
      if (timeout == L4_NEVER)
	timeout = L4_TIME_PERIOD_MAX;
#endif
    }
}
Exemplo n.º 2
0
/* Lock the spin lock object LOCK.  If the lock is held by another
   thread spin until it becomes available.  */
int
_pthread_spin_lock (__pthread_spinlock_t *lock)
{
  l4_time_t timeout;
  int i;

  /* Start with a small timeout of 2 microseconds, then back off
     exponentially.  */
  timeout = l4_time_period (2);

  while (1)
    {
      for (i = 0; i < __pthread_spin_count; i++)
	{
	  if (__pthread_spin_trylock (lock) == 0)
	    return 0;
	}
      l4_sleep (timeout);

      timeout = l4_time_mul2 (timeout);
      if (timeout == L4_NEVER)
	timeout = L4_TIME_PERIOD_MAX;
    }
}
Exemplo n.º 3
0
void
shutdown_machine (void)
{
  if (shutdown_reset)
    {
      l4_time_t timespec = l4_time_period (SLEEP_TIME * 1000UL * 1000UL);

      l4_sleep (timespec);
      reset ();
    }
  else
    halt ();

  /* Never reached.  */
  if (shutdown_reset)
    {
      printf ("Unable to reset this machine.\n");
      halt ();
    }

  printf ("Unable to halt this machine.\n");
  while (1)
    ;
}