source: rtems/cpukit/rtems/src/taskgetscheduler.c @ ef6f8a83

Last change on this file since ef6f8a83 was ef6f8a83, checked in by Sebastian Huber <sebastian.huber@…>, on May 11, 2016 at 12:03:23 PM

score: Avoid Giant lock for scheduler set/get

Update #2555.

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[27270b0d]1/*
2 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#if HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#include <rtems/rtems/tasks.h>
20#include <rtems/score/schedulerimpl.h>
21
22rtems_status_code rtems_task_get_scheduler(
[e5274df]23  rtems_id  task_id,
[27270b0d]24  rtems_id *scheduler_id
25)
26{
[ef6f8a83]27  Thread_Control          *the_thread;
28  ISR_lock_Context         lock_context;
29  const Scheduler_Control *scheduler;
30
31  if ( scheduler_id == NULL ) {
32    return RTEMS_INVALID_ADDRESS;
33  }
34
35  the_thread = _Thread_Get_interrupt_disable( task_id, &lock_context );
36
37  if ( the_thread == NULL ) {
[27270b0d]38#if defined(RTEMS_MULTIPROCESSING)
[ef6f8a83]39    if ( _Thread_MP_Is_remote( task_id ) ) {
40      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
[27270b0d]41    }
[ef6f8a83]42#endif
43
44    return RTEMS_INVALID_ID;
[27270b0d]45  }
46
[ef6f8a83]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;
[27270b0d]54}
Note: See TracBrowser for help on using the repository browser.