ThreadX 中文文档

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 73

ThreadXExpress Logic

ThreadX

ThreadX
ThreadX
ThreadX I/O
ThreadX
ThreadX
A ThreadX API
B ThreadX
C ThreadX
D Thread
E ASCII
ThreadX
ThreadX
C C
tx_port.h
ThreadX
UNIT
8 16 32

ULONG
32
VOID

CHAR
8
ThreadX tx_port.h

ThreadX

ThreadX
Picokernel
ANSI C

ThreadX

ThreadX
ThreadX ThreadX

RISCreduced instruction set computer


DSPDigital
Signal Processing
ThreadX ThreadX C
ThreadX
ThreadX 2Kbyte 15Kbyte
Picokernel
layering kernel functionsThreadX
Picokernel

ANSI C
ThreadX ANTI C
ThreadX

ThreadX C
ThreadX

ThreadX

ThreadX picokernel ThreadX

ThreadX

ThreadX

ThreadX task

ThreadX



ThreadX
ThreadX



ThreadX ID

IBM-PC UNIX

RS-232

BDM(Background Debug Monitor), ICEIn-Circuit EmulatorICE

ThreadX ASCII 1
readme.txt

ThreadX ROM (read-only memory) 2K 15K


RAM(random access memory) 1K 2K

ThreadX

ThreadX CD-ROM

ThreadX

Readme.txt
Tx_api.h
Tx_port.h
Demo.c
Build_ap.bat
Build_tx.bat
Tx.lib

ThreadX
C equates,
C
C
MS-DOS ThreadX
MS-DOS ThreadX C
ThreadX C

ThreadX
ThreadX
ThreadX
ThreadX
ThreadX
ThreadX,
Build_tx.bat ThreadX
ThreadX
ThreadX ThreadX tx.lib
tx_api.h
ThreadX
tx_api.h ThreadX
C main main tx_kernel_enter ThreadX
ThreadX

ThreadX tx_kernel_enter

tx_application_define

ThreadX

ThreadX tx.lib

2.1 3

#include "tx_api.h"
unsigned long my_thread_counter = 0;
TX_THREAD my_thread;
main( )
{
/* Enter the ThreadX kernel. */
tx_kernel_enter( );
}
void tx_application_define(void *first_unused_memory)

{
/* Create my_thread! */
tx_thread_create(&my_thread, "My Thread",
my_thread_entry, 0x1234, first_unused_memory, 1024,
3, 3, TX_NO_TIME_SLICE, TX_AUTO_START);
}
void my_thread_entry(ULONG thread_input)
{
/* Enter into a forever loop. */
while(1)
{
/* Increment thread counter. */
my_thread_counter++;
/* Sleep for 1 tick. */
tx_thread_sleep(1);
}
}

ThreadX

build_up.bat

1.
2.
3.

ThreadX bypass service call


error C TX_DISABLE_ERROR_CHECKING
30%

ThreadX API API


TX_DISABLE_ERROR_CHECKING

ThreadX

ThreadX

ISR

main
tx_kernel_enter

Round-Robin

TX_THREAD

Reentrancy

TX_QUEUE

TX_SEMAPHORE
Deadly Embrace

TX_EVENT_FLAG_GROUP
(Memory Block Pools)

TX_BLOCK_POOL

(Memory Byte Pools)

TX_BYTE_POOL

TX_TIMER

ThreadX
ISR

ThreadX
3.1

ThreadX

while()

ThreadX
ThreadX

ThreadX

ISR

ISR watchdog ISR

ThreadX ThreadX

3.2

ROM

RAM
ROM

RAM

ThreadX ISR

TX_THREAD

ThreadX

ThreadX

Main
main
ThreadX
tx_kernel_enter ThreadX

tx_kernel_enter
tx_kernel_enter
ThreadX
tx_application_define.
tx_application_define

tx_application_define

tx_application_define RAM

3.3

----------------------------------------------------------------------------------------------------------------------

ThreadX

tx_thread_create

ThreadX
3.4 ThreadX


ThreadX

tx_thread_terminate

ThreadX
0 310 31

ThreadX
FIFO
Round-Robin
ThreadX
tx_thread_relinquish tx_thread_relinquish

ThreadX

ThreadX

starvation

ThreadX

20 15 20
20 15
0 14


TX_THREAD
tx_api.h

tx_run_count

tx_state

TX_READY (0x00)
TX_COMPLETED (0x01)
TX_TERMINATED (0x02)
TX_SUSPENDED (0x03)
TX_SLEEP (0x04)
TX_QUEUE_SUSP (0x05)
TX_SEMAPHORE_SUSP (0x06)
TX_EVENT_FLAG (0x07)
TX_BLOCK_MEMORY (0x08)
TX_BYTE_MEMORY (0x09)
TX_IO_DRIVER (0x0A)

tx_thread_identify

Thread_X _tx_thread_current_ptr
NULL Thread_X

C
3.5

RAM

TX_MINIMUM_STACK, Thread_X

0xEFEF
3.6
0xEFEF

jumping into the weeds

Reentrancy
C
C

C strtok

Thread_X

thread_1, thread_2,
thread_3 thread_1
thread_2thread_3

thread_2 thread_1 thread_3 thread_2

tx_queue_send
ThreadX

_tx_thread_current_ptr,

ThreadX


ThreadX

tx_queue_send, tx_queue_receive

ThreadX

1248
16 32-bit
16

4 100
25
Queue Memory Area
ThreadX

RAM

(time-outs)

Block TX_QUEUE

tx_api.h

ThreadX 32 0 4,294,967,295
tx_semaphore_get tx_semaphore_put

ThreadX

Mutual Exclusion

1 0 1

-
0

TX_SEMAPHONE

tx_api.h

Deadly Embrace

3.7

32
32 tx_event_flags_set
tx_event_flags_get
/
/ tx_event_flags_set
get request

tx_event_flags_get

TX_OR_CLEAR TX_AND_CLEAR
0
ThreadX

TX_EVENT_FLAGS_GROUP

tx_api.h

ThreadX


ThreadX

ThreadX C
ThreadX

ThreadX

I/O
ThreadX

TX_BLOCK_POOL

tx_api.h

ThreadX C

malloc
first-fit

ThreadX ISR

ThreadX

TX_BYTE_POOL

tx_api.h

2000 1000
1000
1000

ThreadX C
(expire).one-shot timer,
periodic timer
ThreadX

ThreadX timer tick.


timer tick 10ms

ThreadX

tick tick
timer tick
tick
10ms 10ms 10ms
1ms

32
tx_api.h

tick

ThreadX 32 tick
tick
tx_time_get tx_time_set 32
tick ThreadX tick

tx_interrupt_control

ThreadX
ThreadX
ThreadX ISR
tx_block_allocate
tx_block_release
tx_event_flags_set
tx_event_flags_get
tx_interrupt_control
tx_queue_send
tx_queue_receive
tx_semaphore_get
tx_semaphore_put
tx_thread_identify
tx_thread_resume
tx_time_get
tx_time_set
tx_timer_activate
tx_timer_change

tx_timer_deactivate

ISR ISR
ISR
ISR ThreadX
readme.txt
ThreadX ISR

ISR

ISR ThreadX ISR

ThreadX

ThreadX

ThreadX
API
TX_DISABLE_ERROR_CHECKING API

tx_block_allocate

UINT tx_block_allocate(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG


wait_option)

pool_ptr

block_ptr

wait_option wait_option

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER
(0xFFFFFFFF)
timeout value
(0x00000001 through 0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER
timer-ticks 0 0xFFFFFFFE

TX_SUCCESS
TX_DELETED
TX_NO_MEMORY
TX_POOL_ERROR
TX_PTR_ERROR
TX_WAIT_ERROR

(0x00)

(0x01)
(0x10)
(0x02)
(0x03)

(0x04)

TX_NO_WAIT

Initialization, threads, timers, and ISRs

tx_block_pool_create

UINT tx_block_pool_create(TX_BLOCK_POOL *pool_ptr,


CHAR *name_ptr, ULONG block_size,
VOID *pool_start, ULONG pool_size)

=/+sizeof(*)
sizeof(*)

pool_ptr

name_ptr

block_size

pool_start

pool_size

TX_SUCCESS
(0x00)

TX_POOL_ERROR
(0x02)
NULL

TX_PTR_ERROR
(0x03)
TX_SIZE_ERROR
(0x05)

TX_CALLER_ERROR

Initialization and threads

(0x13)

tx_block_pool_delete

UINT tx_block_pool_delete(TX_BLOCK_POOL *pool_ptr)

TX_DELETED

pool_ptr

TX_SUCCESS
(0x00)
TX_POOL_ERROR
(0x02)
TX_CALLER_ERROR
(0x13)

Threads

tx_block_release

UINT tx_block_release(VOID *block_ptr)

block_ptr

TX_SUCCESS
(0x00)
TX_PTR_ERROR (0x03)

Initialization, threads, timers, and ISRs

tx_byte_allocate

UINT tx_byte_allocate(TX_BYTE_POOL *pool_ptr,


VOID **memory_ptr, ULONG memory_size,
ULONG wait_option)

pool_ptr

memory_ptr

memory_size

wait_option

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER
(0xFFFFFFFF)
timeout value
(0x00000001 through 0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER

timer-ticks
0 0xFFFFFFFE

TX_SUCCESS
(0x00)
TX_DELETED
(0x01)
TX_NO_MEMORY
(0x10)
TX_POOL_ERROR
(0x02)
TX_PTR_ERROR
(0x03)
TX_WAIT_ERROR
(0x04)
TX_NO_WAIT
TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_byte_pool_create

UINT tx_byte_pool_create(TX_BYTE_POOL *pool_ptr,


CHAR *name_ptr, VOID *pool_start,
ULONG pool_size)

pool_ptr

name_ptr
pool_start
pool_size

TX_SUCCESS
(0x00)

TX_POOL_ERROR

NULL

(0x03)
(0x05)
(0x13)

(0x02)

TX_PTR_ERROR
TX_SIZE_ERROR
TX_CALLER_ERROR

Initialization and threads

tx_byte_pool_delete

UINT tx_byte_pool_delete(TX_BYTE_POOL *pool_ptr)

TX_DELETED

pool_ptr

TX_SUCCESS
(0x00)
TX_POOL_ERROR
(0x02)
TX_CALLER_ERROR
(0x13)

Threads

tx_byte_release

UINT tx_byte_release(VOID *memory_ptr)

memory_ptr

TX_SUCCESS
(0x00)
TX_PTR_ERROR
(0x03)
TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_event_flags_create

UINT tx_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr,


CHAR *name_ptr)

32 0

group_ptr
name_ptr

TX_SUCCESS
TX_GROUP_ERROR
TX_CALLER_ERROR

(0x00)
(0x06) NULL

(0x13)

Initialization and threads

tx_event_flags_delete

UINT tx_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr)

TX_DELETED

group_ptr

TX_SUCCESS
(0x00)
TX_GROUP_ERROR
(0x06)
TX_CALLER_ERROR (0x13)

Threads

tx_event_flags_get

UINT tx_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr,


ULONG requested_flags, UINT get_option,
ULONG *actual_flags_ptr, ULONG wait_option)


32

group_ptr

requested_flags 32
get_option

TX_AND
(0x02)
TX_AND_CLEAR (0x03)
TX_OR
(0x00)
TX_OR_CLEAR
(0x01)
TX_ANDTX_AND_CLEAR
TX_ORTX_OR_CLEAR
TX_AND_CLEARTX_OR_CLEAR
0
actual_flags_ptr

wait_option

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER (0xFFFFFFFF)
timeout value
(0x00000001 through 0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER

timer-ticks
0 0xFFFFFFFE

TX_SUCCESS
(0x00)

TX_DELETED
(0x01)

TX_NO_EVENTS
(0x07)

TX_GROUP_ERROR
(0x06)

TX_PTR_ERROR
(0x03)

TX_WAIT_ERROR
(0x04)

TX_NO_WAIT
TX_OPTION_ERROR (0x08)
get_option
TX_CALLER_ERROR
(0x13)

Initialization, threads, and ISRs

tx_event_flags_set


UINT tx_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr,
ULONG flags_to_setUINT set_option)

group_ptr
flags_to_set set_option
set_option AND
OR
TX_AND
(0x02)
TX_OR
(0x00)
TX_ANDAND
TX_AND
TX_OROR

TX_SUCCESS
(0x00)

TX_GROUP_ERROR
(0x06)

TX_OPTION_ERROR (0x08) set_option

Initialization, threads, timers, and ISRs

tx_interrupt_control

UINT tx_interrupt_control(UINT new_posture)

new_posture

new_posture
TX_INT_DISABLE
TX_INT_ENABLE
readme.txt

previous posture

Threads, timers, and ISRs

tx_queue_create

UINT tx_queue_create(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT


message_size, VOID *queue_start, ULONG queue_size)

queue_ptr

name_ptr

message_size
321632

TX_1_ULONG
(0x01)
TX_2_ULONG
(0x02)
TX_4_ULONG
(0x04)
TX_8_ULONG
(0x08)
TX_16_ULONG
(0x10)
queue_start

queue_size

TX_SUCCESS
(0x00)
TX_QUEUE_ERROR
(0x09) NULL

TX_PTR_ERROR
(0x03)
TX_SIZE_ERROR
(0x05)
TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_queue_delete

UINT tx_queue_delete(TX_QUEUE *queue_ptr)

TX_DELETED

queue_ptr

TX_SUCCESS
(0x00) .
TX_QUEUE_ERROR
(0x09)
TX_CALLER_ERROR
(0x13)

Threads

tx_queue_flush

UINT tx_queue_flush(TX_QUEUE *queue_ptr)

queue_ptr

TX_SUCCESS
(0x00) .
TX_QUEUE_ERROR
(0x09)
TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_queue_receive

UINT tx_queue_receive(TX_QUEUE *queue_ptr,


VOID *destination_ptr, ULONG wait_option)

queue_ptr

destination_ptr

wait_option

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER (0xFFFFFFFF)
timeout value
(0x00000001 through
0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER

timer-ticks 0

0xFFFFFFFE

TX_SUCCESS
TX_DELETED
TX_QUEUE_EMPTY
TX_QUEUE_ERROR
TX_PTR_ERROR
TX_WAIT_ERROR

(0x00)
(0x01)
(0x0A)
(0x09)
(0x03)
(0x04)

TX_NO_WAIT

Initialization, threads, timers, and ISRs

tx_queue_send

UINT tx_queue_send(TX_QUEUE *queue_ptr,


VOID *source_ptr, ULONG wait_option)

queue_ptr

source_ptr

wait_option

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER (0xFFFFFFFF)
timeout value
(0x00000001 through
0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER
timer-ticks
0 0xFFFFFFFE

TX_SUCCESS
(0x00)

TX_DELETED
(0x01)
TX_QUEUE_FULL
(0x0A)
TX_QUEUE_ERROR
(0x09)
TX_PTR_ERROR
(0x03)
TX_WAIT_ERROR
(0x04) TX_NO_WAIT

Initialization, threads, timers, and ISRs

tx_semaphore_create

UINT tx_semaphore_create(TX_SEMAPHORE *semaphore_ptr,


CHAR *name_ptr, ULONG initial_count)

semaphore_ptr

name_ptr

initial_count
0x00000000 0xFFFFFFFF

TX_SUCCESS
(0x00) .
TX_SEMAPHORE_ERROR (0x0C) NULL

TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_semaphore_delete

UINT tx_semaphore_delete(TX_SEMAPHORE *semaphore_ptr)

TX_DELETED

semaphore_ptr
.

TX_SUCCESS
(0x00)
TX_SEMAPHORE_ERROR
(0x0C)
TX_CALLER_ERROR
(0x13)

Threads

tx_semaphore_get

UINT tx_semaphore_get(TX_SEMAPHORE *semaphore_ptr,


ULONG wait_option)

semaphore_ptr
wait_option
0

TX_NO_WAIT
(0x00000000)
TX_WAIT_FOREVER (0xFFFFFFFF)
timeout value
(0x00000001 through
0xFFFFFFFE)
TX_NO_WAIT
ISR
TX_WAIT_FOREVER

timer-ticks
0 0xFFFFFFFE

TX_SUCCESS
(0x00)
TX_DELETED
(0x01)
TX_NO_INSTANCE
(0x0D) 0
TX_SEMAPHORE_ERROR (0x0C)
TX_WAIT_ERROR
(0x04) TX_NO_WAIT

Initialization, threads, timers, and ISRs

tx_semaphore_put

UINT tx_semaphore_put(TX_SEMAPHORE *semaphore_ptr)

1 0xFFFFFFFF
0

semaphore_ptr

TX_SUCCESS
(0x00)
TX_SEMAPHORE_ERROR (0x0C)

Initialization, threads, timers, and ISRs

tx_thread_create

UINT tx_thread_create(TX_THREAD *thread_ptr,


CHAR *name_ptr, VOID (*entry_function)(ULONG),
ULONG entry_input, VOID *stack_start,
ULONG stack_size, UINT priority,
UINT preempt_threshold, ULONG time_slice,
UINT auto_start)

thread_ptr

name_ptr

entry_function
C
completed state,

entry_input
32

stack_start

stack_size

priority
0310
preempt_threshold

time_slice

timer-ticks

10xffffffffTX_NO_TIME_SLICE (0)

auto_start

TX_AUTO_START (0x01) TX_DONT_START (0x00)

TX_SUCCESS
(0x00)

TX_THREAD_ERROR
(0x0E) NULL

TX_PTR_ERROR
(0x03)
NULL
TX_SIZE_ERROR
(0x05)

TX_MINIMUM_STACK
TX_PRIORITY_ERROR (0x0F)
0~31
TX_THRESH_ERROR
(0x18)

TX_START_ERROR
TX_CALLER_ERROR

Initialization and threads

(0x10) auto_start
(0x13)

tx_thread_delete
`
UINT tx_thread_delete(TX_THREAD *thread_ptr)

thread_ptr

TX_SUCCESS
(0x00)
TX_THREAD_ERROR
(0x0E)
TX_DELETE_ERROR
(0x11)

TX_CALLER_ERROR
(0x13)

Threads and timers

tx_thread_identify

TX_THREAD* tx_thread_identify(VOID)

None

thread pointer

TX_NULL

Threads and ISRs

tx_thread_preemption_change

UINT tx_thread_preemption_change(TX_THREAD *thread_ptr,

UINT new_threshold, UINT *old_threshold)

thread_ptr

new_threshold 0~31
old_threshold

TX_SUCCESS
(0x00)

TX_THREAD_ERROR (0x0E)
TX_THRESH_ERROR
(0x18)
0~31

TX_PTR_ERROR
(0x03)
TX_CALLER_ERROR
(0x13)

Threads and timers

tx_thread_priority_change

UINT tx_thread_priority_change(TX_THREAD *thread_ptr,


UINT new_priority, UINT *old_priority)

tx_thread_preemption_change

thread_ptr

new_priority (0-31).
old_priority

TX_SUCCESS
(0x00)
TX_THREAD_ERROR (0x0E)
TX_PRIORITY_ERROR (0x0F) (0-31)
TX_PTR_ERROR
(0x03)
TX_CALLER_ERROR
(0x13)

Threads and timers

tx_thread_relinquish

VOID tx_thread_relinquish(VOID)

VOID

VOID

Only the executing thread

tx_thread_resume

UINT tx_thread_resume(TX_THREAD *thread_ptr)

tx_thread_suspend
threads that created without an automatic start

thread_ptr

TX_SUCCESS
(0x00)
TX_SUSPEND_LIFTED (0x19)
previously set
delayed suspension was lifted
TX_THREAD_ERROR
(0x0E)
TX_RESUME_ERROR
(0x12)
tx_thread_suspend

Initialization, threads, timers, and ISRs

tx_thread_sleep

UINT tx_thread_sleep(ULONG timer_ticks)

timer ticks

timer_ticks

timer ticks00xFFFFFFFF
0

TX_SUCCESS
(0x00)
TX_CALLER_ERROR
(0x13)

Currently executing thread

tx_thread_suspend

UINT tx_thread_suspend(TX_THREAD *thread_ptr)

tx_thread_resume

thread_ptr

TX_SUCCESS
(0x00)
TX_THREAD_ERROR (0x0E)
TX_SUSPEND_ERROR (0x14)
TX_CALLER_ERROR
(0x13)
Allowed From
Threads and timers

tx_thread_terminate

UINT tx_thread_terminate(TX_THREAD *thread_ptr)

thread_ptr

TX_SUCCESS
(0x00)
TX_THREAD_ERROR (0x0E)
TX_CALLER_ERROR (0x13)

Threads and timers

tx_thread_time_slice_change

UINT tx_thread_time_slice_change(TX_THREAD *thread_ptr,


ULONG new_time_slice, ULONG *old_time_slice)

thread_ptr

new_time_slice TX_NO_TIME_SLICE 1
0xFFFFFFFF.
old_time_slice

TX_SUCCESS
(0x00)

TX_THREAD_ERROR (0x0E)
TX_PTR_ERROR
(0x03)

TX_CALLER_ERROR
(0x13)

Threads and timers

tx_time_get

ULONG tx_time_get(VOID)

timer_tick
0 tx_time_set

None

system clock ticks

Threads, timers, and ISRs

tx_time_set

VOID tx_time_set(ULONG new_time)

timer_tick

new_time
00xFFFFFFFF


None

Threads, timers, and ISRs

tx_timer_activate

UINT tx_timer_activate(TX_TIMER *timer_ptr)

timer_ptr

TX_SUCCESS
(0x00)
TX_TIMER_ERROR
(0x15)
TX_ACTIVATE_ERROR (0x17)

Initialization, threads, timers, and ISRs

tx_timer_change

UINT tx_timer_change(TX_TIMER *timer_ptr,


ULONG initial_ticks, ULONG reschedule_ticks)

tx_timer_activate

timer_ptr

initial_ticks

10xFFFFFFFF
reschedule_ticks
ticks,0
1
0xFFFFFFFF

TX_SUCCESS
(0x00)

TX_TIMER_ERROR
(0x15)

TX_TICK_ERROR
(0x16)
0
TX_CALLER_ERROR (0x13)

Threads, timers, and ISRs

tx_timer_create

UINT tx_timer_create(TX_TIMER *timer_ptr, CHAR *name_ptr,


VOID (*expiration_function)(ULONG),
ULONG expiration_input, ULONG initial_ticks,
ULONG reschedule_ticks, UINT auto_activate)

timer_ptr

name_ptr

expiration_function

expiration_input
expiration function
initial_ticks
10xFFFFFFFF
reschedule_ticks
0
1
0xFFFFFFFF
auto_activate

TX_AUTO_ACTIVATE (0x01)
TX_NO_ACTIVATE(0x00)
tx_timer_activate

TX_SUCCESS
(0x00)

TX_TIMER_ERROR
(0x15)

TX_TICK_ERROR
(0x16)
0
TX_ACTIVATE_ERROR (0x17)

TX_CALLER_ERROR
(0x13)

Initialization and threads

tx_timer_deactivate

UINT tx_timer_deactivate(TX_TIMER *timer_ptr)

timer_ptr

TX_SUCCESS
(0x00)
TX_TIMER_ERROR (0x15)


Initialization, threads, timers, and ISRs

tx_timer_delete

UINT tx_timer_delete(TX_TIMER *timer_ptr)

timer_ptr

TX_SUCCESS
(0x00)

TX_TIMER_ERROR
(0x15)

TX_CALLER_ERROR (0x13)

Threads

ThreadX I/O

ThreadX I/O
I/O


I/O

I/O
TX_IO_BUFFER
I/O

I/O

I/O
I/O ????????

ThreadX I/O

ThreadX I/O
Driver Initialization
Driver Control
Driver Access
Driver Input
Driver Output
Driver Interrupts
Driver Status
Driver Termination
I/O

tx_application_define

I/O
I/O
/

Current device status


Input bytes
Output bytes
I/O error counts

/
s

tx_sdriver_initialize
ISR
0
1

low-level interrupt vector handlers


ThreadX ISR
ISR _tx_thread_context_save ISR
_tx_thread_context_restore

?
?
?

ISR the transmit complete interrupt. ISR

tx_sdriver_output

ThreadX I/O
ThreadX

I/O
ISR
I/O

I/O,DMA,

I/O

UART

characters that arrive before the application is ready for


them ISR

??????

I/O
I/O

I/O

TX_IO_BUFFER
Typedef TX_IO_BUFFER tx_next_packet
tx_next_buffer
NULL
field

I/O
I/O
I/O
full condition

ThreadX

ThreadX pdf

ThreadX

ThreadX
System Include File
ThreadX (include file)tx_api.h tx_port.htx_api.h

tx_port.h tx_api.h /
interrupt management macros, ThreadX C

tx_port.h ThreadX ASCII _tx_version_id


ThreadX API tx_api.h

ThreadX 8 internal
component,

ThreadX tx_kernel_enter
_tx_initialize_kernel_enter

C
ThreadX

ThreadX tx_application_define
tx_application_define C

tx_application_define

Software Components
Express Logic C++
(action functions)
the internal data of the component
global datathread component

ThreadX
ThreadX specification include file
ThreadX
component files
Express Logic
more than one function per-file
ThreadX
ThreadX 8
ThreadX
Initialize
Thread
Timer
Queue
Semaphore
Event Flags
Block Memory
Byte Memory

ThreadX C
external and internal component
function prototypes

C
instantiation

If
none of the components services are used by the application, only the components small initialization
function is included in the applications run-time image.

ThreadX

ThreadX

ThreadX
ThreadX C
TX_c[x].C
c [x]
tx_tc.c _tx_thread_create tx_ike.c
_tx_initialize_kernek_enter

TX_ccc.H
ccc tx_tim.h
ThreadX
ThreadX
ThreadX _tx ThreadX

ANSI ThreadX 31

ThreadX
ThreadX
TX_NAME TX_C_NAME
ThreadX tx_api.h tx_port.h

TX_NAME
TX_SUCCESS

TX_C_NAME
C TX_INITIALIZE_IN_PROGRESS
tx_ini.h
ThreadX Typedef
ThreadX C typedef
typedef :
TX_C_NAME

C typedef TX_QUEUE
ThreadX
typedef tx_api.h
UINT
ULONG
VOID TX_ ThreadX
tx_port.h
ThreadX
ThreadX
tx_c_name
c typedef
TX_THREAD

tx_thread_id
ThreadX
ThreadX C a small amount of global C data
elements_tx_c_name ThreadX
c
_tx_thread_current_ptr, tx_thr.h
ThreadX
ThreadX C

ThreadX
ThreadX
_tx_c_name
ThreadX c
_tx_thread_create

ThreadX

ThreadX C
7.1 tx_tc.c

/**************************************************************************/
/**

*/

/** ThreadX Component

*/

/**

*/

/**

Thread Control (THR)

*/

/**

*/

/**************************************************************************/
/**************************************************************************/
/*

*/

/* FUNCTION
/*
/*

RELEASE

*/
*/

_tx_thread_create

/*

PORTABLE C */
3.0 */

/* AUTHOR

*/

/*

*/

/*
/*

William E. Lamie, Express Logic, Inc.

*/
*/

/* DESCRIPTION

*/

/*

*/

/*

This function creates a thread and places it on the list of created */

/*

threads.

*/

/*

*/

/* INPUT

*/

/*

*/

/*

thread_ptr

Thread control block pointer */

/*

name

Pointer to thread name string */

/*

entry_function

Entry function of the thread */

/*

entry_input

32-bit input value to thread */

/*

stack_start

Pointer to start of stack */

/*

stack_size

/*

priority

/*

preempt_threshold

Preemption threshold

/*

time_slice

Thread time-slice value */

/*

auto_start

Stack size in bytes */


Priority of thread (0-31) */

Automatic start selection */

/*

*/

/* OUTPUT

*/

/*
/*

*/

*/
return status

Thread create return status

*/

/*

*/

/* CALLS

*/

/*

*/

/*

_tx_thread_stack_build

/*

_tx_thread_resume

/*

_tx_thread_system_return

Build initial thread stack */


Resume automatic start thread */
Return to system on preemption*/

/*

*/

/* CALLED BY

*/

/*

*/

/*

Application Code

*/

/*

_tx_timer_initialize

Create system timer thread */

/*

*/

/* RELEASE HISTORY

*/

/*
/*

*/
DATE

NAME

DESCRIPTION

William E. Lamie

Initial Version 3.0

/*
/* 12-31-1996

*/
*/

/*

*/
*/

/**************************************************************************/
Figure 7.1 ThreadX

ThreadX
ThreadX tx_application_define

TX_INI.H
ThreadX

_tx_initialize_unused_memory
ThreadX
tx_application_define

TX_IHL.C
_tx_initialize_high_levelThreadX
tx_application_define
TX_IKE.C
_tx_initialize_kernel_enterThreadX
tx_kernel_enter
TX_ILL.[S,ASM]
_tx_initialize_low_level,

ThreadX

TX_THR.H
ThreadX

_tx_thread_system_stack_ptr
ThreadX

_tx_thread_current_ptr
TX_THREAD
NULL,

_tx_thread_execute_ptr
TX_THREAD

_tx_thread_created_ptr
TX_THREAD

_tx_thread_created_count
ULONG
_tx_thread_system_state
ULONG
ThreadX
_tx_thread_preempted_map
ULONG32

_tx_thread_priority_map
ULONG32

_tx_thread_highest_priority
UINT
_tx_thread_lowest_bit
UCHAR
_tx_thread_priority_map

_tx_thread_priority_list
TX_THREAD
NULL

_tx_thread_preempt_disable
UINTThreadX(an
internal mechanism for ThreadX services to enter into internal
critical section processing)ThreadX

_tx_thread_special_string
CHAR,ThreadX
TX_TC.C
_tx_thread_create
TX_TCR.[S,ASM]
_tx_thread_context_restore,ISR

TX_TCS.[S,ASM]
_tx_thread_context_saveISR

TX_TDEL.C
_tx_thread_delete,
TX_TI.C
_tx_thread_initialize,
TX_TIC.[S,ASM]
_tx_thread_interrupt_control,
TX_TIDE.C
_tx_thread_identify,_tx_thread_current_ptr
TX_TPC.[S,ASM]
_tx_thread_preempt_check,

TX_TPCH.C
_tx_thread_preemption_change,
TX_TPRCH.C
_tx_thread_priority_change,
TX_TR.C
_tx_thread_resume,ThreadX
TX_TRA.C
_tx_thread_resume_api,
TX_TREL.C
_tx_thread_relinquish,

TX_TS.[S,ASM]
_tx_thread_schedule,
the last context of the highest-priority thread ready for execution
TX_TSA.C

_tx_thread_suspend_api,
TX_TSB.[S,ASM]
_tx_thread_stack_build,
an interrupt context_tx_thread_shell_entry
_tx_thread_stack_build

TX_TSE.C
_tx_thread_shell_entry,
_tx_thread_shell_entry
TX_TSLE.C
_tx_thread_sleep,
TX_TSR.[S,ASM]
_tx_thread_system_return,ThreadX

TX_TSUS.C
_tx_thread_suspend,ThreadX

TX_TT.C
_tx_thread_terminate,
TX_TTO.C
_tx_thread_timeout,
TX_TTS.C
_tx_thread_time_slice,
TX_TTSC.C
_tx_thread_time_slice_change,
TXE_TC.C
_txe_thread_create,
TXE_TDEL.C
_txe_thread_delete,
TXE_TPCH.C
_txe_thread_preemption_change,

TXE_TRA.C
_txe_thread_resume_api,
TXE_TREL.C
_txe_thread_relinquish,checking thread relinquish
requests for error

TXE_TRPC.C
_txe_thread_priority_change,
TXE_TSA.C
_txe_thread_suspend_api,
TXE_TT.C
_txe_thread_terminate,
TXE_TTSC.C
_txe_thread_time_slice_change,

timer component
API

TX_TIM.H
ThreadX

_tx_timer_system_clock
ULONGtick
_tx_timer_time_slice
ULONG0
_tx_timer_expired_time_slice
UINT
ISR
_tx_timer_list

expiration list
_tx_timer_list_start
TX_INTERNAL_TIMER
a wrap condition_tx_timer_current_ptr
_tx_timer_list
_tx_timer_list_end
TX_INTERNAL_TIMER_tx_timer_list
_tx_timer_current_ptr_tx_timer_list

_tx_timer_current_ptr
TX_INTERNAL_TIMER_tx_timer_list

_tx_timer_expired
UINTISR
the timer system thread

_tx_timer_thread
TX_THREAD

_tx_timer_stack_start
VOID

_tx_timer_stack_size
ULONG

_tx_timer_priority
UINT0

_tx_timer_created_ptr
TX_TIMER

_tx_timer_created_count
ULONG
TX_TA.C
_tx_timer_activate,

TX_TAA.C
_tx_timer_activate_api,
TX_TD.C
_tx_timer_deactivate,deactivate


TX_TDA.C
_tx_timer_deactivate_api,
TX_TIMCH.C
_tx_timer_change,
TX_TIMCR.C
_tx_timer_create,

TX_TIMD.C
_tx_timer_delete,
TX_TIMEG.C
_tx_time_get, _tx_timer_system_clock
TX_TIMES.C
_tx_time_set,_tx_timer_system_clock
TX_TIMI.C
_tx_timer_initialize,
TX_TIMIN.[S,ASM]
_tx_timer_interrupt,

TX_TTE.C
_tx_timer_thread_entry,
TXE_TAA.C
_txe_timer_activate_api,
TXE_TMCH.C
_txe_timer_change,
TXE_TMCR.C
_txe_timer_create,
_TDA.C
_txe_timer_deactivate_api,
TXE_TIMD.C

_txe_timer_delete,

TX_QUE.H
ThreadX

_tx_queue_created_ptr
TX_QUEUE

_tx_queue_created_count
ULONG
TX_QC.C
_tx_queue_create,

TX_QCLE.C
_tx_queue_cleanup,processing
queue suspension time-outs and queue-suspended thread termination

TX_QD.C
_tx_queue_delete,
TX_QF.C
_tx_queue_flush,flush
TX_QI.C
_tx_queue_initialize,
TX_QR.C
_tx_queue_receive,
TX_QS.C

_tx_queue_send,
TXE_QC.C
_txe_queue_create,
TXE_QD.C
_txe_queue_delete,
TXE_QF.C
_txe_queue_flush,flush
TXE_QR.C
_txe_queue_receive,
TXE_QS.C
_txe_queue_send,

semaphore
gets and semaphore puts

TX_SEM.H
ThreadX

:
_tx_semaphore_created_ptr
TX_SEMAPHORE

_tx_semaphore_created_count
ULONG
TX_SC.C
_tx_semaphore_create,
TX_SCLE.C
_tx_semaphore_cleanup,
processing semaphore suspension time-outs and semaphore-suspended thread
termination

TX_SD.C
_tx_semaphore_delete,
TX_SG.C
_tx_semaphore_get,
TX_SI.C
_tx_semaphore_initialize,
TX_SP.C
_tx_semaphore_put,semaphore put requests
TXE_SC.C
_txe_semaphore_create,
TXE_SD.C
_txe_semaphore_delete,
TXE_SG.C
_txe_semaphore_get,

TXE_SP.C
_txe_semaphore_put,

TX_EVE.H
ThreadX

:
_tx_event_flags_created_ptr
TX_EVENT_FLAGS_GROUP

_tx_semaphore_created_count

ULONG

TX_EFC.C
_tx_event_flags_create,
TX_EFCLE.C
_tx_event_flags_cleanup,

TX_EFD.C
_tx_event_flags_delete,

TX_EFG.C
_tx_event_flags_get,
TX_EFI.C
_tx_event_flags_initialize,
TX_EFS.C
_tx_event_flags_set,
TXE_EFC.C
_txe_event_flags_create,
TXE_EFD.C
_txe_event_flags_delete,
TXE_EFG.C
_txe_event_flags_get,
TXE_EFS.C
_txe_event_flags_set,

TX_BLO.H
ThreadX

:
_tx_block_pool_created_ptr
TX_BLOCK_POOL

_tx_block_pool_created_count
ULONG
TX_BA.C
_tx_block_allocate,
TX_BPC.C
_tx_block_pool_create,
TX_BPCLE.C
_tx_block_pool_cleanup,

TX_BPD.C
_tx_block_pool_delete,
TX_BPI.C
_tx_block_pool_initialize,
TX_BR.C
_tx_block_release,
TXE_BA.C
_txe_block_allocate,
TXE_BPC.C
_txe_block_pool_create,

TXE_BPD.C
_txe_block_pool_delete,
TXE_BR.C
_txe_block_release,

TX_BYT.H
ThreadX

:
_tx_byte_pool_created_ptr
TX_BYTE_POOL

_tx_byte_pool_created_count
ULONG
TX_BYTA.C
_tx_byte_allocate,
TX_BYTC.C
_tx_byte_pool_create,
TX_BYTCL.C
_tx_byte_pool_cleanup,

TX_BYTD.C
_tx_byte_pool_delete,

TX_BYTI.C
_tx_byte_pool_initialize,

TX_BYTR.C
_tx_byte_release,
TX_BYTS.C
_tx_byte_pool_search,

TXE_BYTA.C
_txe_byte_allocate,
TXE_BYTC.C
_txe_byte_pool_create,

TXE_BYTD.C
_txe_byte_pool_delete,
TXE_BYTR.C
_txe_byte_release,

You might also like