git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3135 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
83c5424c5f
commit
d79eea31a2
|
@ -29,6 +29,34 @@
|
|||
#ifndef _CHREGISTRY_H_
|
||||
#define _CHREGISTRY_H_
|
||||
|
||||
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Sets the current thread name.
|
||||
* @pre This function only stores the pointer to the name if the option
|
||||
* @p CH_USE_REGISTRY is enabled else no action is performed.
|
||||
*
|
||||
* @param[in] p thread name as a zero terminated string
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
#define chRegSetThreadName(p) (currp->p_name = (p))
|
||||
|
||||
/**
|
||||
* @brief Returns the name of the specified thread.
|
||||
* @pre This function only returns the pointer to the name if the option
|
||||
* @p CH_USE_REGISTRY is enabled else @p NULL is returned.
|
||||
*
|
||||
* @param[in] tp pointer to the thread
|
||||
*
|
||||
* @return Thread name as a zero terminated string.
|
||||
* @retval NULL if the thread name has not been set.
|
||||
*/
|
||||
#define chRegGetThreadName(tp) ((tp)->p_name)
|
||||
#else /* !CH_USE_REGISTRY */
|
||||
#define chRegSetThreadName(p)
|
||||
#define chRegGetThreadName(tp) NULL
|
||||
#endif /* !CH_USE_REGISTRY */
|
||||
|
||||
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,12 @@ struct Thread {
|
|||
Thread *p_older; /**< @brief Older registry element. */
|
||||
#endif
|
||||
/* End of the fields shared with the ReadyList structure. */
|
||||
#if CH_USE_REGISTRY
|
||||
/**
|
||||
* @brief Thread name or @p NULL.
|
||||
*/
|
||||
const char *p_name;
|
||||
#endif
|
||||
/**
|
||||
* @brief Current thread state.
|
||||
*/
|
||||
|
@ -197,36 +203,10 @@ struct Thread {
|
|||
#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread memory mode: pool. */
|
||||
#define THD_TERMINATE 4 /**< @brief Termination requested. */
|
||||
|
||||
/** @brief Thread function.*/
|
||||
typedef msg_t (*tfunc_t)(void *);
|
||||
|
||||
/*
|
||||
* Threads APIs.
|
||||
/**
|
||||
* @brief Thread function.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
Thread *_thread_init(Thread *tp, tprio_t prio);
|
||||
#if CH_DBG_FILL_THREADS
|
||||
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
|
||||
#endif
|
||||
Thread *chThdCreateI(void *wsp, size_t size,
|
||||
tprio_t prio, tfunc_t pf, void *arg);
|
||||
Thread *chThdCreateStatic(void *wsp, size_t size,
|
||||
tprio_t prio, tfunc_t pf, void *arg);
|
||||
tprio_t chThdSetPriority(tprio_t newprio);
|
||||
Thread *chThdResume(Thread *tp);
|
||||
void chThdTerminate(Thread *tp);
|
||||
void chThdSleep(systime_t time);
|
||||
void chThdSleepUntil(systime_t time);
|
||||
void chThdYield(void);
|
||||
void chThdExit(msg_t msg);
|
||||
#if CH_USE_WAITEXIT
|
||||
msg_t chThdWait(Thread *tp);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
typedef msg_t (*tfunc_t)(void *);
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to the current @p Thread.
|
||||
|
@ -342,6 +322,34 @@ extern "C" {
|
|||
*/
|
||||
#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))
|
||||
|
||||
/*
|
||||
* Threads APIs.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
Thread *_thread_init(Thread *tp, tprio_t prio);
|
||||
#if CH_DBG_FILL_THREADS
|
||||
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
|
||||
#endif
|
||||
Thread *chThdCreateI(void *wsp, size_t size,
|
||||
tprio_t prio, tfunc_t pf, void *arg);
|
||||
Thread *chThdCreateStatic(void *wsp, size_t size,
|
||||
tprio_t prio, tfunc_t pf, void *arg);
|
||||
tprio_t chThdSetPriority(tprio_t newprio);
|
||||
Thread *chThdResume(Thread *tp);
|
||||
void chThdTerminate(Thread *tp);
|
||||
void chThdSleep(systime_t time);
|
||||
void chThdSleepUntil(systime_t time);
|
||||
void chThdYield(void);
|
||||
void chThdExit(msg_t msg);
|
||||
#if CH_USE_WAITEXIT
|
||||
msg_t chThdWait(Thread *tp);
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _CHTHREADS_H_ */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -55,6 +55,7 @@ WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
|
|||
void _idle_thread(void *p) {
|
||||
|
||||
(void)p;
|
||||
chRegSetThreadName("idle");
|
||||
while (TRUE) {
|
||||
port_wait_for_interrupt();
|
||||
IDLE_LOOP_HOOK();
|
||||
|
@ -95,6 +96,8 @@ void chSysInit(void) {
|
|||
currp->p_state = THD_STATE_CURRENT;
|
||||
chSysEnable();
|
||||
|
||||
chRegSetThreadName("main");
|
||||
|
||||
#if !CH_NO_IDLE_THREAD
|
||||
/* This thread has the lowest priority in the system, its role is just to
|
||||
serve interrupts in its context while keeping the lowest energy saving
|
||||
|
|
|
@ -89,15 +89,16 @@ Thread *_thread_init(Thread *tp, tprio_t prio) {
|
|||
#if CH_USE_DYNAMIC
|
||||
tp->p_refs = 1;
|
||||
#endif
|
||||
#if CH_USE_REGISTRY
|
||||
tp->p_name = NULL;
|
||||
REG_INSERT(tp);
|
||||
#endif
|
||||
#if CH_USE_WAITEXIT
|
||||
list_init(&tp->p_waiting);
|
||||
#endif
|
||||
#if CH_USE_MESSAGES
|
||||
queue_init(&tp->p_msgqueue);
|
||||
#endif
|
||||
#if CH_USE_REGISTRY
|
||||
REG_INSERT(tp);
|
||||
#endif
|
||||
#if defined(THREAD_EXT_INIT_HOOK)
|
||||
THREAD_EXT_INIT_HOOK(tp);
|
||||
#endif
|
||||
|
|
|
@ -84,6 +84,9 @@
|
|||
(backported to 2.2.4).
|
||||
- FIX: Fixed timeout problem in the lwIP interface layer (bug 3302420)
|
||||
(backported to 2.2.4).
|
||||
- NEW: Added a new functionality to the registry subsystem, now it is possible
|
||||
to associate a name to the threads using chRegSetThreadName. The main and
|
||||
idle threads have their name assigned by default.
|
||||
- NEW: Added TIM8 support to the STM32 GPT, ICU and PWM drivers.
|
||||
- NEW: Updated the STM32 header file to the latest version 3.5.0 and fixed
|
||||
it in order to correct several bugs related to the XL family.
|
||||
|
|
Loading…
Reference in New Issue