示例#1
0
int _POSIX_Priority_From_core(
  const Scheduler_Control *scheduler,
  Priority_Control         core_priority
)
{
  core_priority = _Scheduler_Unmap_priority( scheduler, core_priority );

  return (int) ( scheduler->maximum_priority - core_priority );
}
示例#2
0
void
rtems_monitor_sema_canonical(
    rtems_monitor_sema_t  *canonical_sema,
    const void            *sema_void
)
{
    const Semaphore_Control *rtems_sema = (const Semaphore_Control *) sema_void;
    Thread_Control *owner;

    memset(canonical_sema, 0, sizeof(*canonical_sema));

#if defined(RTEMS_MULTIPROCESSING)
    if (rtems_sema->is_global) {
      canonical_sema->attribute |= RTEMS_GLOBAL;
    }
#endif

    if (rtems_sema->discipline == SEMAPHORE_DISCIPLINE_PRIORITY) {
      canonical_sema->attribute |= RTEMS_PRIORITY;
    }

    switch ( rtems_sema->variant ) {
      case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
        canonical_sema->attribute |= RTEMS_BINARY_SEMAPHORE
          | RTEMS_INHERIT_PRIORITY;
        break;
      case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
        canonical_sema->attribute |= RTEMS_BINARY_SEMAPHORE
          | RTEMS_PRIORITY_CEILING;
        break;
      case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
        canonical_sema->attribute |= RTEMS_BINARY_SEMAPHORE;
        break;
#if defined(RTEMS_SMP)
      case SEMAPHORE_VARIANT_MRSP:
        canonical_sema->attribute |= RTEMS_BINARY_SEMAPHORE
          | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING;
        break;
#endif
      case SEMAPHORE_VARIANT_SIMPLE_BINARY:
        canonical_sema->attribute |= RTEMS_SIMPLE_BINARY_SEMAPHORE;
        break;
      case SEMAPHORE_VARIANT_COUNTING:
        canonical_sema->attribute |= RTEMS_COUNTING_SEMAPHORE;
        break;
    }

    switch ( rtems_sema->variant ) {
      case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
        canonical_sema->priority_ceiling = _Scheduler_Unmap_priority(
          _CORE_ceiling_mutex_Get_scheduler( &rtems_sema->Core_control.Mutex ),
          _CORE_ceiling_mutex_Get_priority( &rtems_sema->Core_control.Mutex )
        );
        /* Fall through */
      case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
      case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
        owner = _CORE_mutex_Get_owner(
          &rtems_sema->Core_control.Mutex.Recursive.Mutex
        );

        if (owner != NULL) {
          canonical_sema->holder_id = owner->Object.id;
          canonical_sema->cur_count = 0;
        } else {
          canonical_sema->cur_count = 1;
        }

        canonical_sema->max_count = 1;
        break;
#if defined(RTEMS_SMP)
      case SEMAPHORE_VARIANT_MRSP:
        canonical_sema->cur_count =
          _MRSP_Get_owner( &rtems_sema->Core_control.MRSP ) == NULL;
        canonical_sema->max_count = 1;
        break;
#endif
      case SEMAPHORE_VARIANT_SIMPLE_BINARY:
        canonical_sema->cur_count = rtems_sema->Core_control.Semaphore.count;
        canonical_sema->max_count = 1;
        break;
      case SEMAPHORE_VARIANT_COUNTING:
        canonical_sema->cur_count = rtems_sema->Core_control.Semaphore.count;
        canonical_sema->max_count = UINT32_MAX;
        break;
    }
}