Thread Management
[RT-Thread Kernel API]


Functions

rt_err_t rt_thread_init (struct rt_thread *thread, const char *name, void(*entry)(void *parameter), void *parameter, void *stack_start, rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick)
rt_err_t rt_thread_detach (rt_thread_t thread)
rt_thread_t rt_thread_create (const char *name, void(*entry)(void *parameter), void *parameter, rt_uint32_t stack_size, rt_uint8_t priority, rt_uint32_t tick)
rt_thread_t rt_thread_self (void)
rt_err_t rt_thread_startup (rt_thread_t thread)
rt_err_t rt_thread_delete (rt_thread_t thread)
rt_err_t rt_thread_yield (void)
rt_err_t rt_thread_delay (rt_tick_t tick)
rt_err_t rt_thread_suspend (rt_thread_t thread)
rt_err_t rt_thread_resume (rt_thread_t thread)
void rt_thread_timeout (void *parameter)
void rt_thread_idle_init (void)
void rt_thread_idle_sethook (void(*hook)())
void rt_system_scheduler_init (void)
void rt_system_scheduler_start (void)
void rt_schedule (void)
void rt_schedule_insert_thread (struct rt_thread *thread)
void rt_schedule_remove_thread (struct rt_thread *thread)
void rt_enter_critical (void)
void rt_exit_critical (void)
rt_err_t rt_thread_sleep (rt_tick_t tick)

Detailed Description

RT-Thread operating system supports multi-task systems, which are based on thread scheduling.

Function Documentation

void rt_enter_critical (  ) 

This function will lock the thread scheduler.

void rt_exit_critical (  ) 

This function will unlock the thread scheduler.

void rt_schedule (  ) 

This function will perform one schedule. It will select one thread with the highest priority level, then switch to it.

void rt_schedule_insert_thread ( struct rt_thread *  thread  ) 

This function will insert a thread to system ready queue. The state of thread will be set as READY and remove from suspend queue.

Parameters:
thread the thread to be inserted
Note:
Please do not invoke this function in user application.

void rt_schedule_remove_thread ( struct rt_thread *  thread  ) 

This function will remove a thread from system ready queue.

Parameters:
thread the thread to be removed
Note:
Please do not invoke this function in user application.

void rt_system_scheduler_init ( void   ) 

This function will init the system scheduler

void rt_system_scheduler_start ( void   ) 

This function will startup scheduler. It will select one thread with the highest priority level, then switch to it.

rt_thread_t rt_thread_create ( const char *  name,
void(*)(void *parameter)  entry,
void *  parameter,
rt_uint32_t  stack_size,
rt_uint8_t  priority,
rt_uint32_t  tick 
)

This function will create a thread object and allocate thread object memory and stack.

Parameters:
name the name of thread, which shall be unique
entry the entry function of thread
parameter the parameter of thread enter function
stack_size the size of thread stack
priority the priority of thread
tick the time slice if there are same priority thread
Returns:
the created thread object

rt_err_t rt_thread_delay ( rt_tick_t  tick  ) 

This function will let current thread delay for some ticks.

Parameters:
tick the delay ticks
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

rt_err_t rt_thread_delete ( rt_thread_t  thread  ) 

This function will delete a thread. The thread object will be remove from thread queue and detached/deleted from system object management.

Parameters:
thread the thread to be deleted
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

rt_err_t rt_thread_detach ( rt_thread_t  thread  ) 

This function will detach a thread. The thread object will be remove from thread queue and detached/deleted from system object management.

Parameters:
thread the thread to be deleted
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

void rt_thread_idle_init (  ) 

This function will initialize idle thread, then start it.

Note:
this function must be invoked when system init.

void rt_thread_idle_sethook ( void(*)()  hook  ) 

This function will set a hook function to idle thread loop.

Parameters:
hook the specified hook function
Note:
the hook function must be simple and never be blocked or suspend.

rt_err_t rt_thread_init ( struct rt_thread *  thread,
const char *  name,
void(*)(void *parameter)  entry,
void *  parameter,
void *  stack_start,
rt_uint32_t  stack_size,
rt_uint8_t  priority,
rt_uint32_t  tick 
)

This function will init a thread, normally it's used to initialize a static thread object.

Parameters:
thread the static thread object
name the name of thread, which shall be unique
entry the entry function of thread
parameter the parameter of thread enter function
stack_start the start address of thread stack
stack_size the size of thread stack
priority the priority of thread
tick the time slice if there are same priority thread
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

rt_err_t rt_thread_resume ( rt_thread_t  thread  ) 

This function will resume a thread and put it to system ready queue.

Parameters:
thread the thread to be resumed
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

rt_thread_t rt_thread_self ( void   ) 

This function will return self thread object

Returns:
the self thread object

rt_err_t rt_thread_sleep ( rt_tick_t  tick  ) 

This function will let current thread sleep for some ticks.

Parameters:
tick the sleep ticks
Returns:
the operation status, RT_EOK on OK; RT_ERROR on error

rt_err_t rt_thread_startup ( rt_thread_t  thread  ) 

This function will start a thread and put it to system ready queue

Parameters:
thread the thread to be started
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

rt_err_t rt_thread_suspend ( rt_thread_t  thread  ) 

This function will suspend the specified thread.

Parameters:
thread the thread to be suspended
Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error

void rt_thread_timeout ( void *  parameter  ) 

This function is the timeout function for thread, normally which will be invoked when thread is timeout to wait some recourse.

Parameters:
parameter the parameter of thread timeout function

rt_err_t rt_thread_yield (  ) 

This function will let current thread yield processor, and scheduler will get a highest thread to run. After yield processor, the current thread is still in READY state.

Returns:
the operation status, RT_EOK on OK; -RT_ERROR on error


Generated on Thu Oct 9 07:19:09 2008 for RT-Thread Kernel by  doxygen 1.5.7