aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/ARMCM4-STM32F303-DISCOVERY/chconf.h6
-rw-r--r--os/hal/osal/chibios/osal.c4
-rw-r--r--os/rt/include/ch.h2
-rw-r--r--os/rt/include/chglobal.h144
-rw-r--r--os/rt/include/chmtx.h9
-rw-r--r--os/rt/include/chthreads.h352
-rw-r--r--os/rt/src/chthreads.c8
-rw-r--r--test/test.c4
-rw-r--r--test/testbmk.c46
-rw-r--r--test/testdyn.c6
-rw-r--r--test/testevt.c10
-rw-r--r--test/testmsg.c4
-rw-r--r--test/testmtx.c60
-rw-r--r--test/testqueues.c4
-rw-r--r--test/testsem.c18
-rw-r--r--test/testthd.c42
16 files changed, 370 insertions, 349 deletions
diff --git a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h
index 0bf8693a1..73e398e4f 100644
--- a/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h
+++ b/demos/ARMCM4-STM32F303-DISCOVERY/chconf.h
@@ -41,7 +41,7 @@
* setting also defines the system tick time unit.
*/
#if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXYGEN__)
-#define CH_CFG_ST_FREQUENCY 10000
+#define CH_CFG_ST_FREQUENCY 1000
#endif
/**
@@ -62,7 +62,7 @@
* this value.
*/
#if !defined(CH_CFG_TIMEDELTA) || defined(__DOXYGEN__)
-#define CH_CFG_TIMEDELTA 2
+#define CH_CFG_TIMEDELTA 0
#endif
/**
@@ -441,7 +441,7 @@
* tickless mode.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
-#define CH_DBG_THREADS_PROFILING FALSE
+#define CH_DBG_THREADS_PROFILING TRUE
#endif
/** @} */
diff --git a/os/hal/osal/chibios/osal.c b/os/hal/osal/chibios/osal.c
index 65912ce7e..da3746eaf 100644
--- a/os/hal/osal/chibios/osal.c
+++ b/os/hal/osal/chibios/osal.c
@@ -98,9 +98,9 @@ msg_t osalThreadSuspendS(thread_reference_t *trp) {
chDbgAssert(*trp == NULL, "not NULL");
- *trp = (thread_reference_t)chThdSelf();
+ *trp = (thread_reference_t)chThdGetSelfX();
chSchGoSleepS(CH_STATE_SUSPENDED);
- return chThdSelf()->p_msg;
+ return chThdGetSelfX()->p_msg;
}
/**
diff --git a/os/rt/include/ch.h b/os/rt/include/ch.h
index 6af6b8d4d..3e3b90983 100644
--- a/os/rt/include/ch.h
+++ b/os/rt/include/ch.h
@@ -114,9 +114,9 @@ typedef struct virtual_timer virtual_timer_t;
#include "chsys.h"
#include "chglobal.h"
#include "chvt.h"
-#include "chthreads.h"
#include "chlists.h"
#include "chschd.h"
+#include "chthreads.h"
#include "chregistry.h"
#include "chsem.h"
#include "chbsem.h"
diff --git a/os/rt/include/chglobal.h b/os/rt/include/chglobal.h
index 0d49d9a45..9803aa8fb 100644
--- a/os/rt/include/chglobal.h
+++ b/os/rt/include/chglobal.h
@@ -48,7 +48,6 @@
* @brief Generic threads single link list, it works like a stack.
*/
typedef struct {
-
thread_t *p_next; /**< @brief Next in the list/queue. */
} threads_list_t;
@@ -83,6 +82,149 @@ typedef struct {
} ready_list_t;
/**
+ * @extends threads_queue_t
+ *
+ * @brief Structure representing a thread.
+ * @note Not all the listed fields are always needed, by switching off some
+ * not needed ChibiOS/RT subsystems it is possible to save RAM space
+ * by shrinking the @p thread_t structure.
+ */
+typedef struct thread {
+ thread_t *p_next; /**< @brief Next in the list/queue. */
+ /* End of the fields shared with the threads_list_t structure.*/
+ thread_t *p_prev; /**< @brief Previous in the queue. */
+ /* End of the fields shared with the threads_queue_t structure.*/
+ tprio_t p_prio; /**< @brief Thread priority. */
+ struct context p_ctx; /**< @brief Processor context. */
+#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+ thread_t *p_newer; /**< @brief Newer registry element. */
+ thread_t *p_older; /**< @brief Older registry element. */
+#endif
+ /* End of the fields shared with the ReadyList structure. */
+#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
+ /**
+ * @brief Thread name or @p NULL.
+ */
+ const char *p_name;
+#endif
+#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
+ /**
+ * @brief Thread stack boundary.
+ */
+ stkalign_t *p_stklimit;
+#endif
+ /**
+ * @brief Current thread state.
+ */
+ tstate_t p_state;
+ /**
+ * @brief Various thread flags.
+ */
+ tmode_t p_flags;
+#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
+ /**
+ * @brief References to this thread.
+ */
+ trefs_t p_refs;
+#endif
+ /**
+ * @brief Number of ticks remaining to this thread.
+ */
+#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
+ tslices_t p_preempt;
+#endif
+#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
+ /**
+ * @brief Thread consumed time in ticks.
+ * @note This field can overflow.
+ */
+ volatile systime_t p_time;
+#endif
+ /**
+ * @brief State-specific fields.
+ * @note All the fields declared in this union are only valid in the
+ * specified state or condition and are thus volatile.
+ */
+ union {
+ /**
+ * @brief Thread wakeup code.
+ * @note This field contains the low level message sent to the thread
+ * by the waking thread or interrupt handler. The value is valid
+ * after exiting the @p chSchWakeupS() function.
+ */
+ msg_t rdymsg;
+ /**
+ * @brief Thread exit code.
+ * @note The thread termination code is stored in this field in order
+ * to be retrieved by the thread performing a @p chThdWait() on
+ * this thread.
+ */
+ msg_t exitcode;
+ /**
+ * @brief Pointer to a generic "wait" object.
+ * @note This field is used to get a generic pointer to a synchronization
+ * object and is valid when the thread is in one of the wait
+ * states.
+ */
+ void *wtobjp;
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+ /**
+ * @brief Enabled events mask.
+ * @note This field is only valid while the thread is in the
+ * @p CH_STATE_WTOREVT or @p CH_STATE_WTANDEVT states.
+ */
+ eventmask_t ewmask;
+#endif
+ } p_u;
+#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
+ /**
+ * @brief Termination waiting list.
+ */
+ threads_list_t p_waiting;
+#endif
+#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
+ /**
+ * @brief Messages queue.
+ */
+ threads_queue_t p_msgqueue;
+ /**
+ * @brief Thread message.
+ */
+ msg_t p_msg;
+#endif
+#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
+ /**
+ * @brief Pending events mask.
+ */
+ eventmask_t p_epending;
+#endif
+#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
+ /**
+ * @brief List of the mutexes owned by this thread.
+ * @note The list is terminated by a @p NULL in this field.
+ */
+ struct mutex *p_mtxlist;
+ /**
+ * @brief Thread's own, non-inherited, priority.
+ */
+ tprio_t p_realprio;
+#endif
+#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
+ /**
+ * @brief Memory Pool where the thread workspace is returned.
+ */
+ void *p_mpool;
+#endif
+#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
+ time_measurement_t p_stats;
+#endif
+#if defined(CH_CFG_THREAD_EXTRA_FIELDS)
+ /* Extra fields defined in chconf.h.*/
+ CH_CFG_THREAD_EXTRA_FIELDS
+#endif
+} thread_t;
+
+/**
* @brief Virtual timers list header.
* @note The timers list is implemented as a double link bidirectional list
* in order to make the unlink time constant, the reset of a virtual
diff --git a/os/rt/include/chmtx.h b/os/rt/include/chmtx.h
index a4ff5e49f..0444d936c 100644
--- a/os/rt/include/chmtx.h
+++ b/os/rt/include/chmtx.h
@@ -48,16 +48,21 @@
/*===========================================================================*/
/**
+ * @brief Type of a mutex structure.
+ */
+typedef struct mutex mutex_t;
+
+/**
* @brief Mutex structure.
*/
-typedef struct mutex {
+struct mutex {
threads_queue_t m_queue; /**< @brief Queue of the threads sleeping
on this mutex. */
thread_t *m_owner; /**< @brief Owner @p thread_t pointer or
@p NULL. */
mutex_t *m_next; /**< @brief Next @p mutex_t into an
owner-list or @p NULL. */
-} mutex_t;
+};
/*===========================================================================*/
/* Module macros. */
diff --git a/os/rt/include/chthreads.h b/os/rt/include/chthreads.h
index 22f499edf..d27de04a9 100644
--- a/os/rt/include/chthreads.h
+++ b/os/rt/include/chthreads.h
@@ -39,22 +39,23 @@
*/
#define CH_STATE_READY 0 /**< @brief Waiting on the ready list. */
#define CH_STATE_CURRENT 1 /**< @brief Currently running. */
-#define CH_STATE_SUSPENDED 2 /**< @brief Created in suspended state. */
-#define CH_STATE_WTSEM 3 /**< @brief Waiting on a semaphore. */
-#define CH_STATE_WTMTX 4 /**< @brief Waiting on a mutex. */
-#define CH_STATE_WTCOND 5 /**< @brief Waiting on a condition
+#define CH_STATE_WTSTART 2 /**< @brief Created but not started. */
+#define CH_STATE_SUSPENDED 3 /**< @brief Created in suspended state. */
+#define CH_STATE_WTSEM 4 /**< @brief Waiting on a semaphore. */
+#define CH_STATE_WTMTX 5 /**< @brief Waiting on a mutex. */
+#define CH_STATE_WTCOND 6 /**< @brief Waiting on a condition
variable. */
-#define CH_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep()
+#define CH_STATE_SLEEPING 7 /**< @brief Waiting in @p chThdSleep()
or @p chThdSleepUntil(). */
-#define CH_STATE_WTEXIT 7 /**< @brief Waiting in @p chThdWait(). */
-#define CH_STATE_WTOREVT 8 /**< @brief Waiting for an event. */
-#define CH_STATE_WTANDEVT 9 /**< @brief Waiting for several events. */
-#define CH_STATE_SNDMSGQ 10 /**< @brief Sending a message, in queue.*/
-#define CH_STATE_SNDMSG 11 /**< @brief Sent a message, waiting
+#define CH_STATE_WTEXIT 8 /**< @brief Waiting in @p chThdWait(). */
+#define CH_STATE_WTOREVT 9 /**< @brief Waiting for an event. */
+#define CH_STATE_WTANDEVT 10 /**< @brief Waiting for several events. */
+#define CH_STATE_SNDMSGQ 11 /**< @brief Sending a message, in queue.*/
+#define CH_STATE_SNDMSG 12 /**< @brief Sent a message, waiting
answer. */
-#define CH_STATE_WTMSG 12 /**< @brief Waiting for a message. */
-#define CH_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */
-#define CH_STATE_FINAL 14 /**< @brief Thread terminated. */
+#define CH_STATE_WTMSG 13 /**< @brief Waiting for a message. */
+#define CH_STATE_WTQUEUE 14 /**< @brief Waiting on an I/O queue. */
+#define CH_STATE_FINAL 15 /**< @brief Thread terminated. */
/**
* @brief Thread states as array of strings.
@@ -62,9 +63,9 @@
* indexed using the numeric thread state values.
*/
#define CH_STATE_NAMES \
- "READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \
- "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \
- "FINAL"
+ "READY", "WTSTART", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", \
+ "SLEEPING", "WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", \
+ "WTMSG", "WTQUEUE", "FINAL"
/** @} */
/**
@@ -92,154 +93,6 @@
/* Module data structures and types. */
/*===========================================================================*/
-/* Forward declaration required by the mutexes stack structure present
- in every thread.*/
-#if CH_CFG_USE_MUTEXES
-typedef struct mutex mutex_t;
-#endif
-
-/**
- * @extends threads_queue_t
- *
- * @brief Structure representing a thread.
- * @note Not all the listed fields are always needed, by switching off some
- * not needed ChibiOS/RT subsystems it is possible to save RAM space
- * by shrinking the @p thread_t structure.
- */
-typedef struct thread {
- thread_t *p_next; /**< @brief Next in the list/queue. */
- /* End of the fields shared with the threads_list_t structure.*/
- thread_t *p_prev; /**< @brief Previous in the queue. */
- /* End of the fields shared with the threads_queue_t structure.*/
- tprio_t p_prio; /**< @brief Thread priority. */
- struct context p_ctx; /**< @brief Processor context. */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
- thread_t *p_newer; /**< @brief Newer registry element. */
- thread_t *p_older; /**< @brief Older registry element. */
-#endif
- /* End of the fields shared with the ReadyList structure. */
-#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
- /**
- * @brief Thread name or @p NULL.
- */
- const char *p_name;
-#endif
-#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
- /**
- * @brief Thread stack boundary.
- */
- stkalign_t *p_stklimit;
-#endif
- /**
- * @brief Current thread state.
- */
- tstate_t p_state;
- /**
- * @brief Various thread flags.
- */
- tmode_t p_flags;
-#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
- /**
- * @brief References to this thread.
- */
- trefs_t p_refs;
-#endif
- /**
- * @brief Number of ticks remaining to this thread.
- */
-#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
- tslices_t p_preempt;
-#endif
-#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
- /**
- * @brief Thread consumed time in ticks.
- * @note This field can overflow.
- */
- volatile systime_t p_time;
-#endif
- /**
- * @brief State-specific fields.
- * @note All the fields declared in this union are only valid in the
- * specified state or condition and are thus volatile.
- */
- union {
- /**
- * @brief Thread wakeup code.
- * @note This field contains the low level message sent to the thread
- * by the waking thread or interrupt handler. The value is valid
- * after exiting the @p chSchWakeupS() function.
- */
- msg_t rdymsg;
- /**
- * @brief Thread exit code.
- * @note The thread termination code is stored in this field in order
- * to be retrieved by the thread performing a @p chThdWait() on
- * this thread.
- */
- msg_t exitcode;
- /**
- * @brief Pointer to a generic "wait" object.
- * @note This field is used to get a generic pointer to a synchronization
- * object and is valid when the thread is in one of the wait
- * states.
- */
- void *wtobjp;
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
- /**
- * @brief Enabled events mask.
- * @note This field is only valid while the thread is in the
- * @p CH_STATE_WTOREVT or @p CH_STATE_WTANDEVT states.
- */
- eventmask_t ewmask;
-#endif
- } p_u;
-#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
- /**
- * @brief Termination waiting list.
- */
- threads_list_t p_waiting;
-#endif
-#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
- /**
- * @brief Messages queue.
- */
- threads_queue_t p_msgqueue;
- /**
- * @brief Thread message.
- */
- msg_t p_msg;
-#endif
-#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
- /**
- * @brief Pending events mask.
- */
- eventmask_t p_epending;
-#endif
-#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
- /**
- * @brief List of the mutexes owned by this thread.
- * @note The list is terminated by a @p NULL in this field.
- */
- mutex_t *p_mtxlist;
- /**
- * @brief Thread's own, non-inherited, priority.
- */
- tprio_t p_realprio;
-#endif
-#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
- /**
- * @brief Memory Pool where the thread workspace is returned.
- */
- void *p_mpool;
-#endif
-#if CH_DBG_STATISTICS || defined(__DOXYGEN__)
- time_measurement_t p_stats;
-#endif
-#if defined(CH_CFG_THREAD_EXTRA_FIELDS)
- /* Extra fields defined in chconf.h.*/
- CH_CFG_THREAD_EXTRA_FIELDS
-#endif
-} thread_t;
/**
* @brief Thread function.
@@ -255,80 +108,6 @@ typedef msg_t (*tfunc_t)(void *);
* @{
*/
/**
- * @brief Returns a pointer to the current @p thread_t.
- * @note Can be invoked in any context.
- *
- * @special
- */
-#define chThdSelf() currp
-
-/**
- * @brief Returns the current thread priority.
- * @note Can be invoked in any context.
- *
- * @special
- */
-#define chThdGetPriority() (currp->p_prio)
-
-/**
- * @brief Returns the number of ticks consumed by the specified thread.
- * @note This function is only available when the
- * @p CH_DBG_THREADS_PROFILING configuration option is enabled.
- * @note Can be invoked in any context.
- *
- * @param[in] tp pointer to the thread
- *
- * @special
- */
-#define chThdGetTicks(tp) ((tp)->p_time)
-
-/**
- * @brief Verifies if the specified thread is in the @p CH_STATE_FINAL state.
- * @note Can be invoked in any context.
- *
- * @param[in] tp pointer to the thread
- * @retval true thread terminated.
- * @retval false thread not terminated.
- *
- * @special
- */
-#define chThdTerminated(tp) ((tp)->p_state == CH_STATE_FINAL)
-
-/**
- * @brief Verifies if the current thread has a termination request pending.
- * @note Can be invoked in any context.
- *
- * @retval true termination request pending.
- * @retval false termination request not pending.
- *
- * @special
- */
-#define chThdShouldTerminate() (currp->p_flags & CH_FLAG_TERMINATE)
-
-/**
- * @brief Resumes a thread created with @p chThdCreateI().
- *
- * @param[in] tp pointer to the thread
- *
- * @iclass
- */
-#define chThdResumeI(tp) chSchReadyI(tp)
-
-/**
- * @brief Suspends the invoking thread for the specified time.
- *
- * @param[in] time the delay in system ticks, the special values are
- * handled as follow:
- * - @a TIME_INFINITE the thread enters an infinite sleep
- * state.
- * - @a TIME_IMMEDIATE this value is not allowed.
- * .
- *
- * @sclass
- */
-#define chThdSleepS(time) chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time)
-
-/**
* @brief Delays the invoking thread for the specified number of seconds.
* @note The specified time is rounded up to a value allowed by the real
* system tick clock.
@@ -401,6 +180,103 @@ extern "C" {
/* Module inline functions. */
/*===========================================================================*/
+ /**
+ * @brief Returns a pointer to the current @p thread_t.
+ *
+ * @xclass
+ */
+static inline thread_t *chThdGetSelfX(void) {
+
+ return ch.rlist.r_current;
+}
+
+/**
+ * @brief Returns the current thread priority.
+ * @note Can be invoked in any context.
+ *
+ * @xclass
+ */
+static inline tprio_t chThdGetPriorityX(void) {
+
+ return chThdGetSelfX()->p_prio;
+}
+
+/**
+ * @brief Returns the number of ticks consumed by the specified thread.
+ * @note This function is only available when the
+ * @p CH_DBG_THREADS_PROFILING configuration option is enabled.
+ *
+ * @param[in] tp pointer to the thread
+ *
+ * @xclass
+ */
+#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
+static inline systime_t chThdGetTicksX(thread_t *tp) {
+
+ return tp->p_time;
+}
+#endif
+
+/**
+ * @brief Verifies if the specified thread is in the @p CH_STATE_FINAL state.
+ *
+ * @param[in] tp pointer to the thread
+ * @retval true thread terminated.
+ * @retval false thread not terminated.
+ *
+ * @xclass
+ */
+static inline bool chThdTerminatedX(thread_t *tp) {
+
+ return (bool)(tp->p_state == CH_STATE_FINAL);
+}
+
+/**
+ * @brief Verifies if the current thread has a termination request pending.
+ *
+ * @retval true termination request pending.
+ * @retval false termination request not pending.
+ *
+ * @xclass
+ */
+static inline bool chThdShouldTerminateX(void) {
+
+ return (bool)(chThdGetSelfX()->p_flags & CH_FLAG_TERMINATE);
+}
+
+/**
+ * @brief Resumes a thread created with @p chThdCreateI().
+ *
+ * @param[in] tp pointer to the thread
+ *
+ * @xclass
+ */
+static inline thread_t *chThdStartI(thread_t *tp) {
+
+ chDbgAssert(tp->p_state == CH_STATE_WTSTART, "wrong state");
+
+ return chSchReadyI(tp);
+}
+
+/**
+ * @brief Suspends the invoking thread for the specified time.
+ *
+ * @param[in] time the delay in system ticks, the special values are
+ * handled as follow:
+ * - @a TIME_INFINITE the thread enters an infinite sleep
+ * state.
+ * - @a TIME_IMMEDIATE this value is not allowed.
+ * .
+ *
+ * @sclass
+ */
+static inline void chThdSleepS(systime_t time) {
+
+ chDbgCheck(time != TIME_IMMEDIATE);
+
+ chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time);
+}
+
#endif /* _CHTHREADS_H_ */
/** @} */
diff --git a/os/rt/src/chthreads.c b/os/rt/src/chthreads.c
index 073b6eed7..d6fbc880f 100644
--- a/os/rt/src/chthreads.c
+++ b/os/rt/src/chthreads.c
@@ -93,7 +93,7 @@
thread_t *_thread_init(thread_t *tp, tprio_t prio) {
tp->p_prio = prio;
- tp->p_state = CH_STATE_SUSPENDED;
+ tp->p_state = CH_STATE_WTSTART;
tp->p_flags = CH_FLAG_MODE_STATIC;
#if CH_CFG_TIME_QUANTUM > 0
tp->p_preempt = CH_CFG_TIME_QUANTUM;
@@ -153,9 +153,9 @@ void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
/**
* @brief Creates a new thread into a static memory area.
* @details The new thread is initialized but not inserted in the ready list,
- * the initial state is @p CH_STATE_SUSPENDED.
+ * the initial state is @p CH_STATE_WTSTART.
* @post The initialized thread can be subsequently started by invoking
- * @p chThdResume(), @p chThdResumeI() or @p chSchWakeupS()
+ * @p chThdStart(), @p chThdStartI() or @p chSchWakeupS()
* depending on the execution context.
* @note A thread can terminate by calling @p chThdExit() or by simply
* returning from its main function.
@@ -310,8 +310,6 @@ void chThdTerminate(thread_t *tp) {
*/
void chThdSleep(systime_t time) {
- chDbgCheck(time != TIME_IMMEDIATE);
-
chSysLock();
chThdSleepS(time);
chSysUnlock();
diff --git a/test/test.c b/test/test.c
index f88b402a7..77759f5b8 100644
--- a/test/test.c
+++ b/test/test.c
@@ -224,10 +224,10 @@ void test_wait_threads(void) {
void test_cpu_pulse(unsigned duration) {
systime_t start, end, now;
- start = chThdSelf()->p_time;
+ start = chThdGetTicksX(chThdGetSelfX());
end = start + MS2ST(duration);
do {
- now = chThdSelf()->p_time;
+ now = chThdGetTicksX(chThdGetSelfX());
#if defined(SIMULATOR)
ChkIntSources();
#endif
diff --git a/test/testbmk.c b/test/testbmk.c
index 4ce953163..5149323a6 100644
--- a/test/testbmk.c
+++ b/test/testbmk.c
@@ -105,7 +105,7 @@ static unsigned int msg_loop_test(thread_t *tp) {
static void bmk1_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -134,7 +134,7 @@ ROMCONST struct testcase testbmk1 = {
static void bmk2_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -169,11 +169,11 @@ static msg_t thread2(void *p) {
static void bmk3_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2, NULL);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2, NULL);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-4, thread2, NULL);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-5, thread2, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2, NULL);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2, NULL);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-4, thread2, NULL);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-5, thread2, NULL);
n = msg_loop_test(threads[0]);
test_wait_threads();
test_print("--- Score : ");
@@ -202,7 +202,7 @@ ROMCONST struct testcase testbmk3 = {
msg_t thread4(void *p) {
msg_t msg;
- thread_t *self = chThdSelf();
+ thread_t *self = chThdGetSelfX();
(void)p;
chSysLock();
@@ -218,7 +218,7 @@ static void bmk4_execute(void) {
thread_t *tp;
uint32_t n;
- tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1,
+ tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1,
thread4, NULL);
n = 0;
test_wait_tick();
@@ -267,7 +267,7 @@ static void bmk5_execute(void) {
uint32_t n = 0;
void *wap = wa[0];
- tprio_t prio = chThdGetPriority() - 1;
+ tprio_t prio = chThdGetPriorityX() - 1;
test_wait_tick();
test_start_timer(1000);
do {
@@ -306,7 +306,7 @@ static void bmk6_execute(void) {
uint32_t n = 0;
void *wap = wa[0];
- tprio_t prio = chThdGetPriority() + 1;
+ tprio_t prio = chThdGetPriorityX() + 1;
test_wait_tick();
test_start_timer(1000);
do {
@@ -342,7 +342,7 @@ ROMCONST struct testcase testbmk6 = {
static msg_t thread3(void *p) {
(void)p;
- while (!chThdShouldTerminate())
+ while (!chThdShouldTerminateX())
chSemWait(&sem1);
return 0;
}
@@ -355,11 +355,11 @@ static void bmk7_setup(void) {
static void bmk7_execute(void) {
uint32_t n;
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread3, NULL);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+4, thread3, NULL);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread3, NULL);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+2, thread3, NULL);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+1, thread3, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread3, NULL);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+4, thread3, NULL);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread3, NULL);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+2, thread3, NULL);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+1, thread3, NULL);
n = 0;
test_wait_tick();
@@ -410,7 +410,7 @@ static msg_t thread8(void *p) {
#if defined(SIMULATOR)
ChkIntSources();
#endif
- } while(!chThdShouldTerminate());
+ } while(!chThdShouldTerminateX());
return 0;
}
@@ -420,11 +420,11 @@ static void bmk8_execute(void) {
n = 0;
test_wait_tick();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread8, (void *)&n);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread8, (void *)&n);
chThdSleepSeconds(1);
test_terminate_threads();
diff --git a/test/testdyn.c b/test/testdyn.c
index 7ba281e31..3eb3304d5 100644
--- a/test/testdyn.c
+++ b/test/testdyn.c
@@ -83,7 +83,7 @@ static void dyn1_setup(void) {
static void dyn1_execute(void) {
size_t n, sz;
void *p1;
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
(void)chHeapStatus(&heap1, &sz);
/* Starting threads from the heap. */
@@ -140,7 +140,7 @@ static void dyn2_setup(void) {
static void dyn2_execute(void) {
int i;
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
/* Adding the WAs to the pool. */
for (i = 0; i < 4; i++)
@@ -207,7 +207,7 @@ static void dyn3_setup(void) {
static void dyn3_execute(void) {
thread_t *tp;
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
/* Testing references increase/decrease and final detach.*/
tp = chThdCreateFromHeap(&heap1, WA_SIZE, prio-1, thread, "A");
diff --git a/test/testevt.c b/test/testevt.c
index bb9381139..49507f067 100644
--- a/test/testevt.c
+++ b/test/testevt.c
@@ -167,8 +167,8 @@ static void evt2_execute(void) {
*/
test_wait_tick();
target_time = chVTGetSystemTime() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
- thread1, chThdSelf());
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ thread1, chThdGetSelfX());
m = chEvtWaitOne(ALL_EVENTS);
test_assert_time_window(4, target_time, target_time + ALLOWED_DELAY);
test_assert(5, m == 1, "single event error");
@@ -190,8 +190,8 @@ static void evt2_execute(void) {
*/
test_wait_tick();
target_time = chVTGetSystemTime() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
- thread1, chThdSelf());
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
+ thread1, chThdGetSelfX());
m = chEvtWaitAny(ALL_EVENTS);
test_assert_time_window(9, target_time, target_time + ALLOWED_DELAY);
test_assert(10, m == 1, "single event error");
@@ -208,7 +208,7 @@ static void evt2_execute(void) {
chEvtRegisterMask(&es2, &el2, 4);
test_wait_tick();
target_time = chVTGetSystemTime() + MS2ST(50);
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
thread2, "A");
m = chEvtWaitAll(5);
test_assert_time_window(12, target_time, target_time + ALLOWED_DELAY);
diff --git a/test/testmsg.c b/test/testmsg.c
index 30d7f24dd..b3b2aedcd 100644
--- a/test/testmsg.c
+++ b/test/testmsg.c
@@ -71,8 +71,8 @@ static void msg1_execute(void) {
/*
* Testing the whole messages loop.
*/
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() + 1,
- thread, chThdSelf());
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() + 1,
+ thread, chThdGetSelfX());
tp = chMsgWait();
msg = chMsgGet(tp);
chMsgRelease(tp, msg);
diff --git a/test/testmtx.c b/test/testmtx.c
index c775cb51b..cd10fa986 100644
--- a/test/testmtx.c
+++ b/test/testmtx.c
@@ -96,7 +96,7 @@ static msg_t thread1(void *p) {
static void mtx1_execute(void) {
- tprio_t prio = chThdGetPriority(); /* Because priority inheritance.*/
+ tprio_t prio = chThdGetPriorityX(); /* Because priority inheritance.*/
chMtxLock(&m1);
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread1, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread1, "D");
@@ -105,7 +105,7 @@ static void mtx1_execute(void) {
threads[4] = chThdCreateStatic(wa[4], WA_SIZE, prio+5, thread1, "A");
chMtxUnlock();
test_wait_threads();
- test_assert(1, prio == chThdGetPriority(), "wrong priority level");
+ test_assert(1, prio == chThdGetPriorityX(), "wrong priority level");
test_assert_sequence(2, "ABCDE");
}
@@ -192,9 +192,9 @@ static void mtx2_execute(void) {
test_wait_tick();
time = chVTGetSystemTime();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-1, thread2H, 0);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-2, thread2M, 0);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread2L, 0);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-1, thread2H, 0);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-2, thread2M, 0);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread2L, 0);
test_wait_threads();
test_assert_sequence(1, "ABC");
test_assert_time_window(2, time + MS2ST(100), time + MS2ST(100) + ALLOWED_DELAY);
@@ -310,11 +310,11 @@ static void mtx3_execute(void) {
test_wait_tick();
time = chVTGetSystemTime();
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread3LL, 0);
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread3L, 0);
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread3M, 0);
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread3H, 0);
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread3HH, 0);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread3LL, 0);
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread3L, 0);
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread3M, 0);
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread3H, 0);
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread3HH, 0);
test_wait_threads();
test_assert_sequence(1, "ABCDE");
test_assert_time_window(2, time + MS2ST(110), time + MS2ST(110) + ALLOWED_DELAY);
@@ -365,46 +365,46 @@ static msg_t thread4b(void *p) {
static void mtx4_execute(void) {
tprio_t p, p1, p2;
- p = chThdGetPriority();
+ p = chThdGetPriorityX();
p1 = p + 1;
p2 = p + 2;
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "B");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "A");
chMtxLock(&m2);
- test_assert(1, chThdGetPriority() == p, "wrong priority level");
+ test_assert(1, chThdGetPriorityX() == p, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(2, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(2, chThdGetPriorityX() == p1, "wrong priority level");
chMtxLock(&m1);
- test_assert(3, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(3, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(4, chThdGetPriority() == p2, "wrong priority level");
+ test_assert(4, chThdGetPriorityX() == p2, "wrong priority level");
chMtxUnlock();
- test_assert(5, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(5, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(6, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(6, chThdGetPriorityX() == p1, "wrong priority level");
chMtxUnlockAll();
- test_assert(7, chThdGetPriority() == p, "wrong priority level");
+ test_assert(7, chThdGetPriorityX() == p, "wrong priority level");
test_wait_threads();
/* Test repeated in order to cover chMtxUnlockS().*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, p1, thread4a, "D");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, p2, thread4b, "C");
chMtxLock(&m2);
- test_assert(8, chThdGetPriority() == p, "wrong priority level");
+ test_assert(8, chThdGetPriorityX() == p, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(9, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(9, chThdGetPriorityX() == p1, "wrong priority level");
chMtxLock(&m1);
- test_assert(10, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(10, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(11, chThdGetPriority() == p2, "wrong priority level");
+ test_assert(11, chThdGetPriorityX() == p2, "wrong priority level");
chSysLock();
chMtxUnlockS();
chSysUnlock();
- test_assert(12, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(12, chThdGetPriorityX() == p1, "wrong priority level");
chThdSleepMilliseconds(100);
- test_assert(13, chThdGetPriority() == p1, "wrong priority level");
+ test_assert(13, chThdGetPriorityX() == p1, "wrong priority level");
chMtxUnlockAll();
- test_assert(14, chThdGetPriority() == p, "wrong priority level");
+ test_assert(14, chThdGetPriorityX() == p, "wrong priority level");
test_wait_threads();
}
@@ -434,7 +434,7 @@ static void mtx5_execute(void) {
bool_t b;
tprio_t prio;
- prio = chThdGetPriority();
+ prio = chThdGetPriorityX();
b = chMtxTryLock(&m1);
test_assert(1, b, "already locked");
@@ -448,7 +448,7 @@ static void mtx5_execute(void) {
test_assert(3, queue_isempty(&m1.m_queue), "queue not empty");
test_assert(4, m1.m_owner == NULL, "still owned");
- test_assert(5, chThdGetPriority() == prio, "wrong priority level");
+ test_assert(5, chThdGetPriorityX() == prio, "wrong priority level");
chMtxLock(&m1);
chMtxUnlockAll();
@@ -492,7 +492,7 @@ static msg_t thread10(void *p) {
static void mtx6_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C");
@@ -535,7 +535,7 @@ static void mtx7_setup(void) {
static void mtx7_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread10, "E");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "D");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread10, "C");
@@ -594,7 +594,7 @@ static msg_t thread12(void *p) {
static void mtx8_execute(void) {
- tprio_t prio = chThdGetPriority();
+ tprio_t prio = chThdGetPriorityX();
threads[0] = chThdCreateStatic(wa[0], WA_SIZE, prio+1, thread11, "A");
threads[1] = chThdCreateStatic(wa[1], WA_SIZE, prio+2, thread10, "C");
threads[2] = chThdCreateStatic(wa[2], WA_SIZE, prio+3, thread12, "B");
diff --git a/test/testqueues.c b/test/testqueues.c
index 6ef057f3a..0d1bcc872 100644
--- a/test/testqueues.c
+++ b/test/testqueues.c
@@ -138,7 +138,7 @@ static void queues1_execute(void) {
chIQResetI(&iq);
chSysUnlock();
test_assert_lock(11, chIQGetFullI(&iq) == 0, "still full");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread1, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread1, NULL);
test_assert_lock(12, chIQGetFullI(&iq) == 0, "not empty");
test_wait_threads();
@@ -203,7 +203,7 @@ static void queues2_execute(void) {
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
test_assert_lock(7, chOQIsFullI(&oq), "not full");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread2, NULL);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread2, NULL);
test_assert_lock(8, chOQGetFullI(&oq) == TEST_QUEUES_SIZE, "not empty");
test_wait_threads();
diff --git a/test/testsem.c b/test/testsem.c
index 0810300ea..0d74f3613 100644
--- a/test/testsem.c
+++ b/test/testsem.c
@@ -83,11 +83,11 @@ static msg_t thread1(void *p) {
static void sem1_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()+1, thread1, "B");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()+3, thread1, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()+4, thread1, "D");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()+2, thread1, "E");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()+1, thread1, "B");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()+3, thread1, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()+4, thread1, "D");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()+2, thread1, "E");
chSemSignal(&sem1);
chSemSignal(&sem1);
chSemSignal(&sem1);
@@ -99,7 +99,7 @@ static void sem1_execute(void) {
#else
test_assert_sequence(1, "ABCDE");
#endif
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+5, thread1, "A");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+5, thread1, "A");
chSysLock();
chSemAddCounterI(&sem1, 2);
chSysUnlock();
@@ -157,7 +157,7 @@ static void sem2_execute(void) {
/*
* Testing not timeout condition.
*/
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority() - 1,
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX() - 1,
thread2, 0);
msg = chSemWaitTimeout(&sem1, MS2ST(500));
test_wait_threads();
@@ -215,7 +215,7 @@ static msg_t thread3(void *p) {
static void sem3_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread3, 0);
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()+1, thread3, 0);
chSemSignalWait(&sem1, &sem1);
test_assert(1, queue_isempty(&sem1.s_queue), "queue not empty");
test_assert(2, sem1.s_cnt == 0, "counter not zero");
@@ -256,7 +256,7 @@ static void sem4_execute(void) {
/* Starts a signaler thread at a lower priority.*/
threads[0] = chThdCreateStatic(wa[0], WA_SIZE,
- chThdGetPriority()-1, thread4, &bsem);
+ chThdGetPriorityX()-1, thread4, &bsem);
/* Waits to be signaled.*/
chBSemWait(&bsem);
diff --git a/test/testthd.c b/test/testthd.c
index af71a2041..34de252a8 100644
--- a/test/testthd.c
+++ b/test/testthd.c
@@ -65,11 +65,11 @@ static msg_t thread(void *p) {
static void thd1_execute(void) {
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
- threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D");
+ threads[2] = chThdCreateStatic(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A");
test_wait_threads();
test_assert_sequence(1, "ABCDE");
}
@@ -93,13 +93,13 @@ ROMCONST struct testcase testthd1 = {
static void thd2_execute(void) {
- threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriority()-4, thread, "D");
- threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()-5, thread, "E");
- threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriority()-1, thread, "A");
- threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriority()-2, thread, "B");
+ threads[1] = chThdCreateStatic(wa[1], WA_SIZE, chThdGetPriorityX()-4, thread, "D");
+ threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriorityX()-5, thread, "E");
+ threads[4] = chThdCreateStatic(wa[4], WA_SIZE, chThdGetPriorityX()-1, thread, "A");
+ threads[3] = chThdCreateStatic(wa[3], WA_SIZE, chThdGetPriorityX()-2, thread, "B");
/* Done this way for coverage of chThdCreateI() and chThdResume().*/
chSysLock();
- threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriority()-3, thread, "C");
+ threads[2] = chThdCreateI(wa[2], WA_SIZE, chThdGetPriorityX()-3, thread, "C");
chSysUnlock();
chThdResume(threads[2]);
test_wait_threads();
@@ -126,47 +126,47 @@ ROMCONST struct testcase testthd2 = {
static void thd3_execute(void) {
tprio_t prio, p1;
- prio = chThdGetPriority();
+ prio = chThdGetPriorityX();
p1 = chThdSetPriority(prio + 1);
test_assert(1, p1 == prio,
"unexpected returned priority level");
- test_assert(2, chThdGetPriority() == prio + 1,
+ test_assert(2, chThdGetPriorityX() == prio + 1,
"unexpected priority level");
p1 = chThdSetPriority(p1);
test_assert(3, p1 == prio + 1,
"unexpected returned priority level");
- test_assert(4, chThdGetPriority() == prio,
+ test_assert(4, chThdGetPriorityX() == prio,
"unexpected priority level");
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
/* Simulates a priority boost situation (p_prio > p_realprio).*/
chSysLock();
- chThdSelf()->p_prio += 2;
+ chThdGetSelfX()->p_prio += 2;
chSysUnlock();
- test_assert(5, chThdGetPriority() == prio + 2,
+ test_assert(5, chThdGetPriorityX() == prio + 2,
"unexpected priority level");
/* Tries to raise but below the boost level. */
p1 = chThdSetPriority(prio + 1);
test_assert(6, p1 == prio,
"unexpected returned priority level");
- test_assert(7, chThdSelf()->p_prio == prio + 2,
+ test_assert(7, chThdGetSelfX()->p_prio == prio + 2,
"unexpected priority level");
- test_assert(8, chThdSelf()->p_realprio == prio + 1,
+ test_assert(8, chThdGetSelfX()->p_realprio == prio + 1,
"unexpected returned real priority level");
/* Tries to raise above the boost level. */
p1 = chThdSetPriority(prio + 3);
test_assert(9, p1 == prio + 1,
"unexpected returned priority level");
- test_assert(10, chThdSelf()->p_prio == prio + 3,
+ test_assert(10, chThdGetSelfX()->p_prio == prio + 3,
"unexpected priority level");
- test_assert(11, chThdSelf()->p_realprio == prio + 3,
+ test_assert(11, chThdGetSelfX()->p_realprio == prio + 3,
"unexpected real priority level");
chSysLock();
- chThdSelf()->p_prio = prio;
- chThdSelf()->p_realprio = prio;
+ chThdGetSelfX()->p_prio = prio;
+ chThdGetSelfX()->p_realprio = prio;
chSysUnlock();
#endif
}