Introduction   API Reference   Examples   Index  

Exit / shutdown threads
[L4 Thread Library API Reference]

When and how threads are deleted . More...

Data Structures

struct  l4thread_exit_desc
 Exit functions descriptor, see L4THREAD_EXIT_FN. More...

Defines

#define L4THREAD_EXIT_FN_(vis, name, fn)   vis l4thread_exit_desc_t name = { fn, NULL, NULL}
 Declare exit function, generic version.
#define L4THREAD_EXIT_FN(name, fn)   L4THREAD_EXIT_FN_(,name,fn)
 Declare exit function (global scope).
#define L4THREAD_EXIT_FN_STATIC(name, fn)   L4THREAD_EXIT_FN_(static,name,fn)
 Declare exit function (static scope).

Typedefs

typedef L4_CV void(* l4thread_exit_fn_t )(l4thread_t thread, void *data)
 Exit functions (see l4thread_on_exit()).
typedef struct l4thread_exit_desc l4thread_exit_desc_t
 Exit functions descriptor, see L4THREAD_EXIT_FN.

Functions

int l4thread_shutdown (l4thread_t thread)
 Shutdown thread.
L4_CV void l4thread_exit (void) __attribute__((noreturn))
 Exit current thread.
L4_CV int l4thread_on_exit (l4thread_exit_desc_t *name, void *data)
 Register exit function for current thread.

Detailed Description

When and how threads are deleted .

..

A thread exits if:

  1. its thread function returns
  2. it kills itself using l4thread_shutdown()
  3. is is killed using l4thread_exit().

Define Documentation

#define L4THREAD_EXIT_FN_ ( vis,
name,
fn   )     vis l4thread_exit_desc_t name = { fn, NULL, NULL}

Declare exit function, generic version.

Parameters:
vis Scope (global or static)
name Funtion name to declare
fn Exit function

#define L4THREAD_EXIT_FN ( name,
fn   )     L4THREAD_EXIT_FN_(,name,fn)

Declare exit function (global scope).

Parameters:
name Funtion name to declare
fn Exit function

#define L4THREAD_EXIT_FN_STATIC ( name,
fn   )     L4THREAD_EXIT_FN_(static,name,fn)

Declare exit function (static scope).

Parameters:
name Funtion name to declare
fn Exit function


Typedef Documentation

typedef L4_CV void(* l4thread_exit_fn_t)(l4thread_t thread, void *data)

Exit functions (see l4thread_on_exit()).

Parameters:
thread Thread which exists
data Data pointer


Function Documentation

int l4thread_shutdown ( l4thread_t  thread  ) 

Shutdown thread.

Parameters:
thread Thread id of thread to shutdown
Returns:
0 on success, error code otherwise:
  • -L4_EINVAL invalid thread
Shutdown thread thread. All allocated resources are released (stack, thread control block) and the L4 thread is blocked.

L4_CV void l4thread_exit ( void   ) 

Exit current thread.

Exit current thread, it is equivalent to l4thread_shutdown(l4thread_myself()), but indicates to the compiler that it does not return.

L4_CV int l4thread_on_exit ( l4thread_exit_desc_t name,
void *  data 
)

Register exit function for current thread.

Parameters:
name Exit function descriptor, it must be declared with the L4THREAD_EXIT_FN macros
data Data pointer which will be passed to the exit function
Returns:
0 on success, error code otherwise
  • -L4_EINVAL invalid error function / thread
Register exit function. Threads can have more than one exit function, they will be called in the reverse order of their registration. The same exit function can be used several times, but for each use a separate exit function descriptor mus be defined with the L4THREAD_EXIT_FN macros.


L4 Thread Library Reference Manual, written by Lars Reuther  © 2000-2003