2010-02-21 07:24:53 +00:00
|
|
|
/*
|
2011-03-18 18:38:08 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
|
2013-02-02 10:58:09 +00:00
|
|
|
2011,2012,2013 Giovanni Di Sirio.
|
2010-02-21 07:24:53 +00:00
|
|
|
|
|
|
|
This file is part of ChibiOS/RT.
|
|
|
|
|
|
|
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ChibiOS/RT is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-02-27 08:54:22 +00:00
|
|
|
* @file chthreads.h
|
2013-06-16 16:12:33 +00:00
|
|
|
* @brief Threads module macros and structures.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
|
|
|
* @addtogroup threads
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-02-27 08:54:22 +00:00
|
|
|
#ifndef _CHTHREADS_H_
|
|
|
|
#define _CHTHREADS_H_
|
2010-02-21 07:24:53 +00:00
|
|
|
|
2013-06-16 16:12:33 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module constants. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2011-08-22 17:18:52 +00:00
|
|
|
/**
|
|
|
|
* @name Thread states
|
|
|
|
* @{
|
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#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
|
2011-08-22 17:18:52 +00:00
|
|
|
variable. */
|
2013-07-24 14:54:26 +00:00
|
|
|
#define CH_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep()
|
2011-08-22 17:18:52 +00:00
|
|
|
or @p chThdSleepUntil(). */
|
2013-07-24 14:54:26 +00:00
|
|
|
#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
|
2011-08-22 17:18:52 +00:00
|
|
|
answer. */
|
2013-07-24 14:54:26 +00:00
|
|
|
#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. */
|
2011-10-23 11:39:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Thread states as array of strings.
|
|
|
|
* @details Each element in an array initialized with this macro can be
|
|
|
|
* indexed using the numeric thread state values.
|
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#define CH_STATE_NAMES \
|
2011-10-23 11:39:45 +00:00
|
|
|
"READY", "CURRENT", "SUSPENDED", "WTSEM", "WTMTX", "WTCOND", "SLEEPING", \
|
|
|
|
"WTEXIT", "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "WTQUEUE", \
|
|
|
|
"FINAL"
|
2011-08-22 17:18:52 +00:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Thread flags and attributes
|
|
|
|
* @{
|
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#define CH_FLAG_MODE_MASK 3 /**< @brief Thread memory mode mask. */
|
|
|
|
#define CH_FLAG_MODE_STATIC 0 /**< @brief Static thread. */
|
|
|
|
#define CH_FLAG_MODE_HEAP 1 /**< @brief Thread allocated from a
|
2011-08-23 10:09:08 +00:00
|
|
|
Memory Heap. */
|
2013-07-24 14:54:26 +00:00
|
|
|
#define CH_FLAG_MODE_MEMPOOL 2 /**< @brief Thread allocated from a
|
2011-08-23 10:09:08 +00:00
|
|
|
Memory Pool. */
|
2013-07-24 14:54:26 +00:00
|
|
|
#define CH_FLAG_TERMINATE 4 /**< @brief Termination requested flag. */
|
2011-08-22 17:18:52 +00:00
|
|
|
/** @} */
|
|
|
|
|
2013-06-16 16:12:33 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module pre-compile time settings. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Derived constants and error checks. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module data structures and types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/* Forward declaration required by the mutexes stack structure present
|
|
|
|
in every thread.*/
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_MUTEXES
|
2013-07-19 14:51:35 +00:00
|
|
|
typedef struct mutex mutex_t;
|
2013-06-16 16:12:33 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Generic threads single link list, it works like a stack.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *p_next; /**< @brief Next in the list/queue. */
|
2013-07-19 09:43:11 +00:00
|
|
|
} threads_list_t;
|
2013-06-16 16:12:33 +00:00
|
|
|
|
|
|
|
/**
|
2013-07-19 09:43:11 +00:00
|
|
|
* @extends threads_list_t
|
2013-06-16 16:12:33 +00:00
|
|
|
*
|
|
|
|
* @brief Generic threads bidirectional linked list header and element.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *p_next; /**< @brief Next in the list/queue. */
|
|
|
|
thread_t *p_prev; /**< @brief Previous in the queue. */
|
2013-07-19 09:43:11 +00:00
|
|
|
} threads_queue_t;
|
2013-06-16 16:12:33 +00:00
|
|
|
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
2013-07-19 09:43:11 +00:00
|
|
|
* @extends threads_queue_t
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
|
|
|
* @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
|
2013-07-19 12:22:31 +00:00
|
|
|
* by shrinking the @p thread_t structure.
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
2013-07-19 12:22:31 +00:00
|
|
|
typedef struct thread {
|
|
|
|
thread_t *p_next; /**< @brief Next in the list/queue. */
|
2013-07-19 09:43:11 +00:00
|
|
|
/* End of the fields shared with the threads_list_t structure.*/
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *p_prev; /**< @brief Previous in the queue. */
|
2013-07-19 09:43:11 +00:00
|
|
|
/* End of the fields shared with the threads_queue_t structure.*/
|
2010-02-21 07:24:53 +00:00
|
|
|
tprio_t p_prio; /**< @brief Thread priority. */
|
|
|
|
struct context p_ctx; /**< @brief Processor context. */
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *p_newer; /**< @brief Newer registry element. */
|
|
|
|
thread_t *p_older; /**< @brief Older registry element. */
|
2010-02-21 07:24:53 +00:00
|
|
|
#endif
|
|
|
|
/* End of the fields shared with the ReadyList structure. */
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_REGISTRY || defined(__DOXYGEN__)
|
2011-07-08 19:29:00 +00:00
|
|
|
/**
|
|
|
|
* @brief Thread name or @p NULL.
|
|
|
|
*/
|
|
|
|
const char *p_name;
|
2011-08-07 09:00:12 +00:00
|
|
|
#endif
|
|
|
|
#if CH_DBG_ENABLE_STACK_CHECK || defined(__DOXYGEN__)
|
|
|
|
/**
|
|
|
|
* @brief Thread stack boundary.
|
|
|
|
*/
|
|
|
|
stkalign_t *p_stklimit;
|
2011-07-08 19:29:00 +00:00
|
|
|
#endif
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Current thread state.
|
|
|
|
*/
|
|
|
|
tstate_t p_state;
|
|
|
|
/**
|
|
|
|
* @brief Various thread flags.
|
|
|
|
*/
|
|
|
|
tmode_t p_flags;
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_DYNAMIC || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief References to this thread.
|
|
|
|
*/
|
|
|
|
trefs_t p_refs;
|
2012-02-06 19:45:47 +00:00
|
|
|
#endif
|
|
|
|
/**
|
|
|
|
* @brief Number of ticks remaining to this thread.
|
|
|
|
*/
|
2013-07-20 10:12:44 +00:00
|
|
|
#if (CH_CFG_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
|
2012-02-06 19:45:47 +00:00
|
|
|
tslices_t p_preempt;
|
2010-02-21 07:24:53 +00:00
|
|
|
#endif
|
2011-08-07 09:00:12 +00:00
|
|
|
#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Thread consumed time in ticks.
|
2012-01-10 18:14:24 +00:00
|
|
|
* @note This field can overflow.
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
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;
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Enabled events mask.
|
2011-08-07 09:00:12 +00:00
|
|
|
* @note This field is only valid while the thread is in the
|
2013-07-24 14:54:26 +00:00
|
|
|
* @p CH_STATE_WTOREVT or @p CH_STATE_WTANDEVT states.
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
eventmask_t ewmask;
|
|
|
|
#endif
|
|
|
|
} p_u;
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_WAITEXIT || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Termination waiting list.
|
|
|
|
*/
|
2013-07-19 09:43:11 +00:00
|
|
|
threads_list_t p_waiting;
|
2010-02-21 07:24:53 +00:00
|
|
|
#endif
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_MESSAGES || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Messages queue.
|
|
|
|
*/
|
2013-07-19 09:43:11 +00:00
|
|
|
threads_queue_t p_msgqueue;
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Thread message.
|
|
|
|
*/
|
|
|
|
msg_t p_msg;
|
|
|
|
#endif
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_EVENTS || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Pending events mask.
|
|
|
|
*/
|
|
|
|
eventmask_t p_epending;
|
|
|
|
#endif
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_MUTEXES || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief List of the mutexes owned by this thread.
|
|
|
|
* @note The list is terminated by a @p NULL in this field.
|
|
|
|
*/
|
2013-07-19 14:51:35 +00:00
|
|
|
mutex_t *p_mtxlist;
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Thread's own, non-inherited, priority.
|
|
|
|
*/
|
|
|
|
tprio_t p_realprio;
|
|
|
|
#endif
|
2013-07-20 10:12:44 +00:00
|
|
|
#if (CH_CFG_USE_DYNAMIC && CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Memory Pool where the thread workspace is returned.
|
|
|
|
*/
|
|
|
|
void *p_mpool;
|
|
|
|
#endif
|
2013-07-20 10:12:44 +00:00
|
|
|
#if defined(CH_CFG_THREAD_EXTRA_FIELDS)
|
2010-02-21 07:24:53 +00:00
|
|
|
/* Extra fields defined in chconf.h.*/
|
2013-07-20 10:12:44 +00:00
|
|
|
CH_CFG_THREAD_EXTRA_FIELDS
|
2010-08-21 08:38:14 +00:00
|
|
|
#endif
|
2013-07-19 12:22:31 +00:00
|
|
|
} thread_t;
|
2010-02-21 07:24:53 +00:00
|
|
|
|
2011-07-08 19:29:00 +00:00
|
|
|
/**
|
2013-07-19 12:22:31 +00:00
|
|
|
* @brief Thread function.
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
2011-07-08 19:29:00 +00:00
|
|
|
typedef msg_t (*tfunc_t)(void *);
|
2010-02-21 07:24:53 +00:00
|
|
|
|
2013-06-16 16:12:33 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module macros. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2011-08-23 10:09:08 +00:00
|
|
|
/**
|
|
|
|
* @name Macro Functions
|
|
|
|
* @{
|
|
|
|
*/
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
2013-07-19 12:22:31 +00:00
|
|
|
* @brief Returns a pointer to the current @p thread_t.
|
2012-12-13 08:04:25 +00:00
|
|
|
* @note Can be invoked in any context.
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
2012-12-13 08:04:25 +00:00
|
|
|
* @special
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#define chThdSelf() currp
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Returns the current thread priority.
|
2012-12-13 08:04:25 +00:00
|
|
|
* @note Can be invoked in any context.
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
2012-12-13 08:04:25 +00:00
|
|
|
* @special
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#define chThdGetPriority() (currp->p_prio)
|
|
|
|
|
2010-08-20 07:15:55 +00:00
|
|
|
/**
|
|
|
|
* @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.
|
2012-12-13 08:04:25 +00:00
|
|
|
* @note Can be invoked in any context.
|
2010-08-20 07:15:55 +00:00
|
|
|
*
|
2011-02-23 18:59:39 +00:00
|
|
|
* @param[in] tp pointer to the thread
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
2012-12-13 08:04:25 +00:00
|
|
|
* @special
|
2010-08-20 07:15:55 +00:00
|
|
|
*/
|
|
|
|
#define chThdGetTicks(tp) ((tp)->p_time)
|
|
|
|
|
2010-02-21 07:24:53 +00:00
|
|
|
/**
|
2013-07-24 14:54:26 +00:00
|
|
|
* @brief Verifies if the specified thread is in the @p CH_STATE_FINAL state.
|
2012-12-13 08:04:25 +00:00
|
|
|
* @note Can be invoked in any context.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2011-02-23 18:59:39 +00:00
|
|
|
* @param[in] tp pointer to the thread
|
2013-07-20 07:24:12 +00:00
|
|
|
* @retval true thread terminated.
|
|
|
|
* @retval false thread not terminated.
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
2012-12-13 08:04:25 +00:00
|
|
|
* @special
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#define chThdTerminated(tp) ((tp)->p_state == CH_STATE_FINAL)
|
2010-02-21 07:24:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Verifies if the current thread has a termination request pending.
|
2012-12-13 08:04:25 +00:00
|
|
|
* @note Can be invoked in any context.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2013-07-20 07:24:12 +00:00
|
|
|
* @retval true termination request pending.
|
|
|
|
* @retval false termination request not pending.
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
2012-08-15 14:10:01 +00:00
|
|
|
* @special
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#define chThdShouldTerminate() (currp->p_flags & CH_FLAG_TERMINATE)
|
2010-02-21 07:24:53 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-23 10:09:08 +00:00
|
|
|
* @brief Resumes a thread created with @p chThdCreateI().
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2011-02-23 18:59:39 +00:00
|
|
|
* @param[in] tp pointer to the thread
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
|
|
|
* @iclass
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#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.
|
2011-02-21 19:06:46 +00:00
|
|
|
* - @a TIME_IMMEDIATE this value is not allowed.
|
2010-02-21 07:24:53 +00:00
|
|
|
* .
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
|
|
|
* @sclass
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
2013-07-24 14:54:26 +00:00
|
|
|
#define chThdSleepS(time) chSchGoSleepTimeoutS(CH_STATE_SLEEPING, time)
|
2010-02-21 07:24:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
2013-04-11 08:25:03 +00:00
|
|
|
* system tick clock.
|
|
|
|
* @note The maximum specifiable value is implementation dependent.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2011-09-20 20:31:20 +00:00
|
|
|
* @param[in] sec time in seconds, must be different from zero
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
|
|
|
* @api
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#define chThdSleepSeconds(sec) chThdSleep(S2ST(sec))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Delays the invoking thread for the specified number of
|
|
|
|
* milliseconds.
|
|
|
|
* @note The specified time is rounded up to a value allowed by the real
|
2013-04-11 08:25:03 +00:00
|
|
|
* system tick clock.
|
|
|
|
* @note The maximum specifiable value is implementation dependent.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2011-09-20 20:31:20 +00:00
|
|
|
* @param[in] msec time in milliseconds, must be different from zero
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
|
|
|
* @api
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Delays the invoking thread for the specified number of
|
|
|
|
* microseconds.
|
|
|
|
* @note The specified time is rounded up to a value allowed by the real
|
2013-04-11 08:25:03 +00:00
|
|
|
* system tick clock.
|
|
|
|
* @note The maximum specifiable value is implementation dependent.
|
2010-02-21 07:24:53 +00:00
|
|
|
*
|
2011-09-20 20:31:20 +00:00
|
|
|
* @param[in] usec time in microseconds, must be different from zero
|
2010-09-21 10:22:06 +00:00
|
|
|
*
|
|
|
|
* @api
|
2010-02-21 07:24:53 +00:00
|
|
|
*/
|
|
|
|
#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))
|
2011-08-23 10:09:08 +00:00
|
|
|
/** @} */
|
2010-02-21 07:24:53 +00:00
|
|
|
|
2013-06-16 16:48:40 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2011-07-08 19:29:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *_thread_init(thread_t *tp, tprio_t prio);
|
2011-07-08 19:29:00 +00:00
|
|
|
#if CH_DBG_FILL_THREADS
|
|
|
|
void _thread_memfill(uint8_t *startp, uint8_t *endp, uint8_t v);
|
|
|
|
#endif
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *chThdCreateI(void *wsp, size_t size,
|
|
|
|
tprio_t prio, tfunc_t pf, void *arg);
|
|
|
|
thread_t *chThdCreateStatic(void *wsp, size_t size,
|
|
|
|
tprio_t prio, tfunc_t pf, void *arg);
|
2011-07-08 19:29:00 +00:00
|
|
|
tprio_t chThdSetPriority(tprio_t newprio);
|
2013-07-19 12:22:31 +00:00
|
|
|
thread_t *chThdResume(thread_t *tp);
|
|
|
|
void chThdTerminate(thread_t *tp);
|
2011-07-08 19:29:00 +00:00
|
|
|
void chThdSleep(systime_t time);
|
|
|
|
void chThdSleepUntil(systime_t time);
|
|
|
|
void chThdYield(void);
|
|
|
|
void chThdExit(msg_t msg);
|
2011-09-20 17:08:22 +00:00
|
|
|
void chThdExitS(msg_t msg);
|
2013-07-20 10:12:44 +00:00
|
|
|
#if CH_CFG_USE_WAITEXIT
|
2013-07-19 12:22:31 +00:00
|
|
|
msg_t chThdWait(thread_t *tp);
|
2011-07-08 19:29:00 +00:00
|
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-06-16 16:12:33 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module inline functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2010-02-27 08:54:22 +00:00
|
|
|
#endif /* _CHTHREADS_H_ */
|
2010-02-21 07:24:53 +00:00
|
|
|
|
|
|
|
/** @} */
|