summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/taskgetscheduler.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-11 14:03:23 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-12 13:24:41 +0200
commitef6f8a8377964a2d94eb7215724d11b499ec078b (patch)
treeaae76c846caa88944627c51b6589ab9caeb24ce0 /cpukit/rtems/src/taskgetscheduler.c
parentposix: Avoid Giant lock for some pthread functions (diff)
downloadrtems-ef6f8a8377964a2d94eb7215724d11b499ec078b.tar.bz2
score: Avoid Giant lock for scheduler set/get
Update #2555.
Diffstat (limited to 'cpukit/rtems/src/taskgetscheduler.c')
-rw-r--r--cpukit/rtems/src/taskgetscheduler.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/cpukit/rtems/src/taskgetscheduler.c b/cpukit/rtems/src/taskgetscheduler.c
index 47895a42e4..9d8bbb6c41 100644
--- a/cpukit/rtems/src/taskgetscheduler.c
+++ b/cpukit/rtems/src/taskgetscheduler.c
@@ -24,37 +24,31 @@ rtems_status_code rtems_task_get_scheduler(
rtems_id *scheduler_id
)
{
- rtems_status_code sc;
-
- if ( scheduler_id != NULL ) {
- Thread_Control *the_thread;
- Objects_Locations location;
- const Scheduler_Control *scheduler;
-
- the_thread = _Thread_Get( task_id, &location );
-
- switch ( location ) {
- case OBJECTS_LOCAL:
- scheduler = _Scheduler_Get( the_thread );
- *scheduler_id = _Scheduler_Build_id(
- _Scheduler_Get_index( scheduler )
- );
- _Objects_Put( &the_thread->Object );
- sc = RTEMS_SUCCESSFUL;
- break;
+ Thread_Control *the_thread;
+ ISR_lock_Context lock_context;
+ const Scheduler_Control *scheduler;
+
+ if ( scheduler_id == NULL ) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
+ the_thread = _Thread_Get_interrupt_disable( task_id, &lock_context );
+
+ if ( the_thread == NULL ) {
#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE:
- _Thread_Dispatch();
- sc = RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
- break;
-#endif
- default:
- sc = RTEMS_INVALID_ID;
- break;
+ if ( _Thread_MP_Is_remote( task_id ) ) {
+ return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
}
- } else {
- sc = RTEMS_INVALID_ADDRESS;
+#endif
+
+ return RTEMS_INVALID_ID;
}
- return sc;
+ _Thread_State_acquire_critical( the_thread, &lock_context );
+
+ scheduler = _Scheduler_Get( the_thread );
+ *scheduler_id = _Scheduler_Build_id( _Scheduler_Get_index( scheduler ) );
+
+ _Thread_State_release( the_thread, &lock_context );
+ return RTEMS_SUCCESSFUL;
}