5
Line | |
---|
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 | |
---|
22 | rtems_status_code rtems_task_get_scheduler( |
---|
23 | rtems_id task_id, |
---|
24 | rtems_id *scheduler_id |
---|
25 | ) |
---|
26 | { |
---|
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 ) { |
---|
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; |
---|
54 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.