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

master
gdisirio 2007-11-16 13:14:30 +00:00
parent 3fe3d0d6a9
commit da365c95e4
6 changed files with 83 additions and 29 deletions

View File

@ -62,12 +62,15 @@ UDEFS =
UADEFS = UADEFS =
# List ARM-mode C source files here # List ARM-mode C source files here
ASRC = chcore.c main.c buzzer.c mmcsd.c ../../src/lib/evtimer.c ../../test/test.c \ ASRC = chcore.c \
../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \
../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \
../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \ ../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \
../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \ ../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \
../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c ../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c \
../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \
../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \
../../src/lib/evtimer.c ../../test/test.c \
buzzer.c mmcsd.c main.c
# List THUMB-mode C sources here # List THUMB-mode C sources here
# NOTE: If any module is compiled in thumb mode then -mthumb-interwork is # NOTE: If any module is compiled in thumb mode then -mthumb-interwork is
@ -99,7 +102,7 @@ TOPT = -mthumb -D THUMB
# increases the code size. # increases the code size.
OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing
#OPT += -ffixed-r7 #OPT += -ffixed-r7
#OPT += -falign-functions=16 OPT += -falign-functions=16
# Define warning options here # Define warning options here
WARN = -Wall -Wstrict-prototypes WARN = -Wall -Wstrict-prototypes

View File

@ -67,12 +67,13 @@ ASRC = chcore.c
# List THUMB-mode C sources here # List THUMB-mode C sources here
# NOTE: If any module is compiled in thumb mode then -mthumb-interwork is # NOTE: If any module is compiled in thumb mode then -mthumb-interwork is
# enabled for all modules and that lowers performance. # enabled for all modules and that lowers performance.
TSRC = main.c buzzer.c mmcsd.c ../../src/lib/evtimer.c ../../test/test.c \ TSRC = ../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \
../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \
../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c \
../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \ ../../ports/ARM7-LPC214x/GCC/vic.c ../../ports/ARM7-LPC214x/GCC/lpc214x_serial.c \
../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \ ../../ports/ARM7-LPC214x/GCC/lpc214x_ssp.c \
../../src/chinit.c ../../src/chdebug.c ../../src/chlists.c ../../src/chdelta.c \ ../../src/lib/evtimer.c ../../test/test.c \
../../src/chschd.c ../../src/chthreads.c ../../src/chsem.c ../../src/chevents.c \ buzzer.c mmcsd.c main.c
../../src/chmsg.c ../../src/chsleep.c ../../src/chqueues.c ../../src/chserial.c
# List ASM source files here # List ASM source files here
ASMSRC = crt0.s chcore2.s ASMSRC = crt0.s chcore2.s
@ -99,7 +100,7 @@ TOPT = -mthumb -D THUMB
# increases the code size. # increases the code size.
OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing OPT = -O2 -ggdb -fomit-frame-pointer -fno-strict-aliasing
#OPT += -ffixed-r7 #OPT += -ffixed-r7
#OPT += -falign-functions=16 OPT += -falign-functions=16
# Define warning options here # Define warning options here
WARN = -Wall -Wstrict-prototypes WARN = -Wall -Wstrict-prototypes

View File

@ -25,8 +25,13 @@
#include "buzzer.h" #include "buzzer.h"
#include "evtimer.h" #include "evtimer.h"
static BYTE8 waThread1[UserStackSize(32)]; static BYTE8 waIdleThread[UserStackSize(16)];
static t_msg IdleThread(void *arg) {
chSysPause();
}
static BYTE8 waThread1[UserStackSize(32)];
static t_msg Thread1(void *arg) { static t_msg Thread1(void *arg) {
while (TRUE) { while (TRUE) {
@ -43,7 +48,6 @@ static t_msg Thread1(void *arg) {
} }
static BYTE8 waThread2[UserStackSize(32)]; static BYTE8 waThread2[UserStackSize(32)];
static t_msg Thread2(void *arg) { static t_msg Thread2(void *arg) {
while (TRUE) { while (TRUE) {
@ -94,7 +98,7 @@ static void RemoveHandler(t_eventid id) {
PlaySoundWait(1000, 100); PlaySoundWait(1000, 100);
} }
static BYTE8 waThread3[UserStackSize(256)]; /*static BYTE8 waThread3[UserStackSize(256)];*/
static EvTimer evt; static EvTimer evt;
static t_evhandler evhndl[] = { static t_evhandler evhndl[] = {
TimerHandler, TimerHandler,
@ -102,7 +106,7 @@ static t_evhandler evhndl[] = {
RemoveHandler RemoveHandler
}; };
static t_msg Thread3(void *arg) { /*static t_msg Thread3(void *arg) {
struct EventListener el0, el1, el2; struct EventListener el0, el1, el2;
evtInit(&evt, 500); evtInit(&evt, 500);
@ -114,20 +118,51 @@ static t_msg Thread3(void *arg) {
while (TRUE) while (TRUE)
chEvtWait(ALL_EVENTS, evhndl); chEvtWait(ALL_EVENTS, evhndl);
return 0; return 0;
} }*/
int main(int argc, char **argv) { int main(int argc, char **argv) {
struct EventListener el0, el1, el2;
chSysInit();
/* /*
* If a button is pressed during the reset then the blinking leds are not * The main() function becomes a thread here, ChibiOS/RT goes live.
* started in order to make accurate benchmarks. */
chSysInit();
/*
* This thread has the lowest priority in the system, its role is just to
* execute the chSysPause() and serve interrupts in its context.
* In ChibiOS/RT at least one thread in the system *must* execute
* chThdPause(), it can be done in a dedicated thread or in the main()
* function (that would never exit the call).
*/
chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), IdleThread, NULL);
/*
* If a button is pressed during the reset then the blinking leds threads
* are not started in order to make accurate benchmarks.
*/ */
if ((IO0PIN & 0x00018000) == 0x00018000) { if ((IO0PIN & 0x00018000) == 0x00018000) {
chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL); chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL);
chThdCreate(NORMALPRIO, 0, waThread2, sizeof(waThread2), Thread2, NULL); chThdCreate(NORMALPRIO, 0, waThread2, sizeof(waThread2), Thread2, NULL);
} }
chThdCreate(NORMALPRIO, 0, waThread3, sizeof(waThread3), Thread3, NULL);
chSysPause(); /*
* Allows the other threads to run by lowering the priority, remember,
* the priority is set to the maximum in the \p chSysInit().
*/
chThdSetPriority(NORMALPRIO);
/*
* Normal main() activity, in this demo it server events incoming from
* various sources.
*/
evtInit(&evt, 500); /* Initializes an event timer object. */
evtRegister(&evt, &el0, 0); /* Registers on the timer event source. */
evtStart(&evt); /* Starts the event timer. */
mmcStartPolling(); /* Starts the MMC connector polling. */
chEvtRegister(&MMCInsertEventSource, &el1, 1);
chEvtRegister(&MMCRemoveEventSource, &el2, 2);
while (TRUE) /* Just serve events. */
chEvtWait(ALL_EVENTS, evhndl);
return 0; return 0;
} }

View File

@ -38,6 +38,21 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
*** Releases *** *** Releases ***
***************************************************************************** *****************************************************************************
*** 0.4.1 ***
- Cleaned up the LPC2148 demo in main.c, it is now well documented and
explains everything, I assumed too much stuff to be "obvious".
- Included a Makefile in the LPC2148 demo that builds in THUMB mode.
- 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. No .xls available, ODF only.
- 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, unpredictabilty
is bad for a RTOS. This option however increases the code size slightly
because of alignment gaps.
- Fine tuning in the scheduler code for improved performance.
*** 0.4.0 *** *** 0.4.0 ***
- NEW, added a benchmark functionality to the test suite. The benchmark - NEW, added a benchmark functionality to the test suite. The benchmark
measures the kernel throughput as messages per second and context switches measures the kernel throughput as messages per second and context switches

View File

@ -27,7 +27,6 @@
/** @cond never*/ /** @cond never*/
static ReadyList rlist; static ReadyList rlist;
static t_cnt preempt;
#ifndef CH_CURRP_REGISTER_CACHE #ifndef CH_CURRP_REGISTER_CACHE
Thread *currp; Thread *currp;
@ -47,7 +46,7 @@ void chSchInit(void) {
fifo_init(&rlist.r_queue); fifo_init(&rlist.r_queue);
rlist.r_prio = ABSPRIO; rlist.r_prio = ABSPRIO;
preempt = CH_TIME_QUANTUM; rlist.r_preempt = CH_TIME_QUANTUM;
#ifdef CH_USE_SYSTEMTIME #ifdef CH_USE_SYSTEMTIME
stime = 0; stime = 0;
#endif #endif
@ -89,7 +88,7 @@ static void nextready(void) {
Thread *otp = currp; Thread *otp = currp;
(currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR; (currp = fifo_remove(&rlist.r_queue))->p_state = PRCURR;
preempt = CH_TIME_QUANTUM; rlist.r_preempt = CH_TIME_QUANTUM;
#ifdef CH_USE_DEBUG #ifdef CH_USE_DEBUG
chDbgTrace(otp, currp); chDbgTrace(otp, currp);
#endif #endif
@ -131,7 +130,7 @@ void chSchWakeupS(Thread *ntp, t_msg msg) {
chSchReadyI(otp); chSchReadyI(otp);
(currp = ntp)->p_state = PRCURR; (currp = ntp)->p_state = PRCURR;
ntp->p_rdymsg = msg; ntp->p_rdymsg = msg;
preempt = CH_TIME_QUANTUM; rlist.r_preempt = CH_TIME_QUANTUM;
#ifdef CH_USE_DEBUG #ifdef CH_USE_DEBUG
chDbgTrace(otp, ntp); chDbgTrace(otp, ntp);
#endif #endif
@ -172,7 +171,7 @@ BOOL chSchRescRequiredI(void) {
if (isempty(&rlist.r_queue)) if (isempty(&rlist.r_queue))
return FALSE; return FALSE;
if (preempt) { if (rlist.r_preempt) {
if (firstprio(&rlist.r_queue) <= currp->p_prio) if (firstprio(&rlist.r_queue) <= currp->p_prio)
return FALSE; return FALSE;
} }
@ -191,8 +190,8 @@ BOOL chSchRescRequiredI(void) {
*/ */
void chSchTimerHandlerI(void) { void chSchTimerHandlerI(void) {
if (preempt) if (rlist.r_preempt)
preempt--; rlist.r_preempt--;
#ifdef CH_USE_SYSTEMTIME #ifdef CH_USE_SYSTEMTIME
stime++; stime++;

View File

@ -38,8 +38,9 @@
* Ready list header. * Ready list header.
*/ */
typedef struct { typedef struct {
ThreadsQueue r_queue; ThreadsQueue r_queue;
t_prio r_prio; t_prio r_prio;
t_cnt r_preempt;
} ReadyList; } ReadyList;
/* /*