ThreadX-presentation TN
ThreadX-presentation TN
ThreadX-presentation TN
Contents
03/31/16
Picokernel Architecture
ANSI C source code
Not a black box
A potential stantard
03/31/16
03/31/16
03/31/16
03/31/16
03/31/16
Embedded Applications
Real-time software
Multitasking
Tasks and Threads
03/31/16
Embedded Applications
Real-time software
interaction with the external world
Multitasking
the allocation of the processor between
the various application tasks
the primary purpose of ThreadX
03/31/16
Embedded Applications
Tasks and Threads
Task
sometimes means a separately loadable
program
In other instances, it might refer to an internal
program segment
Thread
A semi-independent program segment that
executes within a process
Share the same process address space.
The overhead associated with thread
management is minimal
03/31/16
10
ThreadX benefits
Improved responsiveness
Software maintenance
Increased throughput
Processor isolation
Dividing the application
Easy to use
Improve time-to-market
Protecting the software investment
03/31/16
11
ThreadX benefits
Improved responsiveness
preemptive, priority-based scheduling
algorithm
Software maintenance
Enables developers to concentrate on
specific requirements of their application
threads without having to worry about
changing the timing of other areas of
the application
03/31/16
12
ThreadX benefits
Increased throughput
multi-threading actually reduces
overhead by eliminating all of the
redundant polling
Processor isolation
robust processor-independent interface
between the application and the
underlying processor
03/31/16
13
ThreadX benefits
Dividing the application
Application is divided into clearly
defined threads
Ease of use
ThreadX architecture and service call
interface are designed to be easily
understood
03/31/16
14
ThreadX benefits
Improve time-to-market
ThreadX takes care of most processor
issues
03/31/16
15
Functional Components of
ThreadX
Execution overview
Initialization
Thread Execution
Application timers
Memory usage
Interrupts
03/31/16
16
Execution overview
Hardware Reset
Initializati
on
Thread
Executio
n
ISR
03/31/16
Applicatio
n timers
17
Initialization
int main() {
/* Enter the ThreadX kernel.
*/
tx_kernel_enter();
}
Main()
tx_kernel_enter()
tx_application_define(mem
_ptr)
Enter thread Scheduling loop
03/31/16
tx_thread_crea
te
tx_mutex_crea
te
18
Thread Execution
Tx_thread_create
TX_DONT_START
TX_AUTO_START
Ready
State
Thread
scheduling
Suspend
ed State
Executin
g State
Comple
ted
State
03/31/16
Terminate
d State
19
Thread priorities
0
Highest
31
Lowest
03/31/16
20
Thread Scheduling
If multiple threads of the same priority :
FIFO
Time-slicing
21
Thread Scheduling
Preemption causing :
- starvation
- excessive context switching
overhead
- priority inversion.
03/31/16
22
Thread Scheduling
Preemption-threshold
What is a
preempti
onthreshold
?
Example
?
Higher
priorities
03/31/16
>
>
The ceiling
Lower
priorities
23
Application timers
applications with the ability to
execute application C functions at
specific intervals of timers.
Using timer interrupt (timer ticks)
10ms .
How to generate periodic interrupts ?
peripheral
Underlying
hardware
03/31/16
device
interrupts.
24
Memory Usage
Adresses
0x00000000
Instruction Area
ROM
Constant Area
ROM
0x80000000
Initialized Data
Area
RAM
Uninitialized Data
Area
RAM
Static
memory
usage
System Stack
Area
03/31/16
25
Memory Usage
Dynamic
memory
usage
03/31/16
Control blocks
and memory areas
associated with stacks,
queues,
and memory pools
it facilitates easy
utilization of different
types
of physical memory
26
Memory pitfalls
03/31/16
27
Another componnents
Interrupt
Memory
Block
Pools
Event
Flags
03/31/16
Message
Queues
Semaphor
es
Mutexes
28
Q&A
03/31/16
29