Cyg_Thread::Cyg_Thread | |
Name: | Cyg_Thread::Cyg_Thread ( ) - contructor to create a new thread |
---|---|
Synopsis: | Cyg_Thread::Cyg_Thread ( CYG_ADDRWORD sched_info, /* Scheduling parameter(s) */ cyg_thread_entry *entry, /* entry point function */ CYG_ADDRWORD entry_data, /* entry data */ char *name, /* thread name */ CYG_ADDRESS stack_base = 0, /* stack base, NULL = allocate */ cyg_ucount32 stack_size = 0 /* stack size, 0 = use default */ ) |
Description: | This is the constructor to create a new thread. The "sched_info" parameter is usually just the priority, although this may change depending on the scheduler that is being used. The "name" parameter is optional but it's strongly recommended that it be used. If you do use the "name" parameter it MUST be a constant string since the string will not be copied, only the pointer to it will be. NOTE: stack_base and stack_size CANNOT be 0 in this current implementation although this may change in future versions. The entry function is of type: void cyg_thread_entry(CYG_ADDRWORD data). |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::exit |
Cyg_Thread::exit | |
Name: | Cyg_Thread::exit ( ) - terminate calling thread |
---|---|
Synopsis: | static void Cyg_Thread::exit ( void ) |
Description: | This terminates the calling thread. Before exiting a thread, be sure to free any resources you may have allocated such as mutexes, semaphores, memory, etc. This will also call the destructors if there are any before exiting. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing - this function will not return |
See Also: |
Cyg_Thread::suspend | |
Name: | Cyg_Thread::suspend ( ) - suspend a thread |
---|---|
Synopsis: | void Cyg_Thread::suspend ( void ) |
Description: | This suspends a thread. For every call to suspend a thread, there must be a matching call to resume it with Cyg_Thread::resume(). Suspending a thread may prevent resources that the thread has from being released, so care must be taking in using this function. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::resume, Cyg_Thread::force_resume |
Cyg_Thread::resume | |
Name: | Cyg_Thread::resume ( ) - resume a suspended thread |
---|---|
Synopsis: | void Cyg_Thread::resume ( void ) |
Description: | This resumes a thread that has been suspended. If the thread has been suspended multiple times, the thread will have to be resumed the same number of times before it can run again. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::suspend, Cyg_Thread::force_resume |
Cyg_Thread::force_resume | |
Name: | Cyg_Thread::force_resume ( ) - force a suspended thread to be resumed |
---|---|
Synopsis: | void Cyg_Thread::force_resume ( void ) |
Description: | This resumes a thread that has been suspended regardless of how many times it's been suspended. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::suspend, Cyg_Thread::resume |
Cyg_Thread::kill | |
Name: | Cyg_Thread::kill ( ) - kill a thread |
---|---|
Synopsis: | void Cyg_Thread::kill ( void ) |
Description: | This kills the calling thread. Before killing a thread, be sure to free any resources you may have allocated such as mutexes, semaphores, memory, etc. Note that this is probably a bad way of shutting down a thread. If possible, send a signal to the thread to have it shut itself down so it can free any resources it's allocated. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: |
Cyg_Thread::release | |
Name: | Cyg_Thread::release ( ) - force a thread to wake up with the reason of BREAK |
---|---|
Synopsis: | void Cyg_Thread::release ( void ) |
Description: | This wakes a thread up from a DELAY. It may also wake the thread up on a blocking wait for a semaphore, mutex, etc. It is the responsibility of the thread being woken to detect that it's been awoken |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: |
Cyg_Thread::yield | |
Name: | Cyg_Thread::yield ( ) - yield the cpu to another thread |
---|---|
Synopsis: | static void Cyg_Thread::yield ( void ) |
Description: | This yields the current thread to another, usually of the same priority - although this depends on the scheduler implementation. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | nothing |
See Also: |
Cyg_Thread::self | |
Name: | Cyg_Thread::self ( ) - get the "this" pointer of the calling thread |
---|---|
Synopsis: | static Cyg_Thread *self ( void ) |
Description: | This function returns the thread's "this" pointer. This is most useful when in a C context and doesn't serve much purpose when working with C++ other than defensive programming. You can use this function to find out which thread was interrupted in an interrupt context. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | Pointer to the thread's "this" pointer. |
See Also: |
Cyg_Thread::set_priority | |
Name: | Cyg_Thread::set_priority ( ) - set priority of a thread |
---|---|
Synopsis: | void Cyg_Thread::set_priority ( cyg_priority new_priority /* new priority */ ) |
Description: | Changes the priority of a given thread. Note there is no error checking, so be careful to check ranges when using this to change the priority of a thread. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::get_priority, Cyg_Thread::get_current_priority |
Cyg_Thread::get_priority | |
Name: | Cyg_Thread::get_priority ( ) - get the set priority of a thread |
---|---|
Synopsis: | cyg_priority get_priority ( void ) |
Description: | This returns the set priority of a given thread. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | The set priority of a given thread. |
See Also: | Cyg_Thread::set_priority, Cyg_Thread::get_current_priority |
Cyg_Thread::get_current_priority | |
Name: | Cyg_Thread::get_current_priority ( ) - get the current priority of a thread |
---|---|
Synopsis: | cyg_priority Cyg_Thread::get_current_priority ( void ) |
Description: | This returns the current priority of a given thread. This is normally what Cyg_Thread::get_priority returns but if the thread has inherited another priority, the inherited priority will be returned instead. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | the current priority of a given thread. |
See Also: | Cyg_Thread::set_priority, Cyg_Thread::get_priority |
Cyg_Thread::delay | |
Name: | Cyg_Thread::delay ( ) - delay a thread |
---|---|
Synopsis: | void Cyg_Thread::delay ( cyg_tick_count delay /* number of ticks to delay */ ) |
Description: | This delays a thread for a specified number of ticks. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: |
Cyg_HardwareThread::get_stack_base | |
Name: | Cyg_HardwareThread::get_stack_base ( ) - get base address of a thread's stack |
---|---|
Synopsis: | CYG_ADDRESS Cyg_HardwareThread::get_stack_base ( void ) |
Description: | This returns the base address of a stack of the given thread. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | the base address of the given thread's stack |
See Also: | Cyg_HardwareThread::get_stack_size |
Cyg_HardwareThread::get_stack_size | |
Name: | Cyg_HardwareThread::get_stack_size ( ) - get the size of a thread's stack |
---|---|
Synopsis: | cyg_uint32 Cyg_HardwareThread::get_stack_size ( void ) |
Description: | This returns the size of a given thread's stack in bytes. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | the size in bytes of the given thread's stack |
See Also: | Cyg_HardwareThread::get_stack_base |
Cyg_HardwareThread::measure_stack_usage | |
Name: | Cyg_HardwareThread::measure_stack_usage ( ) - measure a stack's usage |
---|---|
Synopsis: | cyg_uint32 Cyg_HardwareThread::measure_stack_usage ( void ) |
Description: | This function measures the number of bytes that have been used for a given thread. This can help you tune your stack sizes so there is less memory usage although you should never tune your stacks so that this function returns 0. Note that this function only returns how much stack has been consumed for a given thread at the current time the function was invoked. There is no guarentee that more stack will not be consumed later. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | the number of bytes that have been used by the stack of a given thread. |
See Also: | Cyg_HardwareThread::get_stack_base, Cyg_HardwareThread::get_stack_size |
Cyg_Thread::new_data_index | |
Name: | Cyg_Thread::new_data_index ( ) - gets a new data index for per thread data |
---|---|
Synopsis: | static cyg_data_index Cyg_Thread::new_data_index ( void ) |
Description: | Gets a new index for per thread data. The index is globally allocated for each thread. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | a new (free) index that can be used to store a word of data |
See Also: | Cyg_Thread::free_data_index, Cyg_Thread::get_data, Cyg_Thread::get_data_ptr, Cyg_Thread::set_data |
Cyg_Thread::free_data_index | |
Name: | Cyg_Thread::free_data_index ( ) - free a data index for per thread data |
---|---|
Synopsis: | static void Cyg_Thread::free_data_index ( cyg_data_index index /* index to free */ ) |
Description: | This globally frees an index that was used for per thread data. |
Include: | #include <cyg/kernel/thread.hxx> |
Returns: | nothing |
See Also: | Cyg_Thread::new_data_index, Cyg_Thread::get_data, Cyg_Thread::get_data_ptr, Cyg_Thread::set_data |
Cyg_Thread::get_data | |
Name: | Cyg_Thread::get_data ( ) - get per thread data |
---|---|
Synopsis: | static CYG_ADDRWORD Cyg_Thread::get_data ( cyg_data_index index /* data index */ ) |
Description: | This function reads per thread data. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | per thread data stored at the given index. |
See Also: | Cyg_Thread::get_data_ptr, Cyg_Thread::set_data |
Cyg_Thread::get_data_ptr | |
Name: | Cyg_Thread::get_data_ptr ( ) - get per thread data pointer |
---|---|
Synopsis: | static CYG_ADDRWORD *Cyg_Thread::get_data_ptr ( Cyg_Thread::cyg_data_index index /* data index */ ) |
Description: | Gets the pointer to per thread data of the calling thread. This can be used to read or write the per thread data. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | a pointer to the per thread data. |
See Also: | Cyg_Thread::get_data, Cyg_Thread::set_data |
Cyg_Thread::set_data | |
Name: | Cyg_Thread::set_data ( ) - set per thread data |
---|---|
Synopsis: | void Cyg_Thread::set_data ( cyg_data_index index, /* index of the per thread data */ CYG_ADDRWORD data /* data to write */ ); |
Description: | This function writes per thread data. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | nothing |
See Also: | Cyg_Thread::get_data, Cyg_Thread::get_data_ptr |
Cyg_Thread::add_destructor | |
Name: | Cyg_Thread::add_destructor ( ) - add a thread destructor |
---|---|
Synopsis: | cyg_bool Cyg_Thread::add_destructor ( destructor_fn fn, /* call back destructor function */ CYG_ADDRWORD data /* data to pass to destructor */ ) |
Description: | This adds a destructor to the thread. All the destructors will be called by Cyg_Thread::exit (). The destructor callback has the following prototype void destructor_fn (CYG_ADDRWORD). |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | "true" if the destructor was added, "false" if the destructor could not be added. |
See Also: | Cyg_Thread::rem_destructor, Cyg_Thread::exit |
Cyg_Thread::rem_destructor | |
Name: | Cyg_Thread::rem_destructor ( ) - remove a thread destructor |
---|---|
Synopsis: | cyg_bool Cyg_Thread::rem_destructor ( destructor_fn fn, /* destructor to remove */ CYG_ADDRWORD data /* data that was to be passed to the destructor */ ) |
Description: | Removes a destructor from a thread. The destructor callback and the data must be match those of the constructor otherwise the destructor will not be deleted. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | "true" if the destructor was removed, "false" if the destructor could not be removed. |
See Also: | Cyg_Thread::add_destructor |
Cyg_Thread::register_exception | |
Name: | Cyg_Thread::register_exception ( ) - register an exception handler |
---|---|
Synopsis: | static void Cyg_Thread::register_exception ( cyg_code exception_number, /* exception number */ cyg_exception_handler handler, /* handler function */ CYG_ADDRWORD data, /* data argument */ cyg_exception_handler **old_handler, /* handler function */ CYG_ADDRWORD *old_data /* data argument */ ) |
Description: | This registers an exception handler for the calling thread. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | nothing |
See Also: | Cyg_Thread::deregister_exception |
Cyg_Thread::deregister_exception | |
Name: | Cyg_Thread::deregister_exception ( ) - deregister an exception |
---|---|
Synopsis: | static void deregister_exception ( cyg_code exception_number /* exception number */ ) |
Description: | This deregisters an exception handler for the calling thread. |
Include: | #include <cyg/kernel/thread.hxx>
#include <cyg/kernel/thread.inl> |
Returns: | nothing |
See Also: | Cyg_Thread::register_exception |