aboutsummaryrefslogtreecommitdiffstats
path: root/os/lib/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-10-02 12:58:00 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-10-02 12:58:00 +0000
commitf1f16202873064cdb76e738fba8bfbb5f2ee530d (patch)
treed4c3b1040120e29ad71e548e633d34b6eb82daac /os/lib/include
parent65221fb13150fd9dd7b09b8855f9e1e61eba0a55 (diff)
downloadChibiOS-f1f16202873064cdb76e738fba8bfbb5f2ee530d.tar.gz
ChibiOS-f1f16202873064cdb76e738fba8bfbb5f2ee530d.tar.bz2
ChibiOS-f1f16202873064cdb76e738fba8bfbb5f2ee530d.zip
Revision of pipes.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12315 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/lib/include')
-rw-r--r--os/lib/include/chpipes.h45
1 files changed, 18 insertions, 27 deletions
diff --git a/os/lib/include/chpipes.h b/os/lib/include/chpipes.h
index a09b3c72a..8bf26c62b 100644
--- a/os/lib/include/chpipes.h
+++ b/os/lib/include/chpipes.h
@@ -58,12 +58,16 @@ typedef struct {
uint8_t *rdptr; /**< @brief Read pointer. */
size_t cnt; /**< @brief Bytes in the pipe. */
bool reset; /**< @brief True if in reset state. */
- threads_queue_t qw; /**< @brief Queued writers. */
- threads_queue_t qr; /**< @brief Queued readers. */
+ thread_reference_t wtr; /**< @brief Waiting writer. */
+ thread_reference_t rtr; /**< @brief Waiting reader. */
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
- mutex_t mtx; /**< @brief Heap access mutex. */
+ mutex_t cmtx; /**< @brief Common access mutex. */
+ mutex_t wmtx; /**< @brief Write access mutex. */
+ mutex_t rmtx; /**< @brief Read access mutex. */
#else
- semaphore_t sem; /**< @brief Heap access semaphore. */
+ semaphore_t csem; /**< @brief Common access semaphore.*/
+ semaphore_t wsem; /**< @brief Write access semaphore. */
+ semaphore_t rsem; /**< @brief Read access semaphore. */
#endif
} pipe_t;
@@ -88,9 +92,11 @@ typedef struct {
(uint8_t *)(buffer), \
(size_t)0, \
false, \
- _THREADS_QUEUE_DATA(name.qw), \
- _THREADS_QUEUE_DATA(name.qr), \
- _MUTEX_DATA(name.mtx), \
+ NULL, \
+ NULL, \
+ _MUTEX_DATA(name.cmtx), \
+ _MUTEX_DATA(name.wmtx), \
+ _MUTEX_DATA(name.rmtx), \
}
#else /* CH_CFG_USE_MUTEXES == FALSE */
#define _PIPE_DATA(name, buffer, size) { \
@@ -100,9 +106,11 @@ typedef struct {
(uint8_t *)(buffer), \
(size_t)0, \
false, \
- _THREADS_QUEUE_DATA(name.qw), \
- _THREADS_QUEUE_DATA(name.qr), \
- _SEMAPHORE_DATA(name.sem, (cnt_t)1), \
+ NULL, \
+ NULL, \
+ _SEMAPHORE_DATA(name.csem, (cnt_t)1), \
+ _SEMAPHORE_DATA(name.wsem, (cnt_t)1), \
+ _SEMAPHORE_DATA(name.rsem, (cnt_t)1), \
}
#endif /* CH_CFG_USE_MUTEXES == FALSE */
@@ -182,23 +190,6 @@ static inline size_t chPipeGetFreeCount(const pipe_t *pp) {
}
/**
- * @brief Returns the next byte in the queue without removing it.
- * @pre A byte must be present in the queue for this function to work
- * or it would return garbage. The correct way to use this macro is
- * to use @p chPipeGetFullCountI() and then use this macro, all within
- * a lock state.
- *
- * @param[in] pp the pointer to an initialized @p pipe_t object
- * @return The next byte in queue.
- *
- * @api
- */
-static inline uint8_t chPipePeek(const pipe_t *pp) {
-
- return *pp->rdptr;
-}
-
-/**
* @brief Terminates the reset state.
*
* @param[in] pp the pointer to an initialized @p pipe_t object