Exemplo n.º 1
0
int pthread_spin_unlock(
  pthread_spinlock_t *spinlock
)
{
  POSIX_Spinlock_Control  *the_spinlock = NULL;
  Objects_Locations        location;
  CORE_spinlock_Status     status;

  if ( !spinlock )
    return EINVAL;

  the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
  switch ( location ) {

    case OBJECTS_LOCAL:
      status = _CORE_spinlock_Release( &the_spinlock->Spinlock );
      _Thread_Enable_dispatch();
      return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );

#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
      break;
  }

  return EINVAL;
}
Exemplo n.º 2
0
/**
 *  This directive allows a thread to delete a spinlock specified by
 *  the spinlock id.  The spinlock is freed back to the inactive
 *  spinlock chain.
 *
 *  @param[in] spinlock is the spinlock id
 *
 *  @return This method returns 0 if there was not an
 *  error. Otherwise, a status code is returned indicating the
 *  source of the error.
 */
int pthread_spin_destroy(
  pthread_spinlock_t *spinlock
)
{
  POSIX_Spinlock_Control *the_spinlock = NULL;
  Objects_Locations      location;

  if ( !spinlock )
    return EINVAL;

  the_spinlock = _POSIX_Spinlock_Get( spinlock, &location );
  switch ( location ) {

    case OBJECTS_LOCAL:
      if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) {
        _Thread_Enable_dispatch();
        return EBUSY;
      }

      _Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object );

      _POSIX_Spinlock_Free( the_spinlock );

      _Thread_Enable_dispatch();
      return 0;

#if defined(RTEMS_MULTIPROCESSING)
    case OBJECTS_REMOTE:
#endif
    case OBJECTS_ERROR:
      break;
  }

  return EINVAL;
}
Exemplo n.º 3
0
int pthread_spin_unlock( pthread_spinlock_t *lock )
{
  POSIX_Spinlock_Control *the_spinlock;
  ISR_Level               level;

  the_spinlock = _POSIX_Spinlock_Get( lock );
  level = the_spinlock->interrupt_state;
#if defined(POSIX_SPINLOCKS_ARE_SELF_CONTAINED)
#if defined(RTEMS_SMP)
  _SMP_ticket_lock_Release(
    &the_spinlock->Lock,
    &_Per_CPU_Get()->Lock_stats_context
  );
#endif
  _ISR_Local_enable( level );
#else
  if ( --_POSIX_Spinlock_Nest_level == 0 ) {
#if defined(RTEMS_SMP)
    _POSIX_Spinlock_Owner = 0xffffffff;
    _SMP_ticket_lock_Release(
      &the_spinlock->Lock,
      &_Per_CPU_Get()->Lock_stats_context
    );
#endif
    _ISR_Local_enable( level );
  }
#endif
  return 0;
}
Exemplo n.º 4
0
int pthread_spin_destroy( pthread_spinlock_t *spinlock )
{
#if defined(RTEMS_SMP) && defined(POSIX_SPINLOCKS_ARE_SELF_CONTAINED)
  POSIX_Spinlock_Control *the_spinlock;

  the_spinlock = _POSIX_Spinlock_Get( spinlock );
  _SMP_ticket_lock_Destroy( &the_spinlock->Lock );
#endif
  return 0;
}
Exemplo n.º 5
0
int pthread_spin_init(
    pthread_spinlock_t  *spinlock,
    int                  pshared
)
{
#if defined(RTEMS_SMP) && defined(POSIX_SPINLOCKS_ARE_SELF_CONTAINED)
    POSIX_Spinlock_Control *the_spinlock;

    the_spinlock = _POSIX_Spinlock_Get( spinlock );
    _SMP_ticket_lock_Initialize( &the_spinlock->Lock );
#endif
    return 0;
}
Exemplo n.º 6
0
int pthread_spin_unlock( pthread_spinlock_t *spinlock )
{
  POSIX_Spinlock_Control *the_spinlock;
  ISR_lock_Context        lock_context;
  CORE_spinlock_Status    status;

  the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context );
  if ( the_spinlock == NULL ) {
    return EINVAL;
  }

  status = _CORE_spinlock_Surrender( &the_spinlock->Spinlock, &lock_context );
  return _POSIX_Spinlock_Translate_core_spinlock_return_code( status );
}
Exemplo n.º 7
0
int pthread_spin_lock( pthread_spinlock_t *spinlock )
{
  POSIX_Spinlock_Control *the_spinlock;
  ISR_lock_Context        lock_context;
  Status_Control          status;

  the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context );
  if ( the_spinlock == NULL ) {
    return EINVAL;
  }

  status = _CORE_spinlock_Seize(
    &the_spinlock->Spinlock,
    true,
    0,
    &lock_context
  );
  return _POSIX_Get_error( status );
}