git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@666 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-01-22 15:37:29 +00:00
parent b094fe9dc1
commit bae98eb8d8
17 changed files with 102 additions and 78 deletions

View File

@ -3,21 +3,21 @@
* @{
* Response time jitter is one of the most sneaky source of problems when
* designing a real time system. When using a RTOS like ChibiOS/RT one must
* be aware of what Jitter is and how it can affect the performance of the
* be aware of what the jitter is and how it can affect the performance of the
* system.<br>
* A good place to start is this
* <a href="http://en.wikipedia.org/wiki/Jitter">Wikipedia article</a>.
*
* <h2>Jitter Sources</h2>
* Under ChibiOS/RT (or any other similar RTOS) there are several jitter
* possible sources:
* Under ChibiOS/RT (or any other similar RTOS) there are several possible
* jitter sources:
* -# Hardware interrupts latency.
* -# Interrupts service time and priority.
* -# Kernel lock zones.
* -# Higher priority threads activity.
*
* <h2>Jitter mitigation countermeasures</h2>
* For each of the previously described jitter source there are possible
* For each of the previously described jitter sources there are possible
* mitigation actions.
*
* <h3>Hardware interrupts latency</h3>
@ -49,13 +49,14 @@
* As example, in the ARM port, FIQ sources are not affected by the
* kernel-generated jitter. The Cortex-M3 port is even better thanks to its
* hardware-assisted interrupt architecture allowing handlers preemption,
* late switch, tail chaining etc. See the notes about the various @ref Ports.
* late arriving, tail chaining etc. See the notes about the various
* @ref Ports.
*
* <h3>Kernel lock zones</h3>
* The OS kernel protects some critical internal data structure by disabling
* (fully in simple architecture, to some extent in more advanced
* microcontrollers) the interrupt sources. Because of this the kernel itself
* is a jitter source, a good OS design minimizes the jitter generated by the
* is a jitter cause, a good OS design minimizes the jitter generated by the
* kernel by both using adequate data structure, algorithms and good coding
* practices.<br>
* A good OS design is not the whole story, some OS primitives may generate
@ -72,6 +73,6 @@
* by carefully assigning priorities to the various threads and carefully
* designing mutual exclusion zones.<br>
* The use of the proper synchronization mechanism (semaphores, mutexes, events,
* messages and so on) also helps to improve the system performance.
* messages and so on) also helps to improve the overall system performance.
*/
/** @} */

View File

@ -197,7 +197,10 @@ struct context {
* Disables the IRQ sources and keeps the FIQ sources enabled.
*/
#ifdef THUMB
#define port_lock() _port_lock_thumb()
//#define port_lock() _port_lock_thumb()
#define port_lock() { \
asm volatile ("bl _port_lock_thumb" : : : "r3", "lr"); \
}
#else /* THUMB */
#define port_lock() asm volatile ("msr CPSR_c, #0x9F")
#endif /* !THUMB */
@ -206,7 +209,10 @@ struct context {
* Enables both the IRQ and FIQ sources.
*/
#ifdef THUMB
#define port_unlock() _port_unlock_thumb()
//#define port_unlock() _port_unlock_thumb()
#define port_unlock() { \
asm volatile ("bl _port_unlock_thumb" : : : "r3", "lr"); \
}
#else /* THUMB */
#define port_unlock() asm volatile ("msr CPSR_c, #0x1F")
#endif /* !THUMB */
@ -227,7 +233,10 @@ struct context {
* LPC214x datasheet.
*/
#ifdef THUMB
#define port_disable() _port_disable_thumb()
//#define port_disable() _port_disable_thumb()
#define port_disable() { \
asm volatile ("bl _port_disable_thumb" : : : "r3", "lr"); \
}
#else /* THUMB */
#define port_disable() { \
asm volatile ("mrs r3, CPSR \n\t" \
@ -242,7 +251,9 @@ struct context {
* Disables the IRQ sources and enables the FIQ sources.
*/
#ifdef THUMB
#define port_suspend() _port_suspend_thumb()
#define port_suspend() { \
asm volatile ("bl _port_suspend_thumb" : : : "r3", "lr"); \
}
#else /* THUMB */
#define port_suspend() asm volatile ("msr CPSR_c, #0x9F")
#endif /* !THUMB */
@ -251,7 +262,9 @@ struct context {
* Enables both the IRQ and FIQ sources.
*/
#ifdef THUMB
#define port_enable() _port_enable_thumb()
#define port_enable() { \
asm volatile ("bl _port_enable_thumb" : : : "r3", "lr"); \
}
#else /* THUMB */
#define port_enable() asm volatile ("msr CPSR_c, #0x1F")
#endif /* !THUMB */
@ -273,11 +286,6 @@ extern "C" {
void port_puts(char *msg);
void port_halt(void);
#ifdef THUMB
void _port_lock_thumb(void);
void _port_unlock_thumb(void);
void _port_disable_thumb(void);
void _port_suspend_thumb(void);
void _port_enable_thumb(void);
void _port_switch_thumb(Thread *otp, Thread *ntp);
#else /* THUMB */
void _port_switch_arm(Thread *otp, Thread *ntp);

View File

@ -44,27 +44,28 @@
.balign 16
.code 16
.thumb_func
.global _port_disable_all_thumb
_port_disable_all_thumb:
mov r0, pc
bx r0
.global _port_disable_thumb
_port_disable_thumb:
mov r3, pc
bx r3
.code 32
mrs r0, CPSR
orr r0, #I_BIT
msr CPSR_c, r0
orr r0, #F_BIT
msr CPSR_c, r0
mrs r3, CPSR
orr r3, #I_BIT
msr CPSR_c, r3
orr r3, #F_BIT
msr CPSR_c, r3
bx lr
.balign 16
.code 16
.thumb_func
.global _port_suspend_thumb
_port_disable_thumb:
_port_suspend_thumb:
.thumb_func
.global _port_lock_thumb
_port_lock_thumb:
mov r0, pc
bx r0
mov r3, pc
bx r3
.code 32
msr CPSR_c, #MODE_SYS | I_BIT
bx lr
@ -74,10 +75,11 @@ _port_lock_thumb:
.thumb_func
.global _port_enable_thumb
_port_enable_thumb:
.thumb_func
.global _port_unlock_thumb
_port_unlock_thumb:
mov r0, pc
bx r0
mov r3, pc
bx r3
.code 32
msr CPSR_c, #MODE_SYS
bx lr

View File

@ -77,6 +77,10 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- NEW: Added a configuration option to enable nested system locks/unlocks.
- NEW: Improved the interrupt handlers related code. Now interrupts are
handled in a very similar way in every architecture.
- OPT: Improved ARM7 thumb port code, thanks to some GCC tricks involving
registers usage now the kernel is much smaller, much faster and most OS APIs
use less RAM in stack frames (note, this is an ARM7 thumb mode specific
optimization).
- CHANGE: Renamed the macros chSysIRQEnter() and chSysIRQExit() in
CH_IRQ_PROLOGUE() and CH_IRQ_EPILOGUE() in order to make very clear that
those are not functions but inlined code. Also introduced a new macro
@ -86,7 +90,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Introduced the concept of system states, see the documentation.
- Huge improvements to the ports documentation.
- Articles and notes previously in the wiki now merged in the general
documentation, the wiki entries are obsolete and will be removed.
documentation and updated, the wiki entries are obsolete and will be removed.
- New application notes and articles added.
*** 1.0.0rc2 ***
@ -355,7 +359,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- OPT: Removed an unrequired initialization and made other small optimizations
to the chThdCreate().
- OPT: Improvements to the test framework, now a virtual timer is used instead
of software loops into the bechmarks in order to have more stable results.
of software loops into the benchmarks in order to have more stable results.
- New benchmark added to the test suite.
- Added the C++ wrapper entries to the documentation.
- Fixed the documentation entry for the chThdCreate() API.
@ -432,7 +436,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Fixes in various headers to make some macros compatible with both C and C++.
- Fixed a regression in the LPC214x minimal demo that broke interrupt
handling.
- Some fixes to the doxigen documentation.
- Some fixes to the doxygen documentation.
- More work done on the ARM-CM3 port but it is still not complete.
*** 0.6.1 ***
@ -450,7 +454,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Started work on ARM Cortex-M3 architecture. The target chip is the STM32F103
on a Olimex STM32-P103 board.
- Added a threads state diagram to the documentation.
- Various fixes to the doxigen documentation.
- Various fixes to the doxygen documentation.
*** 0.6.0 ***
- Code refactory, all the old sized-integer definitions like LONG32, UWORD16
@ -487,9 +491,9 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
the new demo were added.
*** 0.5.4 ***
- Port for Atmel AT91SAM7X256 introduced, the port should be useable also on
- Port for Atmel AT91SAM7X256 introduced, the port should be usable also on
SAM7S and SAM7XC but no tests were performed. Other SAM7 processors should
also be useable with limited changes.
also be usable with limited changes.
The demo currently just performs basic operations, will be enhanced in next
ChibiOS/RT releases, see the demo readme.txt file.
- Small fix to the thumb mode IRQ code on the LPC214x port, removed some extra
@ -522,12 +526,12 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
the P_MSGBYPRIO option when creating a message server thread.
This change allows the implementation of a priority ceiling protocol into
message servers threads. Threads serving messages by priority and threads
serving messages in FIFO orded can exist at the same time in the system.
serving messages in FIFO order can exist at the same time in the system.
This feature can be enabled or disabled by toggling the option
CH_USE_MESSAGES_PRIORITY into the chconf.h file (disabled by default, old
behavior).
Note: This option brings a small overhead when sending a message regardless
if in FIFO or priority order, if you dont need priority ordering for your
if in FIFO or priority order, if you don't need priority ordering for your
messages it is better to keep the feature disabled in chconf.h.
- Added to the ARM demos load scripts the capability to load code in RAM
instead flash, the function must be marked as:
@ -535,7 +539,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
The option -mlong-calls should be specified in the makefile too or the
function declared with the "long-call" attribute.
- Fixed the MSVC demo project files.
- Fixed some syntax incompatibilites between GCC and MSVC into chmtx.c.
- Fixed some syntax incompatibilities between GCC and MSVC into chmtx.c.
*** 0.5.0 ***
- NEW: Mutexes, the new mechanism provides a complete implementation of the
@ -664,7 +668,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Added a spreadsheet in the documentation that describes the advantages
and disadvantages of the various optimization options (both GCC options and
ChibiOS/RT options), very interesting read IMO.
- The GCC option +falign-functions=16 is now default in the Makefile, it is
- The GCC option -falign-functions=16 is now default in the Makefile, it is
required because of the MAM unit into the LPC chips, without this option
the code performance is less predictable and can change of some % points
depending on how the code is aligned in the flash memory, unpredictability
@ -710,7 +714,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Added experimental MMC/SD block driver to the LPC2148 demo in order to
support file systems. The driver features also events generation on card
insert/remove, hot plugging supported.
- Added missing chThdSuspend() declararion in threads.h.
- Added missing chThdSuspend() declaration in threads.h.
*** 0.3.5 ***
- Space optimization in events code.
@ -748,7 +752,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
is done in order to ensure that the initializations performed into the
main() procedure are finished before any thread starts.
- Added chThdSetPriority() new API.
- Added a generic events generator timer modulee to the library code.
- Added a generic events generator timer module to the library code.
- Modified the ARM7-LPC214x-GCC demo to show the use of the event timer.
- Added the "#ifdef __cplusplus" stuff to the header files.
- Removed an obsolete definition in ./src/templates/chtypes.h.
@ -792,7 +796,7 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- Thread Local Storage implemented as a single API: chThdLS().
The API simply returns a pointer into the thread working area, see the
documentation on the web site.
- Moved some documentation and images from the web site into the Doxigen
- Moved some documentation and images from the web site into the Doxygen
generated HTMLs.
*** 0.2.1 ***

View File

@ -32,7 +32,7 @@
#if defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES)
/**
* CondVar structure.
* @brief CondVar structure.
*/
typedef struct CondVar {
ThreadsQueue c_queue;

View File

@ -33,7 +33,7 @@
typedef struct EventListener EventListener;
/**
* Event Listener structure.
* @brief Event Listener structure.
*/
struct EventListener {
/** Next Event Listener registered on the Event Source.*/
@ -45,7 +45,7 @@ struct EventListener {
};
/**
* Event Source structure.
* @brief Event Source structure.
*/
typedef struct EventSource {
/** First Event Listener registered on the Event Source.*/

View File

@ -32,7 +32,7 @@ typedef struct Thread Thread;
#define notempty(p) ((p)->p_next != (Thread *)(p))
/**
* Generic threads queue header and element.
* @brief Generic threads queue header and element.
* @extends ThreadsList
*/
typedef struct {
@ -43,17 +43,22 @@ typedef struct {
} ThreadsQueue;
/**
* Generic threads single link list, it works like a stack.
* @brief Generic threads single link list.
* @details This list behaves like a stack.
*/
typedef struct {
/** Last pushed @p Thread on the stack list, or @p ThreadList when empty. */
Thread *p_next;
} ThreadsList;
/*
* Threads Lists functions and macros.
/**
* Queue initialization.
*/
#define queue_init(tqp) ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));
/**
* List initialization.
*/
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
#ifndef CH_OPTIMIZE_SPEED

View File

@ -28,7 +28,7 @@
#ifdef CH_USE_MUTEXES
/**
* Mutex structure.
* @brief Mutex structure.
*/
typedef struct Mutex {
/** Queue of the threads sleeping on this Mutex.*/

View File

@ -41,7 +41,8 @@ typedef void (*qnotify_t)(void);
#ifdef CH_USE_QUEUES
/**
* I/O queue structure, it is used by both Input and Output Queues,
* @brief I/O queue structure.
* @details This structure is used by both Input and Output Queues,
* the difference is on how the semaphore is initialized.
*/
typedef struct {
@ -116,7 +117,7 @@ extern "C" {
#ifdef CH_USE_QUEUES_HALFDUPLEX
/**
* Half duplex queue structure.
* @brief Half duplex queue structure.
*/
typedef struct {
/** Pointer to the queue buffer. */

View File

@ -53,7 +53,8 @@
#define firstprio(rlp) ((rlp)->p_next->p_prio)
/**
* Ready list header.
* @brief Ready list header.
*
* @extends ThreadsQueue
*/
typedef struct {

View File

@ -28,7 +28,7 @@
#ifdef CH_USE_SEMAPHORES
/**
* Semaphore structure.
* @brief Semaphore structure.
*/
typedef struct Semaphore {
/** Queue of the threads sleeping on this Semaphore.*/

View File

@ -46,7 +46,7 @@ typedef uint16_t dflags_t;
#ifdef CH_USE_SERIAL_FULLDUPLEX
/**
* Full Duplex Serial Driver main structure.
* @brief Full Duplex Serial Driver main structure.
*/
typedef struct {
@ -111,7 +111,7 @@ extern "C" {
#ifdef CH_USE_SERIAL_HALFDUPLEX
/**
* Full Duplex Serial Driver main structure.
* @brief Full Duplex Serial Driver main structure.
*/
typedef struct {

View File

@ -26,7 +26,8 @@
#define _THREADS_H_
/**
* Structure representing a thread.
* @brief Structure representing a thread.
*
* @extends ThreadsQueue
* @note Not all the listed fields are always needed, by switching off some
* not needed ChibiOS/RT subsystems it is possible to save RAM space by

View File

@ -48,7 +48,7 @@ typedef void (*vtfunc_t)(void *);
typedef struct VirtualTimer VirtualTimer;
/**
* Virtual Timer descriptor structure.
* @brief Virtual Timer descriptor structure.
* @extends DeltaList
*/
struct VirtualTimer {
@ -66,7 +66,7 @@ struct VirtualTimer {
};
/**
* Delta List header.
* @brief Virtual timers list header.
* @note The delta list is implemented as a double link bidirectional list in
* order to make the unlink time constant, the reset of a virtual timer
* is often used in the code.

View File

@ -281,12 +281,12 @@ namespace chibios_rt {
#ifdef CH_USE_SEMAPHORES
/**
* @brief Class encapsulating a @p Semaphore.
* @brief Class encapsulating a semaphore.
*/
class Semaphore {
public:
/**
* @brief Embedded @p Semaphore structure.
* @brief Embedded @p ::Semaphore structure.
*/
struct ::Semaphore sem;
@ -349,12 +349,12 @@ namespace chibios_rt {
#ifdef CH_USE_MUTEXES
/**
* @brief Class encapsulating a @p Mutex.
* @brief Class encapsulating a mutex.
*/
class Mutex {
public:
/**
* @brief Embedded @p Mutex structure.
* @brief Embedded @p ::Mutex structure.
*/
struct ::Mutex mutex;
@ -398,12 +398,12 @@ namespace chibios_rt {
#ifdef CH_USE_CONDVARS
/**
* @brief Class encapsulating a @p CondVar.
* @brief Class encapsulating a conditional variable.
*/
class CondVar {
public:
/**
* @brief Embedded @p CondVar structure.
* @brief Embedded @p ::CondVar structure.
*/
struct ::CondVar condvar;
@ -453,12 +453,12 @@ namespace chibios_rt {
#ifdef CH_USE_EVENTS
/**
* @brief Class encapsulating an @p EventSource.
* @brief Class encapsulating an event source.
*/
class Event {
public:
/**
* @brief Embedded @p EventSource structure.
* @brief Embedded @p ::EventSource structure.
*/
struct ::EventSource event;

View File

@ -26,7 +26,7 @@
#define _EVTIMER_H_
/**
* Event timer structure.
* @brief Event timer structure.
*/
typedef struct {
VirtualTimer et_vt;

View File

@ -38,24 +38,25 @@
typedef uint8_t stkalign_t;
/**
* Interrupt saved context.
* This structure represents the stack frame saved during a preemption-capable
* interrupt handler.
* @brief Interrupt saved context.
* @details This structure represents the stack frame saved during a
* preemption-capable interrupt handler.
*/
struct extctx {
};
/**
* System saved context.
* This structure represents the inner stack frame during a context switching.
* @brief System saved context.
* @details This structure represents the inner stack frame during a context
* switching.
*/
struct intctx {
};
/**
* Platform dependent part of the @p Thread structure.
* This structure usually contains just the saved stack pointer defined as a
* pointer to a @p intctx structure.
* @brief Platform dependent part of the @p Thread structure.
* @details This structure usually contains just the saved stack pointer
* defined as a pointer to a @p intctx structure.
*/
struct context {
struct intctx *sp;