Ignore:
Timestamp:
May 11, 2016, 12:03:23 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0727760
Parents:
8bc6bf28
git-author:
Sebastian Huber <sebastian.huber@…> (05/11/16 12:03:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (05/12/16 11:24:41)
Message:

score: Avoid Giant lock for scheduler set/get

Update #2555.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/src/taskgetscheduler.c

    r8bc6bf28 ref6f8a83  
    2525)
    2626{
    27   rtems_status_code sc;
     27  Thread_Control          *the_thread;
     28  ISR_lock_Context         lock_context;
     29  const Scheduler_Control *scheduler;
    2830
    29   if ( scheduler_id != NULL ) {
    30     Thread_Control          *the_thread;
    31     Objects_Locations        location;
    32     const Scheduler_Control *scheduler;
    33 
    34     the_thread = _Thread_Get( task_id, &location );
    35 
    36     switch ( location ) {
    37       case OBJECTS_LOCAL:
    38         scheduler = _Scheduler_Get( the_thread );
    39         *scheduler_id = _Scheduler_Build_id(
    40           _Scheduler_Get_index( scheduler )
    41         );
    42         _Objects_Put( &the_thread->Object );
    43         sc = RTEMS_SUCCESSFUL;
    44         break;
    45 #if defined(RTEMS_MULTIPROCESSING)
    46       case OBJECTS_REMOTE:
    47         _Thread_Dispatch();
    48         sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
    49         break;
    50 #endif
    51       default:
    52         sc = RTEMS_INVALID_ID;
    53         break;
    54     }
    55   } else {
    56     sc = RTEMS_INVALID_ADDRESS;
     31  if ( scheduler_id == NULL ) {
     32    return RTEMS_INVALID_ADDRESS;
    5733  }
    5834
    59   return sc;
     35  the_thread = _Thread_Get_interrupt_disable( task_id, &lock_context );
     36
     37  if ( the_thread == NULL ) {
     38#if defined(RTEMS_MULTIPROCESSING)
     39    if ( _Thread_MP_Is_remote( task_id ) ) {
     40      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
     41    }
     42#endif
     43
     44    return RTEMS_INVALID_ID;
     45  }
     46
     47  _Thread_State_acquire_critical( the_thread, &lock_context );
     48
     49  scheduler = _Scheduler_Get( the_thread );
     50  *scheduler_id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) );
     51
     52  _Thread_State_release( the_thread, &lock_context );
     53  return RTEMS_SUCCESSFUL;
    6054}
Note: See TracChangeset for help on using the changeset viewer.