RTEMS
taskresume.c
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 1989-2014.
10  * On-Line Applications Research Corporation (OAR).
11  *
12  * The license and distribution terms for this file may be
13  * found in the file LICENSE in this distribution or at
14  * http://www.rtems.org/license/LICENSE.
15  */
16 
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #include <rtems/rtems/tasksimpl.h>
22 #include <rtems/score/threadimpl.h>
23 
25  rtems_id id
26 )
27 {
28  Thread_Control *the_thread;
29  ISR_lock_Context lock_context;
30  Per_CPU_Control *cpu_self;
31  States_Control previous_state;
32 
33  the_thread = _Thread_Get( id, &lock_context );
34 
35  if ( the_thread == NULL ) {
36 #if defined(RTEMS_MULTIPROCESSING)
37  return _RTEMS_tasks_MP_Resume( id );
38 #else
39  return RTEMS_INVALID_ID;
40 #endif
41  }
42 
43  cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
44  _ISR_lock_ISR_enable( &lock_context );
45 
46  previous_state = _Thread_Clear_state( the_thread, STATES_SUSPENDED );
47 
48  _Thread_Dispatch_enable( cpu_self );
49  return _States_Is_suspended( previous_state ) ?
51 }
#define _ISR_lock_ISR_enable(_context)
Restores the saved interrupt state of the ISR lock context.
Definition: isrlock.h:416
Thread_Control * _Thread_Get(Objects_Id id, ISR_lock_Context *lock_context)
Gets a thread by its identifier.
Definition: threadget.c:24
rtems_status_code rtems_task_resume(rtems_id id)
%
Definition: taskresume.c:24
uint32_t States_Control
Definition: states.h:46
This status code indicates successful completion.
Definition: status.h:86
static __inline__ Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
Per CPU Core Structure.
Definition: percpu.h:347
This status code indicates that an object was in wrong state for the requested operation.
Definition: status.h:160
States_Control _Thread_Clear_state(Thread_Control *the_thread, States_Control state)
Clears the specified thread state.
#define STATES_SUSPENDED
Definition: statesimpl.h:96
static __inline__ bool _States_Is_suspended(States_Control the_states)
Checks if SUSPENDED state is set.
Definition: statesimpl.h:231
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
This status code indicates that an object identifier was invalid.
Definition: status.h:106
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
Inlined Routines from the Thread Handler.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
Classic Tasks Manager Implementation.