Renamed Thread to thread_t.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@5995 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
gdisirio 2013-07-19 12:22:31 +00:00
parent 4245ba7659
commit 84e044f176
34 changed files with 215 additions and 217 deletions

View File

@ -422,7 +422,7 @@
/** /**
* @brief Debug option, threads profiling. * @brief Debug option, threads profiling.
* @details If enabled then a field is added to the @p Thread structure that * @details If enabled then a field is added to the @p thread_t structure that
* counts the system ticks occurred while executing the thread. * counts the system ticks occurred while executing the thread.
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
@ -444,7 +444,7 @@
/** /**
* @brief Threads descriptor structure extension. * @brief Threads descriptor structure extension.
* @details User fields added to the end of the @p Thread structure. * @details User fields added to the end of the @p thread_t structure.
*/ */
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) #if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \ #define THREAD_EXT_FIELDS \

View File

@ -102,7 +102,7 @@
/* Forward declaration of the thread structure, it is used in most /* Forward declaration of the thread structure, it is used in most
modules.*/ modules.*/
typedef struct Thread Thread; typedef struct thread thread_t;
/* Inclusion of all the kernel sub-headers.*/ /* Inclusion of all the kernel sub-headers.*/
#include "chconf.h" #include "chconf.h"

View File

@ -105,7 +105,7 @@
*/ */
typedef struct { typedef struct {
systime_t se_time; /**< @brief Time of the switch event. */ systime_t se_time; /**< @brief Time of the switch event. */
Thread *se_tp; /**< @brief Switched in thread. */ thread_t *se_tp; /**< @brief Switched in thread. */
void *se_wtobjp; /**< @brief Object where going to sleep.*/ void *se_wtobjp; /**< @brief Object where going to sleep.*/
uint8_t se_state; /**< @brief Switched out thread state. */ uint8_t se_state; /**< @brief Switched out thread state. */
} ch_swc_event_t; } ch_swc_event_t;
@ -232,7 +232,7 @@ extern "C" {
#endif #endif
#if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__) #if CH_DBG_ENABLE_TRACE || defined(__DOXYGEN__)
void _trace_init(void); void _trace_init(void);
void dbg_trace(Thread *otp); void dbg_trace(thread_t *otp);
#endif #endif
#if CH_DBG_ENABLED #if CH_DBG_ENABLED
extern const char *dbg_panic_msg; extern const char *dbg_panic_msg;

View File

@ -47,15 +47,15 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
Thread *chThdAddRef(Thread *tp); thread_t *chThdAddRef(thread_t *tp);
void chThdRelease(Thread *tp); void chThdRelease(thread_t *tp);
#if CH_USE_HEAP #if CH_USE_HEAP
Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg); tprio_t prio, tfunc_t pf, void *arg);
#endif #endif
#if CH_USE_MEMPOOLS #if CH_USE_MEMPOOLS
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg); tfunc_t pf, void *arg);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -43,7 +43,7 @@ struct EventListener {
EventListener *el_next; /**< @brief Next Event Listener EventListener *el_next; /**< @brief Next Event Listener
registered on the Event registered on the Event
Source. */ Source. */
Thread *el_listener; /**< @brief Thread interested in the thread_t *el_listener; /**< @brief Thread interested in the
Event Source. */ Event Source. */
eventmask_t el_mask; /**< @brief Event flags mask associated eventmask_t el_mask; /**< @brief Event flags mask associated
by the thread to the Event by the thread to the Event
@ -173,8 +173,8 @@ extern "C" {
eventmask_t chEvtAddEvents(eventmask_t mask); eventmask_t chEvtAddEvents(eventmask_t mask);
flagsmask_t chEvtGetAndClearFlags(EventListener *elp); flagsmask_t chEvtGetAndClearFlags(EventListener *elp);
flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp); flagsmask_t chEvtGetAndClearFlagsI(EventListener *elp);
void chEvtSignal(Thread *tp, eventmask_t mask); void chEvtSignal(thread_t *tp, eventmask_t mask);
void chEvtSignalI(Thread *tp, eventmask_t mask); void chEvtSignalI(thread_t *tp, eventmask_t mask);
void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags); void chEvtBroadcastFlags(EventSource *esp, flagsmask_t flags);
void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags); void chEvtBroadcastFlagsI(EventSource *esp, flagsmask_t flags);
void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask); void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask);

View File

@ -56,7 +56,7 @@
* *
* @param[in] name the name of the threads queue variable * @param[in] name the name of the threads queue variable
*/ */
#define _threads_queue_t_DATA(name) {(Thread *)&name, (Thread *)&name} #define _threads_queue_t_DATA(name) {(thread_t *)&name, (thread_t *)&name}
/** /**
* @brief Static threads queue initializer. * @brief Static threads queue initializer.
@ -83,7 +83,7 @@
*/ */
static inline void list_init(threads_list_t *tlp) { static inline void list_init(threads_list_t *tlp) {
tlp->p_next = (Thread *)tlp; tlp->p_next = (thread_t *)tlp;
} }
/** /**
@ -91,9 +91,9 @@ static inline void list_init(threads_list_t *tlp) {
* *
* @notapi * @notapi
*/ */
static inline bool_t list_isempty(threads_list_t *tlp) { static inline bool list_isempty(threads_list_t *tlp) {
return (bool_t)(tlp->p_next == (Thread *)tlp); return (bool)(tlp->p_next == (thread_t *)tlp);
} }
/** /**
@ -101,9 +101,9 @@ static inline bool_t list_isempty(threads_list_t *tlp) {
* *
* @notapi * @notapi
*/ */
static inline bool_t list_notempty(threads_list_t *tlp) { static inline bool list_notempty(threads_list_t *tlp) {
return (bool_t)(tlp->p_next != (Thread *)tlp); return (bool)(tlp->p_next != (thread_t *)tlp);
} }
/** /**
@ -113,7 +113,7 @@ static inline bool_t list_notempty(threads_list_t *tlp) {
*/ */
static inline void queue_init(threads_queue_t *tqp) { static inline void queue_init(threads_queue_t *tqp) {
tqp->p_next = tqp->p_prev = (Thread *)tqp; tqp->p_next = tqp->p_prev = (thread_t *)tqp;
} }
/** /**
@ -121,9 +121,9 @@ static inline void queue_init(threads_queue_t *tqp) {
* *
* @notapi * @notapi
*/ */
static inline bool_t queue_isempty(threads_queue_t *tqp) { static inline bool queue_isempty(threads_queue_t *tqp) {
return (bool_t)(tqp->p_next == (Thread *)tqp); return (bool)(tqp->p_next == (thread_t *)tqp);
} }
/** /**
@ -131,60 +131,60 @@ static inline bool_t queue_isempty(threads_queue_t *tqp) {
* *
* @notapi * @notapi
*/ */
static inline bool_t queue_notempty(threads_queue_t *tqp) { static inline bool queue_notempty(threads_queue_t *tqp) {
return (bool_t)(tqp->p_next != (Thread *)tqp); return (bool)(tqp->p_next != (thread_t *)tqp);
} }
/* If the performance code path has been chosen then all the following /* If the performance code path has been chosen then all the following
functions are inlined into the various kernel modules.*/ functions are inlined into the various kernel modules.*/
#if CH_OPTIMIZE_SPEED #if CH_OPTIMIZE_SPEED
static inline void list_insert(Thread *tp, threads_list_t *tlp) { static inline void list_insert(thread_t *tp, threads_list_t *tlp) {
tp->p_next = tlp->p_next; tp->p_next = tlp->p_next;
tlp->p_next = tp; tlp->p_next = tp;
} }
static inline Thread *list_remove(threads_list_t *tlp) { static inline thread_t *list_remove(threads_list_t *tlp) {
Thread *tp = tlp->p_next; thread_t *tp = tlp->p_next;
tlp->p_next = tp->p_next; tlp->p_next = tp->p_next;
return tp; return tp;
} }
static inline void queue_prio_insert(Thread *tp, threads_queue_t *tqp) { static inline void queue_prio_insert(thread_t *tp, threads_queue_t *tqp) {
Thread *cp = (Thread *)tqp; thread_t *cp = (thread_t *)tqp;
do { do {
cp = cp->p_next; cp = cp->p_next;
} while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio)); } while ((cp != (thread_t *)tqp) && (cp->p_prio >= tp->p_prio));
tp->p_next = cp; tp->p_next = cp;
tp->p_prev = cp->p_prev; tp->p_prev = cp->p_prev;
tp->p_prev->p_next = cp->p_prev = tp; tp->p_prev->p_next = cp->p_prev = tp;
} }
static inline void queue_insert(Thread *tp, threads_queue_t *tqp) { static inline void queue_insert(thread_t *tp, threads_queue_t *tqp) {
tp->p_next = (Thread *)tqp; tp->p_next = (thread_t *)tqp;
tp->p_prev = tqp->p_prev; tp->p_prev = tqp->p_prev;
tp->p_prev->p_next = tqp->p_prev = tp; tp->p_prev->p_next = tqp->p_prev = tp;
} }
static inline Thread *queue_fifo_remove(threads_queue_t *tqp) { static inline thread_t *queue_fifo_remove(threads_queue_t *tqp) {
Thread *tp = tqp->p_next; thread_t *tp = tqp->p_next;
(tqp->p_next = tp->p_next)->p_prev = (Thread *)tqp; (tqp->p_next = tp->p_next)->p_prev = (thread_t *)tqp;
return tp; return tp;
} }
static inline Thread *queue_lifo_remove(threads_queue_t *tqp) { static inline thread_t *queue_lifo_remove(threads_queue_t *tqp) {
Thread *tp = tqp->p_prev; thread_t *tp = tqp->p_prev;
(tqp->p_prev = tp->p_prev)->p_next = (Thread *)tqp; (tqp->p_prev = tp->p_prev)->p_next = (thread_t *)tqp;
return tp; return tp;
} }
static inline Thread *queue_dequeue(Thread *tp) { static inline thread_t *queue_dequeue(thread_t *tp) {
tp->p_prev->p_next = tp->p_next; tp->p_prev->p_next = tp->p_next;
tp->p_next->p_prev = tp->p_prev; tp->p_next->p_prev = tp->p_prev;

View File

@ -41,7 +41,7 @@
* @iclass * @iclass
*/ */
#define chMsgIsPendingI(tp) \ #define chMsgIsPendingI(tp) \
((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue) ((tp)->p_msgqueue.p_next != (thread_t *)&(tp)->p_msgqueue)
/** /**
* @brief Returns the message carried by the specified thread. * @brief Returns the message carried by the specified thread.
@ -71,9 +71,9 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
msg_t chMsgSend(Thread *tp, msg_t msg); msg_t chMsgSend(thread_t *tp, msg_t msg);
Thread * chMsgWait(void); thread_t * chMsgWait(void);
void chMsgRelease(Thread *tp, msg_t msg); void chMsgRelease(thread_t *tp, msg_t msg);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -37,7 +37,7 @@
typedef struct Mutex { typedef struct Mutex {
threads_queue_t m_queue; /**< @brief Queue of the threads sleeping threads_queue_t m_queue; /**< @brief Queue of the threads sleeping
on this Mutex. */ on this Mutex. */
Thread *m_owner; /**< @brief Owner @p Thread pointer or thread_t *m_owner; /**< @brief Owner @p thread_t pointer or
@p NULL. */ @p NULL. */
struct Mutex *m_next; /**< @brief Next @p Mutex into an struct Mutex *m_next; /**< @brief Next @p Mutex into an
owner-list or @p NULL. */ owner-list or @p NULL. */

View File

@ -41,7 +41,7 @@ typedef struct {
uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */ uint16_t ch_version; /**< @brief Encoded ChibiOS/RT version. */
uint8_t ch_ptrsize; /**< @brief Size of a pointer. */ uint8_t ch_ptrsize; /**< @brief Size of a pointer. */
uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */ uint8_t ch_timesize; /**< @brief Size of a @p systime_t. */
uint8_t ch_threadsize; /**< @brief Size of a @p Thread struct. */ uint8_t ch_threadsize; /**< @brief Size of a @p thread_t. */
uint8_t cf_off_prio; /**< @brief Offset of @p p_prio field. */ uint8_t cf_off_prio; /**< @brief Offset of @p p_prio field. */
uint8_t cf_off_ctx; /**< @brief Offset of @p p_ctx field. */ uint8_t cf_off_ctx; /**< @brief Offset of @p p_ctx field. */
uint8_t cf_off_newer; /**< @brief Offset of @p p_newer field. */ uint8_t cf_off_newer; /**< @brief Offset of @p p_newer field. */
@ -108,7 +108,7 @@ typedef struct {
* @param[in] tp thread to add to the registry * @param[in] tp thread to add to the registry
*/ */
#define REG_INSERT(tp) { \ #define REG_INSERT(tp) { \
(tp)->p_newer = (Thread *)&rlist; \ (tp)->p_newer = (thread_t *)&rlist; \
(tp)->p_older = rlist.r_older; \ (tp)->p_older = rlist.r_older; \
(tp)->p_older->p_newer = rlist.r_older = (tp); \ (tp)->p_older->p_newer = rlist.r_older = (tp); \
} }
@ -117,8 +117,8 @@ typedef struct {
extern "C" { extern "C" {
#endif #endif
extern ROMCONST chdebug_t ch_debug; extern ROMCONST chdebug_t ch_debug;
Thread *chRegFirstThread(void); thread_t *chRegFirstThread(void);
Thread *chRegNextThread(Thread *tp); thread_t *chRegNextThread(thread_t *tp);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -99,11 +99,11 @@ typedef struct {
struct context r_ctx; /**< @brief Not used, present because struct context r_ctx; /**< @brief Not used, present because
offsets. */ offsets. */
#if CH_USE_REGISTRY || defined(__DOXYGEN__) #if CH_USE_REGISTRY || defined(__DOXYGEN__)
Thread *r_newer; /**< @brief Newer registry element. */ thread_t *r_newer; /**< @brief Newer registry element. */
Thread *r_older; /**< @brief Older registry element. */ thread_t *r_older; /**< @brief Older registry element. */
#endif #endif
/* End of the fields shared with the Thread structure.*/ /* End of the fields shared with the thread_t structure.*/
Thread *r_current; /**< @brief The currently running thread_t *r_current; /**< @brief The currently running
thread. */ thread. */
} ready_list_t; } ready_list_t;
@ -151,10 +151,10 @@ extern ready_list_t rlist;
extern "C" { extern "C" {
#endif #endif
void _scheduler_init(void); void _scheduler_init(void);
Thread *chSchReadyI(Thread *tp); thread_t *chSchReadyI(thread_t *tp);
void chSchGoSleepS(tstate_t newstate); void chSchGoSleepS(tstate_t newstate);
msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time); msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time);
void chSchWakeupS(Thread *tp, msg_t msg); void chSchWakeupS(thread_t *tp, msg_t msg);
void chSchRescheduleS(void); void chSchRescheduleS(void);
bool chSchIsPreemptionRequired(void); bool chSchIsPreemptionRequired(void);
void chSchDoRescheduleBehind(void); void chSchDoRescheduleBehind(void);

View File

@ -103,7 +103,7 @@ typedef struct Mutex Mutex;
*/ */
typedef struct { typedef struct {
Thread *p_next; /**< @brief Next in the list/queue. */ thread_t *p_next; /**< @brief Next in the list/queue. */
} threads_list_t; } threads_list_t;
/** /**
@ -112,8 +112,8 @@ typedef struct {
* @brief Generic threads bidirectional linked list header and element. * @brief Generic threads bidirectional linked list header and element.
*/ */
typedef struct { typedef struct {
Thread *p_next; /**< @brief Next in the list/queue. */ thread_t *p_next; /**< @brief Next in the list/queue. */
Thread *p_prev; /**< @brief Previous in the queue. */ thread_t *p_prev; /**< @brief Previous in the queue. */
} threads_queue_t; } threads_queue_t;
/** /**
@ -122,18 +122,18 @@ typedef struct {
* @brief Structure representing a thread. * @brief Structure representing a thread.
* @note Not all the listed fields are always needed, by switching off some * @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 * not needed ChibiOS/RT subsystems it is possible to save RAM space
* by shrinking the @p Thread structure. * by shrinking the @p thread_t structure.
*/ */
typedef struct Thread { typedef struct thread {
Thread *p_next; /**< @brief Next in the list/queue. */ thread_t *p_next; /**< @brief Next in the list/queue. */
/* End of the fields shared with the threads_list_t structure.*/ /* End of the fields shared with the threads_list_t structure.*/
Thread *p_prev; /**< @brief Previous in the queue. */ thread_t *p_prev; /**< @brief Previous in the queue. */
/* End of the fields shared with the threads_queue_t structure.*/ /* End of the fields shared with the threads_queue_t structure.*/
tprio_t p_prio; /**< @brief Thread priority. */ tprio_t p_prio; /**< @brief Thread priority. */
struct context p_ctx; /**< @brief Processor context. */ struct context p_ctx; /**< @brief Processor context. */
#if CH_USE_REGISTRY || defined(__DOXYGEN__) #if CH_USE_REGISTRY || defined(__DOXYGEN__)
Thread *p_newer; /**< @brief Newer registry element. */ thread_t *p_newer; /**< @brief Newer registry element. */
Thread *p_older; /**< @brief Older registry element. */ thread_t *p_older; /**< @brief Older registry element. */
#endif #endif
/* End of the fields shared with the ReadyList structure. */ /* End of the fields shared with the ReadyList structure. */
#if CH_USE_REGISTRY || defined(__DOXYGEN__) #if CH_USE_REGISTRY || defined(__DOXYGEN__)
@ -254,10 +254,10 @@ typedef struct Thread {
/* Extra fields defined in chconf.h.*/ /* Extra fields defined in chconf.h.*/
THREAD_EXT_FIELDS THREAD_EXT_FIELDS
#endif #endif
} Thread; } thread_t;
/** /**
* @brief Thread function. * @brief Thread function.
*/ */
typedef msg_t (*tfunc_t)(void *); typedef msg_t (*tfunc_t)(void *);
@ -270,7 +270,7 @@ typedef msg_t (*tfunc_t)(void *);
* @{ * @{
*/ */
/** /**
* @brief Returns a pointer to the current @p Thread. * @brief Returns a pointer to the current @p thread_t.
* @note Can be invoked in any context. * @note Can be invoked in any context.
* *
* @special * @special
@ -386,30 +386,27 @@ typedef msg_t (*tfunc_t)(void *);
/* External declarations. */ /* External declarations. */
/*===========================================================================*/ /*===========================================================================*/
/*
* Threads APIs.
*/
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
Thread *_thread_init(Thread *tp, tprio_t prio); thread_t *_thread_init(thread_t *tp, tprio_t prio);
#if CH_DBG_FILL_THREADS #if CH_DBG_FILL_THREADS
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v); void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
#endif #endif
Thread *chThdCreateI(void *wsp, size_t size, thread_t *chThdCreateI(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg); tprio_t prio, tfunc_t pf, void *arg);
Thread *chThdCreateStatic(void *wsp, size_t size, thread_t *chThdCreateStatic(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg); tprio_t prio, tfunc_t pf, void *arg);
tprio_t chThdSetPriority(tprio_t newprio); tprio_t chThdSetPriority(tprio_t newprio);
Thread *chThdResume(Thread *tp); thread_t *chThdResume(thread_t *tp);
void chThdTerminate(Thread *tp); void chThdTerminate(thread_t *tp);
void chThdSleep(systime_t time); void chThdSleep(systime_t time);
void chThdSleepUntil(systime_t time); void chThdSleepUntil(systime_t time);
void chThdYield(void); void chThdYield(void);
void chThdExit(msg_t msg); void chThdExit(msg_t msg);
void chThdExitS(msg_t msg); void chThdExitS(msg_t msg);
#if CH_USE_WAITEXIT #if CH_USE_WAITEXIT
msg_t chThdWait(Thread *tp); msg_t chThdWait(thread_t *tp);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -124,7 +124,7 @@ void chCondBroadcastI(CondVar *cp) {
chDbgCheckClassI(); chDbgCheckClassI();
chDbgCheck(cp != NULL, "chCondBroadcastI"); chDbgCheck(cp != NULL, "chCondBroadcastI");
/* Empties the condition variable queue and inserts all the Threads into the /* Empties the condition variable queue and inserts all the threads into the
ready list in FIFO order. The wakeup message is set to @p RDY_RESET in ready list in FIFO order. The wakeup message is set to @p RDY_RESET in
order to make a chCondBroadcast() detectable from a chCondSignal().*/ order to make a chCondBroadcast() detectable from a chCondSignal().*/
while (cp->c_queue.p_next != (void *)&cp->c_queue) while (cp->c_queue.p_next != (void *)&cp->c_queue)
@ -175,7 +175,7 @@ msg_t chCondWait(CondVar *cp) {
* @sclass * @sclass
*/ */
msg_t chCondWaitS(CondVar *cp) { msg_t chCondWaitS(CondVar *cp) {
Thread *ctp = currp; thread_t *ctp = currp;
Mutex *mp; Mutex *mp;
msg_t msg; msg_t msg;

View File

@ -232,7 +232,7 @@ void _trace_init(void) {
* *
* @notapi * @notapi
*/ */
void dbg_trace(Thread *otp) { void dbg_trace(thread_t *otp) {
dbg_trace_buffer.tb_ptr->se_time = chTimeNow(); dbg_trace_buffer.tb_ptr->se_time = chTimeNow();
dbg_trace_buffer.tb_ptr->se_tp = currp; dbg_trace_buffer.tb_ptr->se_tp = currp;

View File

@ -42,7 +42,7 @@
* *
* @api * @api
*/ */
Thread *chThdAddRef(Thread *tp) { thread_t *chThdAddRef(thread_t *tp) {
chSysLock(); chSysLock();
chDbgAssert(tp->p_refs < 255, "chThdAddRef(), #1", "too many references"); chDbgAssert(tp->p_refs < 255, "chThdAddRef(), #1", "too many references");
@ -64,7 +64,7 @@ Thread *chThdAddRef(Thread *tp) {
* *
* @api * @api
*/ */
void chThdRelease(Thread *tp) { void chThdRelease(thread_t *tp) {
trefs_t refs; trefs_t refs;
chSysLock(); chSysLock();
@ -114,16 +114,16 @@ void chThdRelease(Thread *tp) {
* @param[in] pf the thread function * @param[in] pf the thread function
* @param[in] arg an argument passed to the thread function. It can be * @param[in] arg an argument passed to the thread function. It can be
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p thread_t structure allocated for
* the thread into the working space area. * the thread into the working space area.
* @retval NULL if the memory cannot be allocated. * @retval NULL if the memory cannot be allocated.
* *
* @api * @api
*/ */
Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, thread_t *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) { tprio_t prio, tfunc_t pf, void *arg) {
void *wsp; void *wsp;
Thread *tp; thread_t *tp;
wsp = chHeapAlloc(heapp, size); wsp = chHeapAlloc(heapp, size);
if (wsp == NULL) if (wsp == NULL)
@ -131,9 +131,9 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
#if CH_DBG_FILL_THREADS #if CH_DBG_FILL_THREADS
_thread_memfill((uint8_t *)wsp, _thread_memfill((uint8_t *)wsp,
(uint8_t *)wsp + sizeof(Thread), (uint8_t *)wsp + sizeof(thread_t),
CH_THREAD_FILL_VALUE); CH_THREAD_FILL_VALUE);
_thread_memfill((uint8_t *)wsp + sizeof(Thread), _thread_memfill((uint8_t *)wsp + sizeof(thread_t),
(uint8_t *)wsp + size, (uint8_t *)wsp + size,
CH_STACK_FILL_VALUE); CH_STACK_FILL_VALUE);
#endif #endif
@ -163,16 +163,16 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
* @param[in] pf the thread function * @param[in] pf the thread function
* @param[in] arg an argument passed to the thread function. It can be * @param[in] arg an argument passed to the thread function. It can be
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p thread_t structure allocated for
* the thread into the working space area. * the thread into the working space area.
* @retval NULL if the memory pool is empty. * @retval NULL if the memory pool is empty.
* *
* @api * @api
*/ */
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, thread_t *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg) { tfunc_t pf, void *arg) {
void *wsp; void *wsp;
Thread *tp; thread_t *tp;
chDbgCheck(mp != NULL, "chThdCreateFromMemoryPool"); chDbgCheck(mp != NULL, "chThdCreateFromMemoryPool");
@ -182,9 +182,9 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
#if CH_DBG_FILL_THREADS #if CH_DBG_FILL_THREADS
_thread_memfill((uint8_t *)wsp, _thread_memfill((uint8_t *)wsp,
(uint8_t *)wsp + sizeof(Thread), (uint8_t *)wsp + sizeof(thread_t),
CH_THREAD_FILL_VALUE); CH_THREAD_FILL_VALUE);
_thread_memfill((uint8_t *)wsp + sizeof(Thread), _thread_memfill((uint8_t *)wsp + sizeof(thread_t),
(uint8_t *)wsp + mp->mp_object_size, (uint8_t *)wsp + mp->mp_object_size,
CH_STACK_FILL_VALUE); CH_STACK_FILL_VALUE);
#endif #endif

View File

@ -28,8 +28,8 @@
* @addtogroup events * @addtogroup events
* @details Event Flags, Event Sources and Event Listeners. * @details Event Flags, Event Sources and Event Listeners.
* <h2>Operation mode</h2> * <h2>Operation mode</h2>
* Each thread has a mask of pending event flags inside its @p Thread * Each thread has a mask of pending event flags inside its
* structure. * @p thread_t structure.
* Operations defined for event flags: * Operations defined for event flags:
* - <b>Wait</b>, the invoking thread goes to sleep until a certain * - <b>Wait</b>, the invoking thread goes to sleep until a certain
* AND/OR combination of event flags becomes pending. * AND/OR combination of event flags becomes pending.
@ -54,7 +54,7 @@
* @pre In order to use the Events APIs the @p CH_USE_EVENTS option must be * @pre In order to use the Events APIs the @p CH_USE_EVENTS option must be
* enabled in @p chconf.h. * enabled in @p chconf.h.
* @post Enabling events requires 1-4 (depending on the architecture) * @post Enabling events requires 1-4 (depending on the architecture)
* extra bytes in the @p Thread structure. * extra bytes in the @p thread_t structure.
* @{ * @{
*/ */
@ -212,14 +212,14 @@ flagsmask_t chEvtGetAndClearFlags(EventListener *elp) {
} }
/** /**
* @brief Adds a set of event flags directly to specified @p Thread. * @brief Adds a set of event flags directly to the specified @p thread_t.
* *
* @param[in] tp the thread to be signaled * @param[in] tp the thread to be signaled
* @param[in] mask the event flags set to be ORed * @param[in] mask the event flags set to be ORed
* *
* @api * @api
*/ */
void chEvtSignal(Thread *tp, eventmask_t mask) { void chEvtSignal(thread_t *tp, eventmask_t mask) {
chDbgCheck(tp != NULL, "chEvtSignal"); chDbgCheck(tp != NULL, "chEvtSignal");
@ -230,7 +230,7 @@ void chEvtSignal(Thread *tp, eventmask_t mask) {
} }
/** /**
* @brief Adds a set of event flags directly to specified @p Thread. * @brief Adds a set of event flags directly to the specified @p thread_t.
* @post This function does not reschedule so a call to a rescheduling * @post This function does not reschedule so a call to a rescheduling
* function must be performed before unlocking the kernel. Note that * function must be performed before unlocking the kernel. Note that
* interrupt handlers always reschedule on exit so an explicit * interrupt handlers always reschedule on exit so an explicit
@ -241,7 +241,7 @@ void chEvtSignal(Thread *tp, eventmask_t mask) {
* *
* @iclass * @iclass
*/ */
void chEvtSignalI(Thread *tp, eventmask_t mask) { void chEvtSignalI(thread_t *tp, eventmask_t mask) {
chDbgCheckClassI(); chDbgCheckClassI();
chDbgCheck(tp != NULL, "chEvtSignalI"); chDbgCheck(tp != NULL, "chEvtSignalI");
@ -341,7 +341,7 @@ void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) {
* @api * @api
*/ */
eventmask_t chEvtWaitOne(eventmask_t mask) { eventmask_t chEvtWaitOne(eventmask_t mask) {
Thread *ctp = currp; thread_t *ctp = currp;
eventmask_t m; eventmask_t m;
chSysLock(); chSysLock();
@ -370,7 +370,7 @@ eventmask_t chEvtWaitOne(eventmask_t mask) {
* @api * @api
*/ */
eventmask_t chEvtWaitAny(eventmask_t mask) { eventmask_t chEvtWaitAny(eventmask_t mask) {
Thread *ctp = currp; thread_t *ctp = currp;
eventmask_t m; eventmask_t m;
chSysLock(); chSysLock();
@ -398,7 +398,7 @@ eventmask_t chEvtWaitAny(eventmask_t mask) {
* @api * @api
*/ */
eventmask_t chEvtWaitAll(eventmask_t mask) { eventmask_t chEvtWaitAll(eventmask_t mask) {
Thread *ctp = currp; thread_t *ctp = currp;
chSysLock(); chSysLock();
@ -437,7 +437,7 @@ eventmask_t chEvtWaitAll(eventmask_t mask) {
* @api * @api
*/ */
eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; thread_t *ctp = currp;
eventmask_t m; eventmask_t m;
chSysLock(); chSysLock();
@ -480,7 +480,7 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
* @api * @api
*/ */
eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; thread_t *ctp = currp;
eventmask_t m; eventmask_t m;
chSysLock(); chSysLock();
@ -521,7 +521,7 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
* @api * @api
*/ */
eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; thread_t *ctp = currp;
chSysLock(); chSysLock();

View File

@ -65,15 +65,15 @@
* *
* @notapi * @notapi
*/ */
void queue_prio_insert(Thread *tp, threads_queue_t *tqp) { void queue_prio_insert(thread_t *tp, threads_queue_t *tqp) {
/* cp iterates over the queue.*/ /* cp iterates over the queue.*/
Thread *cp = (Thread *)tqp; thread_t *cp = (thread_t *)tqp;
do { do {
/* Iterate to next thread in queue.*/ /* Iterate to next thread in queue.*/
cp = cp->p_next; cp = cp->p_next;
/* Not end of queue? and cp has equal or higher priority than tp?.*/ /* Not end of queue? and cp has equal or higher priority than tp?.*/
} while ((cp != (Thread *)tqp) && (cp->p_prio >= tp->p_prio)); } while ((cp != (thread_t *)tqp) && (cp->p_prio >= tp->p_prio));
/* Insertion on p_prev.*/ /* Insertion on p_prev.*/
tp->p_next = cp; tp->p_next = cp;
tp->p_prev = cp->p_prev; tp->p_prev = cp->p_prev;
@ -81,22 +81,22 @@ void queue_prio_insert(Thread *tp, threads_queue_t *tqp) {
} }
/** /**
* @brief Inserts a Thread into a queue. * @brief Inserts a thread into a queue.
* *
* @param[in] tp the pointer to the thread to be inserted in the list * @param[in] tp the pointer to the thread to be inserted in the list
* @param[in] tqp the pointer to the threads list header * @param[in] tqp the pointer to the threads list header
* *
* @notapi * @notapi
*/ */
void queue_insert(Thread *tp, threads_queue_t *tqp) { void queue_insert(thread_t *tp, threads_queue_t *tqp) {
tp->p_next = (Thread *)tqp; tp->p_next = (thread_t *)tqp;
tp->p_prev = tqp->p_prev; tp->p_prev = tqp->p_prev;
tp->p_prev->p_next = tqp->p_prev = tp; tp->p_prev->p_next = tqp->p_prev = tp;
} }
/** /**
* @brief Removes the first-out Thread from a queue and returns it. * @brief Removes the first-out thread from a queue and returns it.
* @note If the queue is priority ordered then this function returns the * @note If the queue is priority ordered then this function returns the
* thread with the highest priority. * thread with the highest priority.
* *
@ -105,15 +105,15 @@ void queue_insert(Thread *tp, threads_queue_t *tqp) {
* *
* @notapi * @notapi
*/ */
Thread *queue_fifo_remove(threads_queue_t *tqp) { thread_t *queue_fifo_remove(threads_queue_t *tqp) {
Thread *tp = tqp->p_next; thread_t *tp = tqp->p_next;
(tqp->p_next = tp->p_next)->p_prev = (Thread *)tqp; (tqp->p_next = tp->p_next)->p_prev = (thread_t *)tqp;
return tp; return tp;
} }
/** /**
* @brief Removes the last-out Thread from a queue and returns it. * @brief Removes the last-out thread from a queue and returns it.
* @note If the queue is priority ordered then this function returns the * @note If the queue is priority ordered then this function returns the
* thread with the lowest priority. * thread with the lowest priority.
* *
@ -122,15 +122,15 @@ Thread *queue_fifo_remove(threads_queue_t *tqp) {
* *
* @notapi * @notapi
*/ */
Thread *queue_lifo_remove(threads_queue_t *tqp) { thread_t *queue_lifo_remove(threads_queue_t *tqp) {
Thread *tp = tqp->p_prev; thread_t *tp = tqp->p_prev;
(tqp->p_prev = tp->p_prev)->p_next = (Thread *)tqp; (tqp->p_prev = tp->p_prev)->p_next = (thread_t *)tqp;
return tp; return tp;
} }
/** /**
* @brief Removes a Thread from a queue and returns it. * @brief Removes a thread from a queue and returns it.
* @details The thread is removed from the queue regardless of its relative * @details The thread is removed from the queue regardless of its relative
* position and regardless the used insertion method. * position and regardless the used insertion method.
* *
@ -139,7 +139,7 @@ Thread *queue_lifo_remove(threads_queue_t *tqp) {
* *
* @notapi * @notapi
*/ */
Thread *queue_dequeue(Thread *tp) { thread_t *queue_dequeue(thread_t *tp) {
tp->p_prev->p_next = tp->p_next; tp->p_prev->p_next = tp->p_next;
tp->p_next->p_prev = tp->p_prev; tp->p_next->p_prev = tp->p_prev;
@ -147,21 +147,21 @@ Thread *queue_dequeue(Thread *tp) {
} }
/** /**
* @brief Pushes a Thread on top of a stack list. * @brief Pushes a thread_t on top of a stack list.
* *
* @param[in] tp the pointer to the thread to be inserted in the list * @param[in] tp the pointer to the thread to be inserted in the list
* @param[in] tlp the pointer to the threads list header * @param[in] tlp the pointer to the threads list header
* *
* @notapi * @notapi
*/ */
void list_insert(Thread *tp, threads_list_t *tlp) { void list_insert(thread_t *tp, threads_list_t *tlp) {
tp->p_next = tlp->p_next; tp->p_next = tlp->p_next;
tlp->p_next = tp; tlp->p_next = tp;
} }
/** /**
* @brief Pops a Thread from the top of a stack list and returns it. * @brief Pops a thread from the top of a stack list and returns it.
* @pre The list must be non-empty before calling this function. * @pre The list must be non-empty before calling this function.
* *
* @param[in] tlp the pointer to the threads list header * @param[in] tlp the pointer to the threads list header
@ -169,9 +169,9 @@ void list_insert(Thread *tp, threads_list_t *tlp) {
* *
* @notapi * @notapi
*/ */
Thread *list_remove(threads_list_t *tlp) { thread_t *list_remove(threads_list_t *tlp) {
Thread *tp = tlp->p_next; thread_t *tp = tlp->p_next;
tlp->p_next = tp->p_next; tlp->p_next = tp->p_next;
return tp; return tp;
} }

View File

@ -40,7 +40,7 @@
* @pre In order to use the message APIs the @p CH_USE_MESSAGES option * @pre In order to use the message APIs the @p CH_USE_MESSAGES option
* must be enabled in @p chconf.h. * must be enabled in @p chconf.h.
* @post Enabling messages requires 6-12 (depending on the architecture) * @post Enabling messages requires 6-12 (depending on the architecture)
* extra bytes in the @p Thread structure. * extra bytes in the @p thread_t structure.
* @{ * @{
*/ */
@ -65,8 +65,8 @@
* *
* @api * @api
*/ */
msg_t chMsgSend(Thread *tp, msg_t msg) { msg_t chMsgSend(thread_t *tp, msg_t msg) {
Thread *ctp = currp; thread_t *ctp = currp;
chDbgCheck(tp != NULL, "chMsgSend"); chDbgCheck(tp != NULL, "chMsgSend");
@ -96,8 +96,8 @@ msg_t chMsgSend(Thread *tp, msg_t msg) {
* *
* @api * @api
*/ */
Thread *chMsgWait(void) { thread_t *chMsgWait(void) {
Thread *tp; thread_t *tp;
chSysLock(); chSysLock();
if (!chMsgIsPendingI(currp)) if (!chMsgIsPendingI(currp))
@ -118,7 +118,7 @@ Thread *chMsgWait(void) {
* *
* @api * @api
*/ */
void chMsgRelease(Thread *tp, msg_t msg) { void chMsgRelease(thread_t *tp, msg_t msg) {
chSysLock(); chSysLock();
chDbgAssert(tp->p_state == THD_STATE_SNDMSG, chDbgAssert(tp->p_state == THD_STATE_SNDMSG,

View File

@ -61,7 +61,7 @@
* @pre In order to use the mutex APIs the @p CH_USE_MUTEXES option * @pre In order to use the mutex APIs the @p CH_USE_MUTEXES option
* must be enabled in @p chconf.h. * must be enabled in @p chconf.h.
* @post Enabling mutexes requires 5-12 (depending on the architecture) * @post Enabling mutexes requires 5-12 (depending on the architecture)
* extra bytes in the @p Thread structure. * extra bytes in the @p thread_t structure.
* @{ * @{
*/ */
@ -112,7 +112,7 @@ void chMtxLock(Mutex *mp) {
* @sclass * @sclass
*/ */
void chMtxLockS(Mutex *mp) { void chMtxLockS(Mutex *mp) {
Thread *ctp = currp; thread_t *ctp = currp;
chDbgCheckClassS(); chDbgCheckClassS();
chDbgCheck(mp != NULL, "chMtxLockS"); chDbgCheck(mp != NULL, "chMtxLockS");
@ -122,7 +122,7 @@ void chMtxLockS(Mutex *mp) {
/* Priority inheritance protocol; explores the thread-mutex dependencies /* Priority inheritance protocol; explores the thread-mutex dependencies
boosting the priority of all the affected threads to equal the priority boosting the priority of all the affected threads to equal the priority
of the running thread requesting the mutex.*/ of the running thread requesting the mutex.*/
Thread *tp = mp->m_owner; thread_t *tp = mp->m_owner;
/* Does the running thread have higher priority than the mutex /* Does the running thread have higher priority than the mutex
owning thread? */ owning thread? */
while (tp->p_prio < ctp->p_prio) { while (tp->p_prio < ctp->p_prio) {
@ -250,7 +250,7 @@ bool_t chMtxTryLockS(Mutex *mp) {
* @api * @api
*/ */
Mutex *chMtxUnlock(void) { Mutex *chMtxUnlock(void) {
Thread *ctp = currp; thread_t *ctp = currp;
Mutex *ump, *mp; Mutex *ump, *mp;
chSysLock(); chSysLock();
@ -260,13 +260,13 @@ Mutex *chMtxUnlock(void) {
chDbgAssert(ctp->p_mtxlist->m_owner == ctp, chDbgAssert(ctp->p_mtxlist->m_owner == ctp,
"chMtxUnlock(), #2", "chMtxUnlock(), #2",
"ownership failure"); "ownership failure");
/* Removes the top Mutex from the Thread's owned mutexes list and marks it /* Removes the top Mutex from the thread's owned mutexes list and marks it
as not owned.*/ as not owned.*/
ump = ctp->p_mtxlist; ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next; ctp->p_mtxlist = ump->m_next;
/* If a thread is waiting on the mutex then the fun part begins.*/ /* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) { if (chMtxQueueNotEmptyS(ump)) {
Thread *tp; thread_t *tp;
/* Recalculates the optimal thread priority by scanning the owned /* Recalculates the optimal thread priority by scanning the owned
mutexes list.*/ mutexes list.*/
@ -310,7 +310,7 @@ Mutex *chMtxUnlock(void) {
* @sclass * @sclass
*/ */
Mutex *chMtxUnlockS(void) { Mutex *chMtxUnlockS(void) {
Thread *ctp = currp; thread_t *ctp = currp;
Mutex *ump, *mp; Mutex *ump, *mp;
chDbgCheckClassS(); chDbgCheckClassS();
@ -327,7 +327,7 @@ Mutex *chMtxUnlockS(void) {
ctp->p_mtxlist = ump->m_next; ctp->p_mtxlist = ump->m_next;
/* If a thread is waiting on the mutex then the fun part begins.*/ /* If a thread is waiting on the mutex then the fun part begins.*/
if (chMtxQueueNotEmptyS(ump)) { if (chMtxQueueNotEmptyS(ump)) {
Thread *tp; thread_t *tp;
/* Recalculates the optimal thread priority by scanning the owned /* Recalculates the optimal thread priority by scanning the owned
mutexes list.*/ mutexes list.*/
@ -367,7 +367,7 @@ Mutex *chMtxUnlockS(void) {
* @api * @api
*/ */
void chMtxUnlockAll(void) { void chMtxUnlockAll(void) {
Thread *ctp = currp; thread_t *ctp = currp;
chSysLock(); chSysLock();
if (ctp->p_mtxlist != NULL) { if (ctp->p_mtxlist != NULL) {
@ -375,7 +375,7 @@ void chMtxUnlockAll(void) {
Mutex *ump = ctp->p_mtxlist; Mutex *ump = ctp->p_mtxlist;
ctp->p_mtxlist = ump->m_next; ctp->p_mtxlist = ump->m_next;
if (chMtxQueueNotEmptyS(ump)) { if (chMtxQueueNotEmptyS(ump)) {
Thread *tp = queue_fifo_remove(&ump->m_queue); thread_t *tp = queue_fifo_remove(&ump->m_queue);
ump->m_owner = tp; ump->m_owner = tp;
ump->m_next = tp->p_mtxlist; ump->m_next = tp->p_mtxlist;
tp->p_mtxlist = ump; tp->p_mtxlist = ump;

View File

@ -65,31 +65,31 @@ ROMCONST chdebug_t ch_debug = {
(CH_KERNEL_PATCH) << 0), (CH_KERNEL_PATCH) << 0),
(uint8_t)sizeof (void *), (uint8_t)sizeof (void *),
(uint8_t)sizeof (systime_t), (uint8_t)sizeof (systime_t),
(uint8_t)sizeof (Thread), (uint8_t)sizeof (thread_t),
(uint8_t)_offsetof(Thread, p_prio), (uint8_t)_offsetof(thread_t, p_prio),
(uint8_t)_offsetof(Thread, p_ctx), (uint8_t)_offsetof(thread_t, p_ctx),
(uint8_t)_offsetof(Thread, p_newer), (uint8_t)_offsetof(thread_t, p_newer),
(uint8_t)_offsetof(Thread, p_older), (uint8_t)_offsetof(thread_t, p_older),
(uint8_t)_offsetof(Thread, p_name), (uint8_t)_offsetof(thread_t, p_name),
#if CH_DBG_ENABLE_STACK_CHECK #if CH_DBG_ENABLE_STACK_CHECK
(uint8_t)_offsetof(Thread, p_stklimit), (uint8_t)_offsetof(thread_t, p_stklimit),
#else #else
(uint8_t)0, (uint8_t)0,
#endif #endif
(uint8_t)_offsetof(Thread, p_state), (uint8_t)_offsetof(thread_t, p_state),
(uint8_t)_offsetof(Thread, p_flags), (uint8_t)_offsetof(thread_t, p_flags),
#if CH_USE_DYNAMIC #if CH_USE_DYNAMIC
(uint8_t)_offsetof(Thread, p_refs), (uint8_t)_offsetof(thread_t, p_refs),
#else #else
(uint8_t)0, (uint8_t)0,
#endif #endif
#if CH_TIME_QUANTUM > 0 #if CH_TIME_QUANTUM > 0
(uint8_t)_offsetof(Thread, p_preempt), (uint8_t)_offsetof(thread_t, p_preempt),
#else #else
(uint8_t)0, (uint8_t)0,
#endif #endif
#if CH_DBG_THREADS_PROFILING #if CH_DBG_THREADS_PROFILING
(uint8_t)_offsetof(Thread, p_time) (uint8_t)_offsetof(thread_t, p_time)
#else #else
(uint8_t)0 (uint8_t)0
#endif #endif
@ -107,8 +107,8 @@ ROMCONST chdebug_t ch_debug = {
* *
* @api * @api
*/ */
Thread *chRegFirstThread(void) { thread_t *chRegFirstThread(void) {
Thread *tp; thread_t *tp;
chSysLock(); chSysLock();
tp = rlist.r_newer; tp = rlist.r_newer;
@ -130,12 +130,12 @@ Thread *chRegFirstThread(void) {
* *
* @api * @api
*/ */
Thread *chRegNextThread(Thread *tp) { thread_t *chRegNextThread(thread_t *tp) {
Thread *ntp; thread_t *ntp;
chSysLock(); chSysLock();
ntp = tp->p_newer; ntp = tp->p_newer;
if (ntp == (Thread *)&rlist) if (ntp == (thread_t *)&rlist)
ntp = NULL; ntp = NULL;
#if CH_USE_DYNAMIC #if CH_USE_DYNAMIC
else { else {

View File

@ -68,7 +68,7 @@ void _scheduler_init(void) {
queue_init(&rlist.r_queue); queue_init(&rlist.r_queue);
rlist.r_prio = NOPRIO; rlist.r_prio = NOPRIO;
#if CH_USE_REGISTRY #if CH_USE_REGISTRY
rlist.r_newer = rlist.r_older = (Thread *)&rlist; rlist.r_newer = rlist.r_older = (thread_t *)&rlist;
#endif #endif
} }
@ -88,8 +88,8 @@ void _scheduler_init(void) {
* *
* @iclass * @iclass
*/ */
Thread *chSchReadyI(Thread *tp) { thread_t *chSchReadyI(thread_t *tp) {
Thread *cp; thread_t *cp;
chDbgCheckClassI(); chDbgCheckClassI();
@ -100,7 +100,7 @@ Thread *chSchReadyI(Thread *tp) {
"invalid state"); "invalid state");
tp->p_state = THD_STATE_READY; tp->p_state = THD_STATE_READY;
cp = (Thread *)&rlist.r_queue; cp = (thread_t *)&rlist.r_queue;
do { do {
cp = cp->p_next; cp = cp->p_next;
} while (cp->p_prio >= tp->p_prio); } while (cp->p_prio >= tp->p_prio);
@ -121,7 +121,7 @@ Thread *chSchReadyI(Thread *tp) {
* @sclass * @sclass
*/ */
void chSchGoSleepS(tstate_t newstate) { void chSchGoSleepS(tstate_t newstate) {
Thread *otp; thread_t *otp;
chDbgCheckClassS(); chDbgCheckClassS();
@ -140,7 +140,7 @@ void chSchGoSleepS(tstate_t newstate) {
* Timeout wakeup callback. * Timeout wakeup callback.
*/ */
static void wakeup(void *p) { static void wakeup(void *p) {
Thread *tp = (Thread *)p; thread_t *tp = (thread_t *)p;
chSysLockFromIsr(); chSysLockFromIsr();
switch (tp->p_state) { switch (tp->p_state) {
@ -221,12 +221,12 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
* @note The function assumes that the current thread has the highest * @note The function assumes that the current thread has the highest
* priority. * priority.
* *
* @param[in] ntp the Thread to be made ready * @param[in] ntp the thread to be made ready
* @param[in] msg message to the awakened thread * @param[in] msg message to the awakened thread
* *
* @sclass * @sclass
*/ */
void chSchWakeupS(Thread *ntp, msg_t msg) { void chSchWakeupS(thread_t *ntp, msg_t msg) {
chDbgCheckClassS(); chDbgCheckClassS();
@ -238,7 +238,7 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
if (ntp->p_prio <= currp->p_prio) if (ntp->p_prio <= currp->p_prio)
chSchReadyI(ntp); chSchReadyI(ntp);
else { else {
Thread *otp = chSchReadyI(currp); thread_t *otp = chSchReadyI(currp);
setcurrp(ntp); setcurrp(ntp);
ntp->p_state = THD_STATE_CURRENT; ntp->p_state = THD_STATE_CURRENT;
chSysSwitch(ntp, otp); chSysSwitch(ntp, otp);
@ -300,7 +300,7 @@ bool chSchIsPreemptionRequired(void) {
* @special * @special
*/ */
void chSchDoRescheduleBehind(void) { void chSchDoRescheduleBehind(void) {
Thread *otp; thread_t *otp;
otp = currp; otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/ /* Picks the first thread from the ready queue and makes it current.*/
@ -323,7 +323,7 @@ void chSchDoRescheduleBehind(void) {
* @special * @special
*/ */
void chSchDoRescheduleAhead(void) { void chSchDoRescheduleAhead(void) {
Thread *otp, *cp; thread_t *otp, *cp;
otp = currp; otp = currp;
/* Picks the first thread from the ready queue and makes it current.*/ /* Picks the first thread from the ready queue and makes it current.*/
@ -331,7 +331,7 @@ void chSchDoRescheduleAhead(void) {
currp->p_state = THD_STATE_CURRENT; currp->p_state = THD_STATE_CURRENT;
otp->p_state = THD_STATE_READY; otp->p_state = THD_STATE_READY;
cp = (Thread *)&rlist.r_queue; cp = (thread_t *)&rlist.r_queue;
do { do {
cp = cp->p_next; cp = cp->p_next;
} while (cp->p_prio > otp->p_prio); } while (cp->p_prio > otp->p_prio);

View File

@ -305,7 +305,7 @@ void chSemSignalI(Semaphore *sp) {
if (++sp->s_cnt <= 0) { if (++sp->s_cnt <= 0) {
/* Note, it is done this way in order to allow a tail call on /* Note, it is done this way in order to allow a tail call on
chSchReadyI().*/ chSchReadyI().*/
Thread *tp = queue_fifo_remove(&sp->s_queue); thread_t *tp = queue_fifo_remove(&sp->s_queue);
tp->p_u.rdymsg = RDY_OK; tp->p_u.rdymsg = RDY_OK;
chSchReadyI(tp); chSchReadyI(tp);
} }
@ -373,7 +373,7 @@ msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw) {
if (++sps->s_cnt <= 0) if (++sps->s_cnt <= 0)
chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = RDY_OK; chSchReadyI(queue_fifo_remove(&sps->s_queue))->p_u.rdymsg = RDY_OK;
if (--spw->s_cnt < 0) { if (--spw->s_cnt < 0) {
Thread *ctp = currp; thread_t *ctp = currp;
sem_insert(ctp, &spw->s_queue); sem_insert(ctp, &spw->s_queue);
ctp->p_u.wtobjp = spw; ctp->p_u.wtobjp = spw;
chSchGoSleepS(THD_STATE_WTSEM); chSchGoSleepS(THD_STATE_WTSEM);

View File

@ -75,7 +75,7 @@ void _idle_thread(void *p) {
* @special * @special
*/ */
void chSysInit(void) { void chSysInit(void) {
static Thread mainthread; static thread_t mainthread;
#if CH_DBG_ENABLE_STACK_CHECK #if CH_DBG_ENABLE_STACK_CHECK
extern stkalign_t __main_thread_stack_base__; extern stkalign_t __main_thread_stack_base__;
#endif #endif
@ -97,7 +97,7 @@ void chSysInit(void) {
setcurrp(_thread_init(&mainthread, NORMALPRIO)); setcurrp(_thread_init(&mainthread, NORMALPRIO));
currp->p_state = THD_STATE_CURRENT; currp->p_state = THD_STATE_CURRENT;
#if CH_DBG_ENABLE_STACK_CHECK #if CH_DBG_ENABLE_STACK_CHECK
/* This is a special case because the main thread Thread structure is not /* This is a special case because the main thread thread_t structure is not
adjacent to its stack area.*/ adjacent to its stack area.*/
currp->p_stklimit = &__main_thread_stack_base__; currp->p_stklimit = &__main_thread_stack_base__;
#endif #endif

View File

@ -90,7 +90,7 @@
* *
* @notapi * @notapi
*/ */
Thread *_thread_init(Thread *tp, tprio_t prio) { thread_t *_thread_init(thread_t *tp, tprio_t prio) {
tp->p_prio = prio; tp->p_prio = prio;
tp->p_state = THD_STATE_SUSPENDED; tp->p_state = THD_STATE_SUSPENDED;
@ -166,15 +166,16 @@ void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
* @param[in] pf the thread function * @param[in] pf the thread function
* @param[in] arg an argument passed to the thread function. It can be * @param[in] arg an argument passed to the thread function. It can be
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p thread_t structure allocated for
* the thread into the working space area. * the thread into the working space area.
* *
* @iclass * @iclass
*/ */
Thread *chThdCreateI(void *wsp, size_t size, thread_t *chThdCreateI(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) { tprio_t prio, tfunc_t pf, void *arg) {
/* Thread structure is laid out in the lower part of the thread workspace.*/ /* The thread structure is laid out in the lower part of the thread
Thread *tp = wsp; workspace.*/
thread_t *tp = wsp;
chDbgCheckClassI(); chDbgCheckClassI();
@ -196,20 +197,20 @@ Thread *chThdCreateI(void *wsp, size_t size,
* @param[in] pf the thread function * @param[in] pf the thread function
* @param[in] arg an argument passed to the thread function. It can be * @param[in] arg an argument passed to the thread function. It can be
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p thread_t structure allocated for
* the thread into the working space area. * the thread into the working space area.
* *
* @api * @api
*/ */
Thread *chThdCreateStatic(void *wsp, size_t size, thread_t *chThdCreateStatic(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) { tprio_t prio, tfunc_t pf, void *arg) {
Thread *tp; thread_t *tp;
#if CH_DBG_FILL_THREADS #if CH_DBG_FILL_THREADS
_thread_memfill((uint8_t *)wsp, _thread_memfill((uint8_t *)wsp,
(uint8_t *)wsp + sizeof(Thread), (uint8_t *)wsp + sizeof(thread_t),
CH_THREAD_FILL_VALUE); CH_THREAD_FILL_VALUE);
_thread_memfill((uint8_t *)wsp + sizeof(Thread), _thread_memfill((uint8_t *)wsp + sizeof(thread_t),
(uint8_t *)wsp + size, (uint8_t *)wsp + size,
CH_STACK_FILL_VALUE); CH_STACK_FILL_VALUE);
#endif #endif
@ -264,7 +265,7 @@ tprio_t chThdSetPriority(tprio_t newprio) {
* *
* @api * @api
*/ */
Thread *chThdResume(Thread *tp) { thread_t *chThdResume(thread_t *tp) {
chSysLock(); chSysLock();
chDbgAssert(tp->p_state == THD_STATE_SUSPENDED, chDbgAssert(tp->p_state == THD_STATE_SUSPENDED,
@ -287,7 +288,7 @@ Thread *chThdResume(Thread *tp) {
* *
* @api * @api
*/ */
void chThdTerminate(Thread *tp) { void chThdTerminate(thread_t *tp) {
chSysLock(); chSysLock();
tp->p_flags |= THD_TERMINATE; tp->p_flags |= THD_TERMINATE;
@ -381,7 +382,7 @@ void chThdExit(msg_t msg) {
* @sclass * @sclass
*/ */
void chThdExitS(msg_t msg) { void chThdExitS(msg_t msg) {
Thread *tp = currp; thread_t *tp = currp;
tp->p_u.exitcode = msg; tp->p_u.exitcode = msg;
#if defined(THREAD_EXT_EXIT_HOOK) #if defined(THREAD_EXT_EXIT_HOOK)
@ -423,7 +424,7 @@ void chThdExitS(msg_t msg) {
* @pre The configuration option @p CH_USE_WAITEXIT must be enabled in * @pre The configuration option @p CH_USE_WAITEXIT must be enabled in
* order to use this function. * order to use this function.
* @post Enabling @p chThdWait() requires 2-4 (depending on the * @post Enabling @p chThdWait() requires 2-4 (depending on the
* architecture) extra bytes in the @p Thread structure. * architecture) extra bytes in the @p thread_t structure.
* @post After invoking @p chThdWait() the thread pointer becomes invalid * @post After invoking @p chThdWait() the thread pointer becomes invalid
* and must not be used as parameter for further system calls. * and must not be used as parameter for further system calls.
* @note If @p CH_USE_DYNAMIC is not specified this function just waits for * @note If @p CH_USE_DYNAMIC is not specified this function just waits for
@ -434,7 +435,7 @@ void chThdExitS(msg_t msg) {
* *
* @api * @api
*/ */
msg_t chThdWait(Thread *tp) { msg_t chThdWait(thread_t *tp) {
msg_t msg; msg_t msg;
chDbgCheck(tp != NULL, "chThdWait"); chDbgCheck(tp != NULL, "chThdWait");

View File

@ -426,7 +426,7 @@
/** /**
* @brief Debug option, threads profiling. * @brief Debug option, threads profiling.
* @details If enabled then a field is added to the @p Thread structure that * @details If enabled then a field is added to the @p thread_t structure that
* counts the system ticks occurred while executing the thread. * counts the system ticks occurred while executing the thread.
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
@ -448,7 +448,7 @@
/** /**
* @brief Threads descriptor structure extension. * @brief Threads descriptor structure extension.
* @details User fields added to the end of the @p Thread structure. * @details User fields added to the end of the @p thread_t structure.
*/ */
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) #if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \ #define THREAD_EXT_FIELDS \

View File

@ -128,7 +128,7 @@ void port_halt(void) {
* @param[in] ntp the thread to be switched in * @param[in] ntp the thread to be switched in
* @param[in] otp the thread to be switched out * @param[in] otp the thread to be switched out
*/ */
void port_switch(Thread *ntp, Thread *otp) { void port_switch(thread_t *ntp, thread_t *otp) {
} }
/** @} */ /** @} */

View File

@ -124,7 +124,7 @@ struct intctx {
}; };
/** /**
* @brief Platform dependent part of the @p Thread structure. * @brief Platform dependent part of the @p thread_t structure.
* @details This structure usually contains just the saved stack pointer * @details This structure usually contains just the saved stack pointer
* defined as a pointer to a @p intctx structure. * defined as a pointer to a @p intctx structure.
*/ */
@ -148,7 +148,7 @@ struct context {
/** /**
* @brief Computes the thread working area global size. * @brief Computes the thread working area global size.
*/ */
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ #define THD_WA_SIZE(n) STACK_ALIGN(sizeof(thread_t) + \
sizeof(struct intctx) + \ sizeof(struct intctx) + \
sizeof(struct extctx) + \ sizeof(struct extctx) + \
(n) + (PORT_INT_REQUIRED_STACK)) (n) + (PORT_INT_REQUIRED_STACK))
@ -203,7 +203,7 @@ extern "C" {
void port_enable(void); void port_enable(void);
void port_wait_for_interrupt(void); void port_wait_for_interrupt(void);
void port_halt(void); void port_halt(void);
void port_switch(Thread *ntp, Thread *otp); void port_switch(thread_t *ntp, thread_t *otp);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -226,7 +226,7 @@ void _port_switch_from_isr(void) {
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
__attribute__((naked)) __attribute__((naked))
#endif #endif
void _port_switch(Thread *ntp, Thread *otp) { void _port_switch(thread_t *ntp, thread_t *otp) {
asm volatile ("push {r4, r5, r6, r7, r8, r9, r10, r11, lr}" asm volatile ("push {r4, r5, r6, r7, r8, r9, r10, r11, lr}"
: : : "memory"); : : : "memory");

View File

@ -291,7 +291,7 @@ struct intctx {
#endif /* !defined(__DOXYGEN__) */ #endif /* !defined(__DOXYGEN__) */
/** /**
* @brief Platform dependent part of the @p Thread structure. * @brief Platform dependent part of the @p thread_t structure.
* @details In this port the structure just holds a pointer to the @p intctx * @details In this port the structure just holds a pointer to the @p intctx
* structure representing the stack pointer at context switch time. * structure representing the stack pointer at context switch time.
*/ */
@ -321,7 +321,7 @@ struct context {
/** /**
* @brief Computes the thread working area global size. * @brief Computes the thread working area global size.
*/ */
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ #define THD_WA_SIZE(n) STACK_ALIGN(sizeof(thread_t) + \
sizeof(struct intctx) + \ sizeof(struct intctx) + \
sizeof(struct extctx) + \ sizeof(struct extctx) + \
(n) + (PORT_INT_REQUIRED_STACK)) (n) + (PORT_INT_REQUIRED_STACK))
@ -508,7 +508,7 @@ extern "C" {
void _port_irq_epilogue(void); void _port_irq_epilogue(void);
void _port_switch_from_isr(void); void _port_switch_from_isr(void);
void _port_exit_from_isr(void); void _port_exit_from_isr(void);
void _port_switch(Thread *ntp, Thread *otp); void _port_switch(thread_t *ntp, thread_t *otp);
void _port_thread_start(void); void _port_thread_start(void);
#if !CH_OPTIMIZE_SPEED #if !CH_OPTIMIZE_SPEED
void _port_lock(void); void _port_lock(void);

View File

@ -70,7 +70,7 @@ union test_buffers test;
/* /*
* Pointers to the spawned threads. * Pointers to the spawned threads.
*/ */
Thread *threads[MAX_THREADS]; thread_t *threads[MAX_THREADS];
/* /*
* Pointers to the working areas. * Pointers to the working areas.

View File

@ -162,7 +162,7 @@ extern "C" {
} }
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
extern Thread *threads[MAX_THREADS]; extern thread_t *threads[MAX_THREADS];
extern union test_buffers test; extern union test_buffers test;
extern void * ROMCONST wa[]; extern void * ROMCONST wa[];
extern bool_t test_timer_done; extern bool_t test_timer_done;

View File

@ -62,7 +62,7 @@ static Mutex mtx1;
#endif #endif
static msg_t thread1(void *p) { static msg_t thread1(void *p) {
Thread *tp; thread_t *tp;
msg_t msg; msg_t msg;
(void)p; (void)p;
@ -77,7 +77,7 @@ static msg_t thread1(void *p) {
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((noinline)) __attribute__((noinline))
#endif #endif
static unsigned int msg_loop_test(Thread *tp) { static unsigned int msg_loop_test(thread_t *tp) {
uint32_t n = 0; uint32_t n = 0;
test_wait_tick(); test_wait_tick();
@ -202,7 +202,7 @@ ROMCONST struct testcase testbmk3 = {
msg_t thread4(void *p) { msg_t thread4(void *p) {
msg_t msg; msg_t msg;
Thread *self = chThdSelf(); thread_t *self = chThdSelf();
(void)p; (void)p;
chSysLock(); chSysLock();
@ -215,7 +215,7 @@ msg_t thread4(void *p) {
} }
static void bmk4_execute(void) { static void bmk4_execute(void) {
Thread *tp; thread_t *tp;
uint32_t n; uint32_t n;
tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL); tp = threads[0] = chThdCreateStatic(wa[0], WA_SIZE, chThdGetPriority()+1, thread4, NULL);
@ -635,12 +635,12 @@ static void bmk13_execute(void) {
test_print("--- System: "); test_print("--- System: ");
test_printn(sizeof(ready_list_t) + sizeof(VTList) + test_printn(sizeof(ready_list_t) + sizeof(VTList) +
PORT_IDLE_THREAD_STACK_SIZE + PORT_IDLE_THREAD_STACK_SIZE +
(sizeof(Thread) + sizeof(struct intctx) + (sizeof(thread_t) + sizeof(struct intctx) +
sizeof(struct extctx) + sizeof(struct extctx) +
PORT_INT_REQUIRED_STACK) * 2); PORT_INT_REQUIRED_STACK) * 2);
test_println(" bytes"); test_println(" bytes");
test_print("--- Thread: "); test_print("--- Thread: ");
test_printn(sizeof(Thread)); test_printn(sizeof(thread_t));
test_println(" bytes"); test_println(" bytes");
test_print("--- Timer : "); test_print("--- Timer : ");
test_printn(sizeof(VirtualTimer)); test_printn(sizeof(VirtualTimer));

View File

@ -188,8 +188,8 @@ ROMCONST struct testcase testdyn2 = {
* coverage. * coverage.
*/ */
static bool_t regfind(Thread *tp) { static bool_t regfind(thread_t *tp) {
Thread *ftp; thread_t *ftp;
bool_t found = FALSE; bool_t found = FALSE;
ftp = chRegFirstThread(); ftp = chRegFirstThread();
@ -206,7 +206,7 @@ static void dyn3_setup(void) {
} }
static void dyn3_execute(void) { static void dyn3_execute(void) {
Thread *tp; thread_t *tp;
tprio_t prio = chThdGetPriority(); tprio_t prio = chThdGetPriority();
/* Testing references increase/decrease and final detach.*/ /* Testing references increase/decrease and final detach.*/

View File

@ -133,7 +133,7 @@ static void evt2_setup(void) {
static msg_t thread1(void *p) { static msg_t thread1(void *p) {
chThdSleepMilliseconds(50); chThdSleepMilliseconds(50);
chEvtSignal((Thread *)p, 1); chEvtSignal((thread_t *)p, 1);
return 0; return 0;
} }

View File

@ -65,7 +65,7 @@ static msg_t thread(void *p) {
} }
static void msg1_execute(void) { static void msg1_execute(void) {
Thread *tp; thread_t *tp;
msg_t msg; msg_t msg;
/* /*