Threading


Typedefs

typedef implementation_defined os_thread_t

Functions

int os_thread_create (os_thread_t *thread, const char *name, void(*func)(void *), void *arg)
void os_thread_stop (os_thread_t *thread, os_event_t *evt)
int os_thread_should_stop (os_thread_t *thread)
void os_try_suspend_thread (os_thread_t *thread)

Detailed Description

Threading support depends on the event API provided by <oska/event.h> (see Events).

Typedef Documentation

typedef implementation_defined os_thread_t

Implementation defined thread object.


Function Documentation

int os_thread_create ( os_thread_t thread,
const char *  name,
void(*)(void *)  func,
void *  arg 
)

Create and start a thread.

The thread function should call os_thread_should_stop() and return when it returns true.

Callable from: thread context.

Parameters:
thread pointer to OS-specific thread data.
name thread name.
func thread entry-point function.
arg argument for func.
Returns:
0 on success; negative error code otherwise.

int os_thread_should_stop ( os_thread_t thread  ) 

Return true if the thread should stop (as signalled by a call to os_thread_stop()).

Parameters:
thread the thread to check.
Returns:
true iff the thread should stop.

void os_thread_stop ( os_thread_t thread,
os_event_t *  evt 
)

Stop a thread and wait for it to exit.

If evt is non-NULL it will be posted to awaken the thread. The thread will also be awakened if it's asleep (in a os_sleep_ms() call for example).

Callable from: thread context.

Parameters:
thread the thread to stop.
evt a event to raise to awaken the thread, may be NULL.
Returns:
0 on success; -ve otherwise.

void os_try_suspend_thread ( os_thread_t thread  ) 

Try to suspend a thread.

This specifies a point where it is safe for a thread to be suspended.

Callable from: thread context.

Parameters:
thread pointer to OS-specific thread data.


Generated on Wed Oct 27 15:14:03 2010 for oska by  doxygen 1.5.5