Incorporated main and idle threads data areas into the ch_system structure, moved around some definitions in order to allow this.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7572 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
055fea386e
commit
e023f0058d
|
@ -3,11 +3,12 @@ Options: -O2 -fomit-frame-pointer -falign-functions=16
|
|||
Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
||||
***************************************************************************
|
||||
|
||||
|
||||
*** ChibiOS/RT test suite
|
||||
***
|
||||
*** Kernel: 3.0.0dev
|
||||
*** Compiled: Oct 26 2014 - 10:54:30
|
||||
*** Compiler: GCC 4.7.4 20140401 (release) [ARM/embedded-4_7-branch revision 209195]
|
||||
*** Compiled: Dec 11 2014 - 16:29:11
|
||||
*** Compiler: GCC 4.7.3 20130312 (release) [ARM/embedded-4_7-branch revision 196615]
|
||||
*** Architecture: ARMv7-ME
|
||||
*** Core Variant: Cortex-M4F
|
||||
*** Port Info: Advanced kernel mode
|
||||
|
@ -94,7 +95,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.1 (Benchmark, messages #1)
|
||||
--- Score : 604311 msgs/S, 1208622 ctxswc/S
|
||||
--- Score : 604310 msgs/S, 1208620 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.2 (Benchmark, messages #2)
|
||||
|
@ -118,11 +119,11 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
|
||||
--- Score : 164867 reschedules/S, 989202 ctxswc/S
|
||||
--- Score : 166172 reschedules/S, 997032 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.8 (Benchmark, round robin context switching)
|
||||
--- Score : 1181012 ctxswc/S
|
||||
--- Score : 1197856 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
|
||||
|
@ -130,7 +131,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
|
||||
--- Score : 1343996 timers/S
|
||||
--- Score : 1322832 timers/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
|
||||
|
@ -142,7 +143,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.13 (Benchmark, RAM footprint)
|
||||
--- System: 732 bytes
|
||||
--- System: 472 bytes
|
||||
--- Thread: 68 bytes
|
||||
--- Timer : 20 bytes
|
||||
--- Semaph: 12 bytes
|
||||
|
|
|
@ -6,8 +6,8 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
*** ChibiOS/RT test suite
|
||||
***
|
||||
*** Kernel: 3.0.0dev
|
||||
*** Compiled: Oct 26 2014 - 10:50:20
|
||||
*** Compiler: GCC 4.7.4 20140401 (release) [ARM/embedded-4_7-branch revision 209195]
|
||||
*** Compiled: Dec 11 2014 - 16:38:49
|
||||
*** Compiler: GCC 4.7.3 20130312 (release) [ARM/embedded-4_7-branch revision 196615]
|
||||
*** Architecture: ARMv7-ME
|
||||
*** Core Variant: Cortex-M4
|
||||
*** Port Info: Advanced kernel mode
|
||||
|
@ -94,7 +94,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.1 (Benchmark, messages #1)
|
||||
--- Score : 799993 msgs/S, 1599986 ctxswc/S
|
||||
--- Score : 799994 msgs/S, 1599988 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.2 (Benchmark, messages #2)
|
||||
|
@ -118,11 +118,11 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
|
||||
--- Score : 206135 reschedules/S, 1236810 ctxswc/S
|
||||
--- Score : 208178 reschedules/S, 1249068 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.8 (Benchmark, round robin context switching)
|
||||
--- Score : 1551960 ctxswc/S
|
||||
--- Score : 1581160 ctxswc/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
|
||||
|
@ -130,7 +130,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.10 (Benchmark, virtual timers set/reset)
|
||||
--- Score : 1343998 timers/S
|
||||
--- Score : 1322832 timers/S
|
||||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.11 (Benchmark, semaphores wait/signal)
|
||||
|
@ -142,7 +142,7 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
--- Result: SUCCESS
|
||||
----------------------------------------------------------------------------
|
||||
--- Test Case 11.13 (Benchmark, RAM footprint)
|
||||
--- System: 460 bytes
|
||||
--- System: 336 bytes
|
||||
--- Thread: 68 bytes
|
||||
--- Timer : 20 bytes
|
||||
--- Semaph: 12 bytes
|
||||
|
@ -156,3 +156,4 @@ Settings: SYSCLK=168, ACR=0x705 (5 wait states)
|
|||
----------------------------------------------------------------------------
|
||||
|
||||
Final result: SUCCESS
|
||||
|
||||
|
|
|
@ -56,6 +56,105 @@
|
|||
#define ABSPRIO 255 /**< @brief Greatest possible priority. */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Thread states
|
||||
* @{
|
||||
*/
|
||||
#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */
|
||||
#define CH_STATE_CURRENT 1 /**< @brief Currently running. */
|
||||
#define CH_STATE_WTSTART 2 /**< @brief Created but not started. */
|
||||
#define CH_STATE_SUSPENDED 3 /**< @brief Suspended state. */
|
||||
#define CH_STATE_QUEUED 4 /**< @brief Waiting on an I/O queue. */
|
||||
#define CH_STATE_WTSEM 5 /**< @brief Waiting on a semaphore. */
|
||||
#define CH_STATE_WTMTX 6 /**< @brief Waiting on a mutex. */
|
||||
#define CH_STATE_WTCOND 7 /**< @brief Waiting on a condition
|
||||
variable. */
|
||||
#define CH_STATE_SLEEPING 8 /**< @brief Waiting in @p chThdSleep()
|
||||
or @p chThdSleepUntil(). */
|
||||
#define CH_STATE_WTEXIT 9 /**< @brief Waiting in @p chThdWait(). */
|
||||
#define CH_STATE_WTOREVT 10 /**< @brief Waiting for an event. */
|
||||
#define CH_STATE_WTANDEVT 11 /**< @brief Waiting for several events. */
|
||||
#define CH_STATE_SNDMSGQ 12 /**< @brief Sending a message, in queue.*/
|
||||
#define CH_STATE_SNDMSG 13 /**< @brief Sent a message, waiting
|
||||
answer. */
|
||||
#define CH_STATE_WTMSG 14 /**< @brief Waiting for a message. */
|
||||
#define CH_STATE_FINAL 15 /**< @brief Thread terminated. */
|
||||
|
||||
/**
|
||||
* @brief Thread states as array of strings.
|
||||
* @details Each element in an array initialized with this macro can be
|
||||
* indexed using the numeric thread state values.
|
||||
*/
|
||||
#define CH_STATE_NAMES \
|
||||
"READY", "CURRENT", "WTSTART", "SUSPENDED", "QUEUED", "WTSEM", "WTMTX", \
|
||||
"WTCOND", "SLEEPING", "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", \
|
||||
"SNDMSG", "WTMSG", "FINAL"
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Thread flags and attributes
|
||||
* @{
|
||||
*/
|
||||
#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */
|
||||
#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */
|
||||
#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a
|
||||
Memory Heap. */
|
||||
#define CH_FLAG_MODE_MEMPOOL 2 /**< @brief Thread allocated from a
|
||||
Memory Pool. */
|
||||
#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Working Areas and Alignment
|
||||
*/
|
||||
/**
|
||||
* @brief Enforces a correct alignment for a stack area size value.
|
||||
*
|
||||
* @param[in] n the stack size to be aligned to the next stack
|
||||
* alignment boundary
|
||||
* @return The aligned stack size.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_ALIGN_STACK_SIZE(n) \
|
||||
((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
|
||||
|
||||
/**
|
||||
* @brief Calculates the total Working Area size.
|
||||
*
|
||||
* @param[in] n the stack size to be assigned to the thread
|
||||
* @return The total used memory in bytes.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_WORKING_AREA_SIZE(n) \
|
||||
THD_ALIGN_STACK_SIZE(sizeof(thread_t) + PORT_WA_SIZE(n))
|
||||
|
||||
/**
|
||||
* @brief Static working area allocation.
|
||||
* @details This macro is used to allocate a static thread working area
|
||||
* aligned as both position and size.
|
||||
*
|
||||
* @param[in] s the name to be assigned to the stack array
|
||||
* @param[in] n the stack size to be assigned to the thread
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_WORKING_AREA(s, n) \
|
||||
stkalign_t s[THD_WORKING_AREA_SIZE(n) / sizeof(stkalign_t)]
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Threads abstraction macros
|
||||
*/
|
||||
/**
|
||||
* @brief Thread declaration macro.
|
||||
* @note Thread declarations should be performed using this macro because
|
||||
* the port layer could define optimizations for thread functions.
|
||||
*/
|
||||
#define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
@ -332,6 +431,10 @@ struct ch_system {
|
|||
* @brief System debug.
|
||||
*/
|
||||
system_debug_t dbg;
|
||||
/**
|
||||
* @brief Main thread descriptor.
|
||||
*/
|
||||
thread_t mainthread;
|
||||
#if CH_CFG_USE_TM || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Time measurement calibration data.
|
||||
|
@ -344,6 +447,12 @@ struct ch_system {
|
|||
*/
|
||||
kernel_stats_t kernel_stats;
|
||||
#endif
|
||||
#if !CH_CFG_NO_IDLE_THREAD
|
||||
/**
|
||||
* @brief Idle thread working area.
|
||||
*/
|
||||
THD_WORKING_AREA(idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
|
||||
#endif
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
|
@ -33,54 +33,6 @@
|
|||
/* Module constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Thread states
|
||||
* @{
|
||||
*/
|
||||
#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */
|
||||
#define CH_STATE_CURRENT 1 /**< @brief Currently running. */
|
||||
#define CH_STATE_WTSTART 2 /**< @brief Created but not started. */
|
||||
#define CH_STATE_SUSPENDED 3 /**< @brief Suspended state. */
|
||||
#define CH_STATE_QUEUED 4 /**< @brief Waiting on an I/O queue. */
|
||||
#define CH_STATE_WTSEM 5 /**< @brief Waiting on a semaphore. */
|
||||
#define CH_STATE_WTMTX 6 /**< @brief Waiting on a mutex. */
|
||||
#define CH_STATE_WTCOND 7 /**< @brief Waiting on a condition
|
||||
variable. */
|
||||
#define CH_STATE_SLEEPING 8 /**< @brief Waiting in @p chThdSleep()
|
||||
or @p chThdSleepUntil(). */
|
||||
#define CH_STATE_WTEXIT 9 /**< @brief Waiting in @p chThdWait(). */
|
||||
#define CH_STATE_WTOREVT 10 /**< @brief Waiting for an event. */
|
||||
#define CH_STATE_WTANDEVT 11 /**< @brief Waiting for several events. */
|
||||
#define CH_STATE_SNDMSGQ 12 /**< @brief Sending a message, in queue.*/
|
||||
#define CH_STATE_SNDMSG 13 /**< @brief Sent a message, waiting
|
||||
answer. */
|
||||
#define CH_STATE_WTMSG 14 /**< @brief Waiting for a message. */
|
||||
#define CH_STATE_FINAL 15 /**< @brief Thread terminated. */
|
||||
|
||||
/**
|
||||
* @brief Thread states as array of strings.
|
||||
* @details Each element in an array initialized with this macro can be
|
||||
* indexed using the numeric thread state values.
|
||||
*/
|
||||
#define CH_STATE_NAMES \
|
||||
"READY", "CURRENT", "WTSTART", "SUSPENDED", "QUEUED", "WTSEM", "WTMTX", \
|
||||
"WTCOND", "SLEEPING", "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", \
|
||||
"SNDMSG", "WTMSG", "FINAL"
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Thread flags and attributes
|
||||
* @{
|
||||
*/
|
||||
#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */
|
||||
#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */
|
||||
#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a
|
||||
Memory Heap. */
|
||||
#define CH_FLAG_MODE_MEMPOOL 2 /**< @brief Thread allocated from a
|
||||
Memory Pool. */
|
||||
#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */
|
||||
/** @} */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
@ -107,57 +59,6 @@ typedef msg_t (*tfunc_t)(void *);
|
|||
/* Module macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @name Working Areas and Alignment
|
||||
*/
|
||||
/**
|
||||
* @brief Enforces a correct alignment for a stack area size value.
|
||||
*
|
||||
* @param[in] n the stack size to be aligned to the next stack
|
||||
* alignment boundary
|
||||
* @return The aligned stack size.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_ALIGN_STACK_SIZE(n) \
|
||||
((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
|
||||
|
||||
/**
|
||||
* @brief Calculates the total Working Area size.
|
||||
*
|
||||
* @param[in] n the stack size to be assigned to the thread
|
||||
* @return The total used memory in bytes.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_WORKING_AREA_SIZE(n) \
|
||||
THD_ALIGN_STACK_SIZE(sizeof(thread_t) + PORT_WA_SIZE(n))
|
||||
|
||||
/**
|
||||
* @brief Static working area allocation.
|
||||
* @details This macro is used to allocate a static thread working area
|
||||
* aligned as both position and size.
|
||||
*
|
||||
* @param[in] s the name to be assigned to the stack array
|
||||
* @param[in] n the stack size to be assigned to the thread
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define THD_WORKING_AREA(s, n) \
|
||||
stkalign_t s[THD_WORKING_AREA_SIZE(n) / sizeof(stkalign_t)]
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Threads abstraction macros
|
||||
*/
|
||||
/**
|
||||
* @brief Thread declaration macro.
|
||||
* @note Thread declarations should be performed using this macro because
|
||||
* the port layer could define optimizations for thread functions.
|
||||
*/
|
||||
#define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Threads queues
|
||||
*/
|
||||
|
|
|
@ -48,13 +48,6 @@
|
|||
/* Module local variables. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if !CH_CFG_NO_IDLE_THREAD || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Idle thread working area.
|
||||
*/
|
||||
static THD_WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
|
||||
#endif /* CH_CFG_NO_IDLE_THREAD */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local functions. */
|
||||
/*===========================================================================*/
|
||||
|
@ -68,7 +61,7 @@ static THD_WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
|
|||
* that this thread is executed only if there are no other ready
|
||||
* threads in the system.
|
||||
*
|
||||
* @param[in] p the thread parameter, unused in this scenario
|
||||
* @param[in] p the thread parameter, unused in this scenario
|
||||
*/
|
||||
static void _idle_thread(void *p) {
|
||||
|
||||
|
@ -89,16 +82,13 @@ static void _idle_thread(void *p) {
|
|||
* @brief ChibiOS/RT initialization.
|
||||
* @details After executing this function the current instructions stream
|
||||
* becomes the main thread.
|
||||
* @pre Interrupts must be still disabled when @p chSysInit() is invoked
|
||||
* and are internally enabled.
|
||||
* @post The main thread is created with priority @p NORMALPRIO.
|
||||
* @note This function has special, architecture-dependent, requirements,
|
||||
* see the notes into the various port reference manuals.
|
||||
* @pre Interrupts must disabled before invoking this function.
|
||||
* @post The main thread is created with priority @p NORMALPRIO and
|
||||
* interrupts are enabled.
|
||||
*
|
||||
* @special
|
||||
*/
|
||||
void chSysInit(void) {
|
||||
static thread_t mainthread;
|
||||
#if CH_DBG_ENABLE_STACK_CHECK
|
||||
extern stkalign_t __main_thread_stack_base__;
|
||||
#endif
|
||||
|
@ -124,10 +114,10 @@ void chSysInit(void) {
|
|||
|
||||
#if !CH_CFG_NO_IDLE_THREAD
|
||||
/* Now this instructions flow becomes the main thread.*/
|
||||
setcurrp(_thread_init(&mainthread, NORMALPRIO));
|
||||
setcurrp(_thread_init(&ch.mainthread, NORMALPRIO));
|
||||
#else
|
||||
/* Now this instructions flow becomes the main thread.*/
|
||||
setcurrp(_thread_init(&mainthread, IDLEPRIO));
|
||||
/* Now this instructions flow becomes the idle thread.*/
|
||||
setcurrp(_thread_init(&ch.mainthread, IDLEPRIO));
|
||||
#endif
|
||||
|
||||
currp->p_state = CH_STATE_CURRENT;
|
||||
|
@ -146,7 +136,7 @@ void chSysInit(void) {
|
|||
/* This thread has the lowest priority in the system, its role is just to
|
||||
serve interrupts in its context while keeping the lowest energy saving
|
||||
mode compatible with the system status.*/
|
||||
chThdCreateStatic(_idle_thread_wa, sizeof(_idle_thread_wa), IDLEPRIO,
|
||||
chThdCreateStatic(ch.idle_thread_wa, sizeof(ch.idle_thread_wa), IDLEPRIO,
|
||||
(tfunc_t)_idle_thread, NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -644,11 +644,7 @@ ROMCONST struct testcase testbmk12 = {
|
|||
static void bmk13_execute(void) {
|
||||
|
||||
test_print("--- System: ");
|
||||
test_printn(sizeof(ready_list_t) + sizeof(virtual_timers_list_t) +
|
||||
PORT_IDLE_THREAD_STACK_SIZE +
|
||||
(sizeof(thread_t) + sizeof(struct port_intctx) +
|
||||
sizeof(struct port_extctx) +
|
||||
PORT_INT_REQUIRED_STACK) * 2);
|
||||
test_printn(sizeof(ch_system_t));
|
||||
test_println(" bytes");
|
||||
test_print("--- Thread: ");
|
||||
test_printn(sizeof(thread_t));
|
||||
|
|
Loading…
Reference in New Issue