Fixed bug 3019099.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2027 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2010-06-21 16:52:51 +00:00
parent 8cb7a02ded
commit fe292af06d
3 changed files with 51 additions and 21 deletions

View File

@ -5,7 +5,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states)
*** ChibiOS/RT test suite
***
*** Kernel: 1.5.7unstable
*** Kernel: 2.1.0unstable
*** GCC Version: 4.5.0
*** Architecture: ARMv7-M
*** Core Variant: Cortex-M3
@ -95,7 +95,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.1 (Benchmark, messages #1)
--- Score : 250283 msgs/S, 500566 ctxswc/S
--- Score : 250284 msgs/S, 500568 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.2 (Benchmark, messages #2)
@ -107,7 +107,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.4 (Benchmark, context switch)
--- Score : 838936 ctxswc/S
--- Score : 838944 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.5 (Benchmark, threads, full cycle)
@ -119,11 +119,11 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.7 (Benchmark, mass reschedule, 5 threads)
--- Score : 62250 reschedules/S, 373500 ctxswc/S
--- Score : 62305 reschedules/S, 373830 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.8 (Benchmark, round robin context switching)
--- Score : 481288 ctxswc/S
--- Score : 481292 ctxswc/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.9 (Benchmark, I/O Queues throughput)
@ -139,7 +139,7 @@ Settings: SYSCLK=72, ACR=0x12 (2 wait states)
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.12 (Benchmark, mutexes lock/unlock)
--- Score : 638608 lock+unlock/S
--- Score : 601192 lock+unlock/S
--- Result: SUCCESS
----------------------------------------------------------------------------
--- Test Case 11.13 (Benchmark, RAM footprint)

View File

@ -145,12 +145,17 @@ void chMtxLockS(Mutex *mp) {
prio_insert(ctp, &mp->m_queue);
ctp->p_u.wtobjp = mp;
chSchGoSleepS(THD_STATE_WTMTX);
chDbgAssert(mp->m_owner == NULL, "chMtxLockS(), #1", "still owned");
/* It is assumed that the thread performing the unlock operation assigns
the mutex to this thread.*/
chDbgAssert(mp->m_owner == ctp, "chMtxLockS(), #1", "not owner");
chDbgAssert(ctp->p_mtxlist == mp, "chMtxLockS(), #2", "not owned");
}
else {
/* It was not owned, inserted in the owned mutexes list.*/
mp->m_owner = ctp;
mp->m_next = ctp->p_mtxlist;
ctp->p_mtxlist = mp;
}
/* The mutex is now inserted in the owned mutexes list.*/
mp->m_owner = ctp;
mp->m_next = ctp->p_mtxlist;
ctp->p_mtxlist = mp;
}
/**
@ -216,9 +221,10 @@ Mutex *chMtxUnlock(void) {
as not owned.*/
ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
ump->m_owner = NULL;
/* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) {
Thread *tp;
/* Recalculates the optimal thread priority by scanning the owned
mutexes list.*/
tprio_t newprio = ctp->p_realprio;
@ -234,9 +240,16 @@ Mutex *chMtxUnlock(void) {
/* Assigns to the current thread the highest priority among all the
waiting threads.*/
ctp->p_prio = newprio;
/* Awakens the highest priority thread waiting for the unlocked mutex.*/
chSchWakeupS(fifo_remove(&ump->m_queue), RDY_OK);
/* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/
tp = fifo_remove(&ump->m_queue);
ump->m_owner = tp;
ump->m_next = tp->p_mtxlist;
tp->p_mtxlist = ump;
chSchWakeupS(tp, RDY_OK);
}
else
ump->m_owner = NULL;
chSysUnlock();
return ump;
}
@ -262,9 +275,10 @@ Mutex *chMtxUnlockS(void) {
owned.*/
ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
ump->m_owner = NULL;
/* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) {
Thread *tp;
/* Recalculates the optimal thread priority by scanning the owned
mutexes list.*/
tprio_t newprio = ctp->p_realprio;
@ -278,8 +292,16 @@ Mutex *chMtxUnlockS(void) {
mp = mp->m_next;
}
ctp->p_prio = newprio;
chSchReadyI(fifo_remove(&ump->m_queue));
/* Awakens the highest priority thread waiting for the unlocked mutex and
assigns the mutex to it.*/
tp = fifo_remove(&ump->m_queue);
ump->m_owner = tp;
ump->m_next = tp->p_mtxlist;
tp->p_mtxlist = ump;
chSchReadyI(tp);
}
else
ump->m_owner = NULL;
return ump;
}
@ -296,11 +318,17 @@ void chMtxUnlockAll(void) {
chSysLock();
if (ctp->p_mtxlist != NULL) {
do {
Mutex *mp = ctp->p_mtxlist;
ctp->p_mtxlist = mp->m_next;
mp->m_owner = NULL;
if (chMtxQueueNotEmptyS(mp))
chSchReadyI(fifo_remove(&mp->m_queue));
Mutex *ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next;
if (chMtxQueueNotEmptyS(ump)) {
Thread *tp = fifo_remove(&ump->m_queue);
ump->m_owner = tp;
ump->m_next = tp->p_mtxlist;
tp->p_mtxlist = ump;
chSchReadyI(tp);
}
else
ump->m_owner = NULL;
} while (ctp->p_mtxlist != NULL);
ctp->p_prio = ctp->p_realprio;
chSchRescheduleS();

View File

@ -59,6 +59,8 @@
*****************************************************************************
*** 2.1.0 ***
- FIX: Fixed instability in Mutexes subsystem (bug 3019099)(backported
in 2.0.1).
- FIX: Fixed broken AVR port (bug 3016619)(backported in 2.0.0).
- FIX: Fixed assertion in adcStop() (bug 3015109)(backported in 2.0.0).
- OPT: Simplified the test suite code, now it is smaller.