Topics

[PATCH 1/4] nanokernel: Add fiber_config structure and wrapper


Vlad Dogaru <vlad.dogaru@...>
 

Many drivers need to start fibers whose parameters are based on user
configuration. Make it easier to specify such parameters by creating a
fiber_config structure and a wrapper to use it.

Change-Id: I26917ada71acbc676c0f32b6ee081aff7bb1d6d8
Signed-off-by: Vlad Dogaru <vlad.dogaru(a)intel.com>
---
include/nanokernel.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/include/nanokernel.h b/include/nanokernel.h
index 8d7a864..e8795ca 100644
--- a/include/nanokernel.h
+++ b/include/nanokernel.h
@@ -230,6 +230,31 @@ extern void fiber_yield(void);
*/
extern void fiber_abort(void);

+/**
+ * @brief Fiber configuration structure.
+ *
+ * Parameters such as stack size and fiber priority are often
+ * user configurable. This structure makes it simple to specify such a
+ * configuration.
+ */
+struct fiber_config {
+ char *fc_stack;
+ unsigned fc_stack_size;
+ unsigned fc_prio;
+};
+
+/**
+ * @brief Start a fiber based on a @ref fiber_config.
+ */
+static inline nano_thread_id_t
+fiber_fiber_start_config(const struct fiber_config *config,
+ nano_fiber_entry_t entry,
+ int arg1, int arg2, unsigned options)
+{
+ return fiber_fiber_start(config->fc_stack, config->fc_stack_size,
+ entry, arg1, arg2, config->fc_prio, options);
+}
+
#ifdef CONFIG_NANO_TIMEOUTS

/**
--
1.9.1