Skip to content

Commit

Permalink
Doc and cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
derMihai committed Jan 8, 2025
1 parent fdb218f commit a8091c5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
49 changes: 41 additions & 8 deletions core/include/wait_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,44 @@

#include "sched.h"

/* Wait queue entry, which is always allocated on the stack. We can't use the
* linked list node in thread_t because while evaluating the condition
* expression the thread may:
* - queue on some other wait queue
* - block on something else, e.g. a mutex */
#ifdef __cplusplus
extern "C" {
#endif

typedef struct wait_queue_entry wait_queue_entry_t;

/**
* @cond INTERNAL
* @brief Wait queue entry
*
* Always allocated on the stack. We can't use the linked list node in thread_t
* because while evaluating the condition expression the thread may:
* - queue on some other wait queue
* - block on something else, e.g. a mutex
*/
struct wait_queue_entry {
wait_queue_entry_t *next;
thread_t *thread;
};
/**
* @endcond
*/

/**
* @brief Wait queue struct
*/
typedef struct {
wait_queue_entry_t *list;

Check failure on line 127 in core/include/wait_queue.h

View workflow job for this annotation

GitHub Actions / static-tests

Member list (variable) of struct wait_queue_t is not documented.
} wait_queue_t;

/**
* @cond INTERNAL
* @brief List terminator for the wait queue
*/
#define WAIT_QUEUE_TAIL ((void *)(-1))
/**
* @endcond
*/

/**
* @brief Init a wait queue
Expand All @@ -130,6 +152,9 @@ typedef struct {
# define CONFIG_QUEUE_WAIT_EARLY_EXIT 1
#endif

/**
* @cond INTERNAL
*/
#if CONFIG_QUEUE_WAIT_EARLY_EXIT
# define BREAK_IF_TRUE(cond) \
if (cond) { \
Expand All @@ -145,13 +170,19 @@ void _prepare_to_wait(wait_queue_t *wq, wait_queue_entry_t *entry);
void _maybe_yield_and_enqueue(wait_queue_t *wq, wait_queue_entry_t *entry);
void _wait_dequeue(wait_queue_t *wq, wait_queue_entry_t *entry);

/* For internal use only in queue_wake() and queue_wake_exclusive(). */
void _queue_wake_common(wait_queue_t *wq, bool all);
/**
* @endcond
*/

/**
* @brief Wait for a condition to become true.
*
* Will not return for as long as the condition expression @p cond evaluates to
* false.
*
* @note @p cond may get evaluated mutiple times.
* @note @p cond may get evaluated multiple times.
*
* @note The interrupt state at the moment of calling this macro will be
* restored before executing the condition expression and before
Expand Down Expand Up @@ -179,8 +210,6 @@ void _wait_dequeue(wait_queue_t *wq, wait_queue_entry_t *entry);
_wait_dequeue(wq, &me); \
} while (0)

/* For internal use only. */
void _queue_wake_common(wait_queue_t *wq, bool all);

Check warning on line 213 in core/include/wait_queue.h

View workflow job for this annotation

GitHub Actions / static-tests

too many consecutive empty lines
/**
* @brief Wake one thread queued on the wait queue.
Expand All @@ -202,5 +231,9 @@ static inline void queue_wake(wait_queue_t *wq)
_queue_wake_common(wq, true);
}

#ifdef __cplusplus
}
#endif

#endif /* WAIT_QUEUE_H */
/** @} */
2 changes: 2 additions & 0 deletions tests/core/wait_queue/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import sys
from testrunner import run


def testfunc(child):
child.expect("Test successful!")


if __name__ == "__main__":
sys.exit(run(testfunc))
4 changes: 2 additions & 2 deletions tests/core/wait_queue_optimized/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Test for the wait queue (optimized)
===================================

This tests the wait queue with the early exit optimization enabled (default).
It performs a subset of the tests in [wait_queue test](../wait_queue/). See the
This tests the wait queue with the early exit optimization enabled (default).
It performs a subset of the tests in [wait_queue test](../wait_queue/). See the
[README](../wait_queue/README.md) for why not all the tests can be run.

0 comments on commit a8091c5

Please sign in to comment.