aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-04 09:50:46 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-07-04 09:50:46 +0000
commite5bd63772994b9b9aa448c43870acf3580efaab7 (patch)
treec9915761bc280883b5dd1ff265ddbbac336aef7d
parent0b7254491c8d987d2d43b55b7699ba8ce7b42307 (diff)
downloadChibiOS-e5bd63772994b9b9aa448c43870acf3580efaab7.tar.gz
ChibiOS-e5bd63772994b9b9aa448c43870acf3580efaab7.tar.bz2
ChibiOS-e5bd63772994b9b9aa448c43870acf3580efaab7.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@332 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--demos/ARM7-LPC214x-GCC/main.c4
-rw-r--r--readme.txt4
-rw-r--r--src/chinit.c3
-rw-r--r--src/chthreads.c39
-rw-r--r--src/include/threads.h2
-rw-r--r--test/testbmk.c16
6 files changed, 52 insertions, 16 deletions
diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c
index 10cae19da..d83a386d5 100644
--- a/demos/ARM7-LPC214x-GCC/main.c
+++ b/demos/ARM7-LPC214x-GCC/main.c
@@ -131,8 +131,8 @@ int main(int argc, char **argv) {
* are not started in order to make accurate benchmarks.
*/
if ((IO0PIN & 0x00018000) == 0x00018000) {
- chThdCreate(NORMALPRIO, 0, waThread1, sizeof(waThread1), Thread1, NULL);
- chThdCreate(NORMALPRIO, 0, waThread2, sizeof(waThread2), Thread2, NULL);
+ chThdCreateFast(NORMALPRIO, waThread1, sizeof(waThread1), Thread1);
+ chThdCreateFast(NORMALPRIO, waThread2, sizeof(waThread2), Thread2);
}
/*
diff --git a/readme.txt b/readme.txt
index 51f0be398..5fbee71f4 100644
--- a/readme.txt
+++ b/readme.txt
@@ -75,10 +75,14 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
*****************************************************************************
*** 0.6.7 ***
+- NEW: New chThdCreateFast() API, it is a simplified form of chThdCreate()
+ that allows even faster threads creation. The new API does not support
+ the "mode" and "arg" parameters (still available in the old API).
- OPT: Removed an unrequired initialization from 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.
- Added the C++ wrapper entries to the documentation.
+- Fixed the documentation entry for the chThdCreate() API.
*** 0.6.6 ***
- NEW: Improved test suite, now the suite is divided in modules and the code
diff --git a/src/chinit.c b/src/chinit.c
index ec7626e6a..5b2c0cd24 100644
--- a/src/chinit.c
+++ b/src/chinit.c
@@ -55,7 +55,8 @@ void chSysInit(void) {
* serve interrupts in its context while keeping the lowest energy saving
* mode compatible with the system status.
*/
- chThdCreate(IDLEPRIO, 0, waIdleThread, sizeof(waIdleThread), (tfunc_t)_IdleThread, NULL);
+ chThdCreateFast(IDLEPRIO, waIdleThread,
+ sizeof(waIdleThread), (tfunc_t)_IdleThread);
}
/**
diff --git a/src/chthreads.c b/src/chthreads.c
index 33c75dd45..d12bced10 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -62,9 +62,8 @@ static void memfill(uint8_t *p, uint32_t n, uint8_t v) {
/**
* Creates a new thread.
* @param prio the priority level for the new thread. Usually the threads are
- * created with priority \p NORMALPRIO (128), priorities
- * can range from \p LOWPRIO (1) to \p HIGHPRIO
- * (255).
+ * created with priority \p NORMALPRIO, priorities
+ * can range from \p LOWPRIO to \p HIGHPRIO.
* @param mode the creation option flags for the thread. The following options
* can be OR'ed in this parameter:<br>
* <ul>
@@ -106,9 +105,7 @@ Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
else {
#endif
chSysLock();
-
chSchWakeupS(tp, RDY_OK);
-
chSysUnlock();
#ifdef CH_USE_RESUME
}
@@ -117,6 +114,38 @@ Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
}
/**
+ * Creates a new thread.
+ * @param prio the priority level for the new thread. Usually the threads are
+ * created with priority \p NORMALPRIO, priorities
+ * can range from \p LOWPRIO to \p HIGHPRIO.
+ * @param workspace pointer to a working area dedicated to the thread stack
+ * @param wsize size of the working area.
+ * @param pf the thread function. Returning from this function automatically
+ * terminates the thread.
+ * @return the pointer to the \p Thread structure allocated for the
+ * thread into the working space area.
+ * @note A thread can terminate by calling \p chThdExit() or by simply
+ * returning from its main function.
+ */
+Thread *chThdCreateFast(tprio_t prio, void *workspace,
+ size_t wsize, tfunc_t pf) {
+ Thread *tp = workspace;
+
+ chDbgAssert((wsize >= UserStackSize(0)) && (prio <= HIGHPRIO) &&
+ (workspace != NULL) && (pf != NULL),
+ "chthreads.c, chThdCreateFast()");
+#ifdef CH_USE_DEBUG
+ memfill(workspace, wsize, MEM_FILL_PATTERN);
+#endif
+ init_thread(prio, 0, tp);
+ SETUP_CONTEXT(workspace, wsize, pf, NULL);
+ chSysLock();
+ chSchWakeupS(tp, RDY_OK);
+ chSysUnlock();
+ return tp;
+}
+
+/**
* Changes the thread priority, reschedules if necessary.
* @param newprio the new priority of the invoking thread
*/
diff --git a/src/include/threads.h b/src/include/threads.h
index 297c56a68..5bfd51423 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -170,6 +170,8 @@ extern "C" {
#endif
Thread *chThdCreate(tprio_t prio, tmode_t mode, void *workspace,
size_t wsize, tfunc_t pf, void *arg);
+ Thread *chThdCreateFast(tprio_t prio, void *workspace,
+ size_t wsize, tfunc_t pf);
void chThdSetPriority(tprio_t newprio);
void chThdExit(msg_t msg);
#ifdef CH_USE_RESUME
diff --git a/test/testbmk.c b/test/testbmk.c
index 8631138d1..a75ccddc2 100644
--- a/test/testbmk.c
+++ b/test/testbmk.c
@@ -61,7 +61,7 @@ static void bmk1_teardown(void) {
static void bmk1_execute(void) {
uint32_t n;
- threads[0] = chThdCreate(chThdGetPriority()-1, 0, wa[0], STKSIZE, thread1, 0);
+ threads[0] = chThdCreateFast(chThdGetPriority()-1, wa[0], STKSIZE, thread1);
n = msg_loop_test(threads[0]);
chThdTerminate(threads[0]);
test_wait_threads();
@@ -93,7 +93,7 @@ static void bmk2_teardown(void) {
static void bmk2_execute(void) {
uint32_t n;
- threads[0] = chThdCreate(chThdGetPriority()+1, 0, wa[0], STKSIZE, thread1, 0);
+ threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], STKSIZE, thread1);
n = msg_loop_test(threads[0]);
chThdTerminate(threads[0]);
test_wait_threads();
@@ -130,11 +130,11 @@ static void bmk3_teardown(void) {
static void bmk3_execute(void) {
uint32_t n;
- threads[0] = chThdCreate(chThdGetPriority()+1, 0, wa[0], STKSIZE, thread1, 0);
- threads[1] = chThdCreate(chThdGetPriority()-2, 0, wa[1], STKSIZE, thread2, 0);
- threads[2] = chThdCreate(chThdGetPriority()-3, 0, wa[2], STKSIZE, thread2, 0);
- threads[3] = chThdCreate(chThdGetPriority()-4, 0, wa[3], STKSIZE, thread2, 0);
- threads[4] = chThdCreate(chThdGetPriority()-5, 0, wa[4], STKSIZE, thread2, 0);
+ threads[0] = chThdCreateFast(chThdGetPriority()+1, wa[0], STKSIZE, thread1);
+ threads[1] = chThdCreateFast(chThdGetPriority()-2, wa[1], STKSIZE, thread2);
+ threads[2] = chThdCreateFast(chThdGetPriority()-3, wa[2], STKSIZE, thread2);
+ threads[3] = chThdCreateFast(chThdGetPriority()-4, wa[3], STKSIZE, thread2);
+ threads[4] = chThdCreateFast(chThdGetPriority()-5, wa[4], STKSIZE, thread2);
n = msg_loop_test(threads[0]);
chThdTerminate(threads[0]);
test_wait_threads();
@@ -171,7 +171,7 @@ static void bmk4_execute(void) {
test_wait_tick();
test_start_timer(1000);
do {
- chThdWait(chThdCreate(prio, 0, wap, STKSIZE, thread2, NULL));
+ chThdWait(chThdCreateFast(prio, wap, STKSIZE, thread2));
n++;
#if defined(WIN32)
ChkIntSources();