Thread information, Name, Synopsis – Comtrol eCos User Manual

Page 43: Description

Advertising
background image

Thread information

Name

cyg_thread_self, cyg_thread_idle_thread, cyg_thread_get_stack_base,

cyg_thread_get_stack_size, cyg_thread_measure_stack_usage,

cyg_thread_get_next, cyg_thread_get_info, cyg_thread_find

— Get basic thread

information

Synopsis

#include

<

cyg/kernel/kapi.h

>

cyg_handle_t cyg_thread_self(void);

cyg_handle_t cyg_thread_idle_thread(void);

cyg_addrword_t cyg_thread_get_stack_base(cyg_handle_t thread);

cyg_uint32 cyg_thread_get_stack_size(cyg_handle_t thread);

cyg_uint32 cyg_thread_measure_stack_usage(cyg_handle_t thread);

cyg_bool cyg_thread_get_next(cyg_handle_t *thread, cyg_uint16 *id);

cyg_bool cyg_thread_get_info(cyg_handle_t thread, cyg_uint16 id, cyg_thread_info

*info);

cyg_handle_t cyg_thread_find(cyg_uint16 id);

Description

These functions can be used to obtain some basic information about various threads in the system. Typically they
serve little or no purpose in real applications, but they can be useful during debugging.

cyg_thread_self

returns a handle corresponding to the current thread. It will be the same as the value filled in

by

cyg_thread_create

when the current thread was created. This handle can then be passed to other functions

such as

cyg_thread_get_priority

.

cyg_thread_idle_thread

returns the handle corresponding to the idle thread. This thread is created automati-

cally by the kernel, so application-code has no other way of getting hold of this information.

cyg_thread_get_stack_base

and

cyg_thread_get_stack_size

return information about a specific thread’s

stack. The values returned will match the values passed to

cyg_thread_create

when this thread was created.

cyg_thread_measure_stack_usage

is

only

available

if

the

configuration

option

CYGFUN_KERNEL_THREADS_STACK_MEASUREMENT

is enabled. The return value is the maximum number of bytes

of stack space used so far by the specified thread. Note that this should not be considered a true upper bound, for
example it is possible that in the current test run the specified thread has not yet been interrupted at the deepest
point in the function call graph. Never the less the value returned can give some useful indication of the thread’s
stack requirements.

cyg_thread_get_next

is used to enumerate all the current threads in the system. It should be called initially with

the locations pointed to by

thread

and

id

set to zero. On return these will be set to the handle and ID of the first

thread. On subsequent calls, these parameters should be left set to the values returned by the previous call. The

43

Advertising