RTEMS
threadstart.c
Go to the documentation of this file.
1 
9 /*
10  * COPYRIGHT (c) 1989-1999.
11  * On-Line Applications Research Corporation (OAR).
12  *
13  * The license and distribution terms for this file may be
14  * found in the file LICENSE in this distribution or at
15  * http://www.rtems.org/license/LICENSE.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21 
22 #include <rtems/score/threadimpl.h>
23 #include <rtems/score/isrlevel.h>
25 
27  Thread_Control *the_thread,
28  const Thread_Entry_information *entry,
29  ISR_lock_Context *lock_context
30 )
31 {
32  Per_CPU_Control *cpu_self;
33 
34  _Thread_State_acquire_critical( the_thread, lock_context );
35 
36  if ( !_States_Is_dormant( the_thread->current_state ) ) {
37  _Thread_State_release( the_thread, lock_context );
38  return false;
39  }
40 
41  the_thread->Start.Entry = *entry;
42  _Thread_Load_environment( the_thread );
44 
45  cpu_self = _Thread_Dispatch_disable_critical( lock_context );
46  _Thread_State_release( the_thread, lock_context );
47 
48  _User_extensions_Thread_start( the_thread );
49 
50  _Thread_Dispatch_enable( cpu_self );
51  return true;
52 }
void _Thread_Load_environment(Thread_Control *the_thread)
Initializes enviroment for a thread.
Definition: threadloadenv.c:24
#define STATES_ALL_SET
Definition: statesimpl.h:144
Thread entry information.
Definition: thread.h:130
static __inline__ void _Thread_State_acquire_critical(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Acquires the lock context in a critical section.
Definition: threadimpl.h:528
Thread_Start_information Start
Definition: thread.h:825
ISR Level Type.
Thread_Entry_information Entry
Definition: thread.h:180
User Extension Handler API.
static __inline__ void _Thread_State_release(Thread_Control *the_thread, ISR_lock_Context *lock_context)
Releases the lock context and enables interrupts.
Definition: threadimpl.h:592
static __inline__ Per_CPU_Control * _Thread_Dispatch_disable_critical(const ISR_lock_Context *lock_context)
Disables thread dispatching inside a critical section (interrupts disabled).
static __inline__ bool _States_Is_dormant(States_Control the_states)
Checks if DORMANT state is set.
Definition: statesimpl.h:213
Per CPU Core Structure.
Definition: percpu.h:347
States_Control current_state
Definition: thread.h:749
void _Thread_Dispatch_enable(Per_CPU_Control *cpu_self)
Enables thread dispatching.
static void _User_extensions_Thread_start(Thread_Control *started)
Starts a thread.
Definition: userextimpl.h:323
States_Control _Thread_Clear_state_locked(Thread_Control *the_thread, States_Control state)
Clears the specified thread state without locking the lock context.
bool _Thread_Start(Thread_Control *the_thread, const Thread_Entry_information *entry, ISR_lock_Context *lock_context)
Starts the specified thread.
Definition: threadstart.c:26
Inlined Routines from the Thread Handler.
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65