aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-01-07 14:06:46 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-01-07 14:06:46 +0000
commitb1db8a9f7fe3bc2cd48c52e7c2c50e0e118f8889 (patch)
treec291c85d4435b20ee8f92d2726f74f7951ad1d52 /src
parent14d3b059c225769038a0f3538f491cf6099dbb3e (diff)
downloadChibiOS-b1db8a9f7fe3bc2cd48c52e7c2c50e0e118f8889.tar.gz
ChibiOS-b1db8a9f7fe3bc2cd48c52e7c2c50e0e118f8889.tar.bz2
ChibiOS-b1db8a9f7fe3bc2cd48c52e7c2c50e0e118f8889.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@166 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/chmsg.c21
-rw-r--r--src/include/threads.h2
-rw-r--r--src/templates/chconf.h5
3 files changed, 28 insertions, 0 deletions
diff --git a/src/chmsg.c b/src/chmsg.c
index 61546d7c1..20a59904e 100644
--- a/src/chmsg.c
+++ b/src/chmsg.c
@@ -36,7 +36,14 @@ t_msg chMsgSend(Thread *tp, t_msg msg) {
chSysLock();
+#ifdef CH_USE_MESSAGES_PRIORITY
+ if (tp->p_flags & P_MSGBYPRIO)
+ prio_insert(currp, &tp->p_msgqueue);
+ else
+ fifo_insert(currp, &tp->p_msgqueue);
+#else
fifo_insert(currp, &tp->p_msgqueue);
+#endif
currp->p_msg = msg;
if (tp->p_state == PRWTMSG)
chSchReadyI(tp, RDY_OK);
@@ -67,7 +74,14 @@ t_msg chMsgSendWithEvent(Thread *tp, t_msg msg, EventSource *esp) {
chSysLock();
chDbgAssert(tp->p_state != PRWTMSG, "chmsg.c, chMsgSendWithEvent()");
+#ifdef CH_USE_MESSAGES_PRIORITY
+ if (tp->p_flags & P_MSGBYPRIO)
+ prio_insert(currp, &tp->p_msgqueue);
+ else
+ fifo_insert(currp, &tp->p_msgqueue);
+#else
fifo_insert(currp, &tp->p_msgqueue);
+#endif
chEvtSendI(esp);
currp->p_msg = msg;
chSchGoSleepS(PRSNDMSG);
@@ -107,7 +121,14 @@ t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time) {
chSysLock();
chVTSetI(&vt, time, wakeup, currp);
+#ifdef CH_USE_MESSAGES_PRIORITY
+ if (tp->p_flags & P_MSGBYPRIO)
+ prio_insert(currp, &tp->p_msgqueue);
+ else
+ fifo_insert(currp, &tp->p_msgqueue);
+#else
fifo_insert(currp, &tp->p_msgqueue);
+#endif
if (tp->p_state == PRWTMSG)
chSchReadyI(tp, RDY_OK);
currp->p_msg = msg;
diff --git a/src/include/threads.h b/src/include/threads.h
index 50468e063..f451278cf 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -135,6 +135,8 @@ struct Thread {
#define P_TERMINATE 1
/** Thread option: Create suspended thread.*/
#define P_SUSPENDED 2
+/** Thread option: Serve messages by priority instead of FIFO order.*/
+#define P_MSGBYPRIO 4
/** Pseudo priority used by the ready list header, do not use.*/
#define NOPRIO 0
diff --git a/src/templates/chconf.h b/src/templates/chconf.h
index fb8ae6a69..d8e5f88da 100644
--- a/src/templates/chconf.h
+++ b/src/templates/chconf.h
@@ -108,6 +108,11 @@
* @note requires \p CH_USE_VIRTUAL_TIMERS.*/
#define CH_USE_MESSAGES_EVENT
+/** Configuration option: If enabled then the threads have an option to serve
+ * messages by priority instead of FIFO order.
+ * @note requires \p CH_USE_MESSAGES.*/
+#define CH_USE_MESSAGES_PRIORITY
+
/** Configuration option: if specified then the
* \p chThdGetExitEventSource() function is included in the kernel.
* @note requires \p CH_USE_MESSAGES.