uCOS-III的关键信息检索,基本都已经完成,不需要目标板额外做任何代码,实时检测RTOS任务执行情况。
下面开始ThreadX的Trace功能支持。
ThreadX 的TCB链表:
[C] 纯文本查看 复制代码 /* ThreadX thread control block structure follows. Additional fields
can be added providing they are added after the information that is
referenced in the port-specific assembly code. */
typedef struct TX_THREAD_STRUCT
{
/* The first section of the control block contains critical
information that is referenced by the port-specific
assembly language code. Any changes in this section could
necessitate changes in the assembly language. */
ULONG tx_thread_id; /* Control block ID */
ULONG tx_thread_run_count; /* Thread's run counter */
VOID *tx_thread_stack_ptr; /* Thread's stack pointer */
VOID *tx_thread_stack_start; /* Stack starting address */
VOID *tx_thread_stack_end; /* Stack ending address */
ULONG tx_thread_stack_size; /* Stack size */
ULONG tx_thread_time_slice; /* Current time-slice */
ULONG tx_thread_new_time_slice; /* New time-slice */
/* Define pointers to the next and previous ready threads. */
struct TX_THREAD_STRUCT
*tx_thread_ready_next,
*tx_thread_ready_previous;
/***************************************************************/
/* Define the first port extension in the thread control block. This
is typically defined to whitespace or a pointer type in tx_port.h. */
TX_THREAD_EXTENSION_0
CHAR *tx_thread_name; /* Pointer to thread's name */
UINT tx_thread_priority; /* Priority of thread (0-1023) */
UINT tx_thread_state; /* Thread's execution state */
UINT tx_thread_delayed_suspend; /* Delayed suspend flag */
UINT tx_thread_suspending; /* Thread suspending flag */
UINT tx_thread_preempt_threshold; /* Preemption threshold */
/* Define the thread schedule hook. The usage of this is port/application specific,
but when used, the function pointer designated is called whenever the thread is
scheduled and unscheduled. */
VOID (*tx_thread_schedule_hook)(struct TX_THREAD_STRUCT *thread_ptr, ULONG id);
/* Nothing after this point is referenced by the target-specific
assembly language. Hence, information after this point can
be added to the control block providing the complete system
is recompiled. */
/* Define the thread's entry point and input parameter. */
VOID (*tx_thread_entry)(ULONG id);
ULONG tx_thread_entry_parameter;
/* Define the thread's timer block. This is used for thread
sleep and timeout requests. */
TX_TIMER_INTERNAL tx_thread_timer;
/* Define the thread's cleanup function and associated data. This
is used to cleanup various data structures when a thread
suspension is lifted or terminated either by the user or
a timeout. */
VOID (*tx_thread_suspend_cleanup)(struct TX_THREAD_STRUCT *thread_ptr, ULONG suspension_sequence);
VOID *tx_thread_suspend_control_block;
struct TX_THREAD_STRUCT
*tx_thread_suspended_next,
*tx_thread_suspended_previous;
ULONG tx_thread_suspend_info;
VOID *tx_thread_additional_suspend_info;
UINT tx_thread_suspend_option;
UINT tx_thread_suspend_status;
/* Define the second port extension in the thread control block. This
is typically defined to whitespace or a pointer type in tx_port.h. */
TX_THREAD_EXTENSION_1
/* Define pointers to the next and previous threads in the
created list. */
struct TX_THREAD_STRUCT
*tx_thread_created_next,
*tx_thread_created_previous;
/* Define the third port extension in the thread control block. This
is typically defined to whitespace in tx_port.h. */
TX_THREAD_EXTENSION_2
/* Define a pointer type for FileX extensions. */
#ifndef TX_NO_FILEX_POINTER
VOID *tx_thread_filex_ptr;
#endif
/* Define the priority inheritance variables. These will be used
to manage priority inheritance changes applied to this thread
as a result of mutex get operations. */
UINT tx_thread_user_priority;
UINT tx_thread_user_preempt_threshold;
UINT tx_thread_inherit_priority;
/* Define the owned mutex count and list head pointer. */
UINT tx_thread_owned_mutex_count;
struct TX_MUTEX_STRUCT
*tx_thread_owned_mutex_list;
#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
/* Define the number of times this thread is resumed. */
ULONG tx_thread_performance_resume_count;
/* Define the number of times this thread suspends. */
ULONG tx_thread_performance_suspend_count;
/* Define the number of times this thread is preempted by calling
a ThreadX API service. */
ULONG tx_thread_performance_solicited_preemption_count;
/* Define the number of times this thread is preempted by an
ISR calling a ThreadX API service. */
ULONG tx_thread_performance_interrupt_preemption_count;
/* Define the number of priority inversions for this thread. */
ULONG tx_thread_performance_priority_inversion_count;
/* Define the last thread pointer to preempt this thread. */
struct TX_THREAD_STRUCT
*tx_thread_performance_last_preempting_thread;
/* Define the total number of times this thread was time-sliced. */
ULONG tx_thread_performance_time_slice_count;
/* Define the total number of times this thread relinquishes. */
ULONG tx_thread_performance_relinquish_count;
/* Define the total number of times this thread had a timeout. */
ULONG tx_thread_performance_timeout_count;
/* Define the total number of times this thread had suspension lifted
because of the tx_thread_wait_abort service. */
ULONG tx_thread_performance_wait_abort_count;
#endif
/* Define the highest stack pointer variable. */
VOID *tx_thread_stack_highest_ptr; /* Stack highest usage pointer */
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
/* Define the application callback routine used to notify the application when
the thread is entered or exits. */
VOID (*tx_thread_entry_exit_notify)(struct TX_THREAD_STRUCT *thread_ptr, UINT type);
#endif
/* Define the fourth port extension in the thread control block. This
is typically defined to whitespace in tx_port.h. */
TX_THREAD_EXTENSION_3
/* Define variables for supporting execution profile. */
/* Note that in ThreadX 5.x, user would define TX_ENABLE_EXECUTION_CHANGE_NOTIFY and use TX_THREAD_EXTENSION_3
to define the following two variables.
For Azure RTOS 6, user shall use TX_EXECUTION_PROFILE_ENABLE instead of TX_ENABLE_EXECUTION_CHANGE_NOTIFY,
and SHALL NOT add variables to TX_THREAD_EXTENSION_3. */
#if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY))
unsigned long long tx_thread_execution_time_total;
unsigned long long tx_thread_execution_time_last_start;
#endif
/* Define suspension sequence number. This is used to ensure suspension is still valid when
cleanup routine executes. */
ULONG tx_thread_suspension_sequence;
/* Define the user extension field. This typically is defined
to white space, but some ports of ThreadX may need to have
additional fields in the thread control block. This is
defined in the file tx_port.h. */
TX_THREAD_USER_EXTENSION
} TX_THREAD;
|