diff options
-rw-r--r-- | docs/reports/STM32F103-72.txt | 36 | ||||
-rw-r--r-- | os/kernel/src/chmtx.c | 37 | ||||
-rw-r--r-- | os/kernel/src/chschd.c | 10 |
3 files changed, 46 insertions, 37 deletions
diff --git a/docs/reports/STM32F103-72.txt b/docs/reports/STM32F103-72.txt index 73ceeffa0..09ddc8850 100644 --- a/docs/reports/STM32F103-72.txt +++ b/docs/reports/STM32F103-72.txt @@ -7,7 +7,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states) ***
*** Kernel: 1.3.2unstable
*** Architecture: ARM Cortex-M3
-*** GCC Version: 4.3.3
+*** GCC Version: 4.4.1
----------------------------------------------------------------------------
--- Test Case 1.1 (Threads, enqueuing test #1)
@@ -90,47 +90,51 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states) --- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
---- Score : 215037 msgs/S, 430074 ctxswc/S
+--- Score : 221677 msgs/S, 443354 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
---- Score : 174744 msgs/S, 349488 ctxswc/S
+--- Score : 185595 msgs/S, 371190 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.3 (Benchmark, messages #3)
---- Score : 174744 msgs/S, 349488 ctxswc/S
+--- Score : 185595 msgs/S, 371190 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
---- Score : 676760 ctxswc/S
+--- Score : 696488 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
---- Score : 164727 threads/S
+--- Score : 173486 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.6 (Benchmark, threads, create only)
---- Score : 215680 threads/S
+--- Score : 222371 threads/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedulation, 5 threads)
---- Score : 54745 reschedulations/S, 328470 ctxswc/S
+--- Score : 56916 reschedulations/S, 341496 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
---- Test Case 11.8 (Benchmark, I/O Queues throughput)
---- Score : 474888 bytes/S
+--- Test Case 11.8 (Benchmark, round robin context switching)
+--- Score : 504956 reschedulations/S, 504956 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
---- Test Case 11.9 (Benchmark, virtual timers set/reset)
---- Score : 647070 timers/S
+--- Test Case 11.9 (Benchmark, I/O Queues throughput)
+--- Score : 474720 bytes/S
--- Result: SUCCESS
----------------------------------------------------------------------------
---- Test Case 11.10 (Benchmark, semaphores wait/signal)
---- Score : 823264 wait+signal/S
+--- Test Case 11.10 (Benchmark, virtual timers set/reset)
+--- Score : 647110 timers/S
--- Result: SUCCESS
----------------------------------------------------------------------------
---- Test Case 11.11 (Benchmark, mutexes lock/unlock)
---- Score : 601084 lock+unlock/S
+--- Test Case 11.11 (Benchmark, semaphores wait/signal)
+--- Score : 832884 wait+signal/S
+--- Result: SUCCESS
+----------------------------------------------------------------------------
+--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
+--- Score : 586424 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
diff --git a/os/kernel/src/chmtx.c b/os/kernel/src/chmtx.c index cc3c91e3e..9e568c782 100644 --- a/os/kernel/src/chmtx.c +++ b/os/kernel/src/chmtx.c @@ -69,7 +69,7 @@ void chMtxLockS(Mutex *mp) { chDbgCheck(mp != NULL, "chMtxLockS"); - /* the mutex is already locked? */ + /* Ia the mutex already locked? */ if (mp->m_owner != NULL) { /* * Priority inheritance protocol; explores the thread-mutex dependencies @@ -77,50 +77,47 @@ void chMtxLockS(Mutex *mp) { * of the running thread requesting the mutex. */ Thread *tp = mp->m_owner; - /* { tp is the thread currently owning the mutex } */ - /* the running thread has higher priority than tp? */ + /* {tp is the thread currently owning the mutex} */ + /* Has the running thread higher priority than tp? */ while (tp->p_prio < currp->p_prio) { - /* make priority of thread tp match the running thread's priority */ + /* Make priority of thread tp match the running thread's priority.*/ tp->p_prio = currp->p_prio; /* * The following states need priority queues reordering. */ switch (tp->p_state) { - /* thread tp is waiting on a mutex? */ case PRWTMTX: - /* Requeues tp with its new priority on the mutex wait queue. */ + /* Re-enqueues tp with its new priority on the mutex wait queue.*/ prio_insert(dequeue(tp), &tp->p_wtmtxp->m_queue); - /* boost the owner of this mutex if needed */ + /* Boost the owner of this mutex if needed.*/ tp = tp->p_wtmtxp->m_owner; continue; #if CH_USE_CONDVARS case PRWTCOND: - /* Requeues tp with its new priority on the condvar queue. */ + /* Re-enqueues tp with its new priority on the condvar queue.*/ prio_insert(dequeue(tp), &tp->p_wtcondp->c_queue); break; #endif #if CH_USE_SEMAPHORES_PRIORITY case PRWTSEM: - /* Requeues tp with its new priority on the semaphore queue. */ + /* Re-enqueues tp with its new priority on the semaphore queue.*/ prio_insert(dequeue(tp), &tp->p_wtsemp->s_queue); break; #endif #if CH_USE_MESSAGES_PRIORITY case PRSNDMSG: - /* Requeues tp with its new priority on the server thread queue. */ + /* Re-enqueues tp with its new priority on the server thread queue.*/ prio_insert(dequeue(tp), &tp->p_wtthdp->p_msgqueue); break; #endif - /* thread tp is ready? */ case PRREADY: - /* Requeue tp with its new priority on the ready list. */ + /* Re-enqueues tp with its new priority on the ready list.*/ chSchReadyI(dequeue(tp)); } break; } - /* sleep on the mutex */ + /* Sleep on the mutex.*/ prio_insert(currp, &mp->m_queue); - /* thread remembers the mutex where it is waiting on */ currp->p_wtmtxp = mp; chSchGoSleepS(PRWTMTX); chDbgAssert(mp->m_owner == NULL, "chMtxLockS(), #1", "still owned"); @@ -201,24 +198,24 @@ Mutex *chMtxUnlock(void) { * If a thread is waiting on the mutex then the hard part begins. */ if (chMtxQueueNotEmptyS(ump)) { - /* get the highest priority thread waiting for the unlocked mutex */ + /* Get the highest priority thread waiting for the unlocked mutex.*/ Thread *tp = fifo_remove(&ump->m_queue); /* * Recalculates the optimal thread priority by scanning the owned mutexes list. */ tprio_t newprio = currp->p_realprio; - /* iterate mp over all the (other) mutexes the current thread still owns */ + /* Iterate mp over all the (other) mutexes the current thread still owns.*/ mp = currp->p_mtxlist; while (mp != NULL) { - /* mutex mp has a higher priority thread pending? */ + /* Has the mutex mp a higher priority thread pending? */ if (chMtxQueueNotEmptyS(mp) && (mp->m_queue.p_next->p_prio > newprio)) - /* boost current thread's priority to waiting thread */ + /* Boost the recalculated thread's priority to waiting thread.*/ newprio = mp->m_queue.p_next->p_prio; mp = mp->m_next; } - /* (possibly) boost the priority of the current thread */ + /* Possibly restores the priority of the current thread.*/ currp->p_prio = newprio; - /* awaken the highest priority thread waiting for the unlocked mutex */ + /* Awaken the highest priority thread waiting for the unlocked mutex.*/ chSchWakeupS(tp, RDY_OK); } chSysUnlock(); diff --git a/os/kernel/src/chschd.c b/os/kernel/src/chschd.c index 7ab32f068..093a1a0c0 100644 --- a/os/kernel/src/chschd.c +++ b/os/kernel/src/chschd.c @@ -162,6 +162,7 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { * @param[in] msg message to the awakened thread * @note It is equivalent to a @p chSchReadyI() followed by a * @p chSchRescheduleS() but much more efficient. + * @note The function assumes that the current thread has the highest priority */ void chSchWakeupS(Thread *ntp, msg_t msg) { @@ -175,10 +176,17 @@ void chSchWakeupS(Thread *ntp, msg_t msg) { else { Thread *otp = currp; chSchReadyI(otp); - (currp = ntp)->p_state = PRCURR; #if CH_USE_ROUNDROBIN rlist.r_preempt = CH_TIME_QUANTUM; #endif +#if 0 + /* Shortcut for when the round robin scheduling is not enabled.*/ + otp->p_state = PRREADY; + /* Direct insertion on top of the ready list, no scanning.*/ + otp->p_next = rlist.r_queue.p_next->p_next; + otp->p_next->p_prev = rlist.r_queue.p_next = otp; +#endif + (currp = ntp)->p_state = PRCURR; chDbgTrace(otp, ntp); chSysSwitchI(otp, ntp); } |