Thread (290 messages) flat view 290 messages, 13 authors, 2022-04-12

Re: [dpdk-dev] [PATCH v16 7/9] eal: implement functions for mutex management

From: Narcisa Ana Maria Vasile <hidden>
Date: 2021-11-09 02:04:03

On Tue, Oct 12, 2021 at 06:28:56PM +0200, Thomas Monjalon wrote:
09/10/2021 09:41, Narcisa Ana Maria Vasile:
quoted
From: Narcisa Vasile <redacted>

Add functions for mutex init, destroy, lock, unlock, trylock.

Add RTE_STATIC_MUTEX macro to replace static initialization
of mutexes.
Windows does not have a static initializer.
Initialization is only done through InitializeCriticalSection().

The RTE_STATIC_MUTEX calls into the rte_thread_mutex_init()
function that performs the actual mutex initialization.
[...]
quoted
--- a/lib/eal/include/rte_thread.h
+++ b/lib/eal/include/rte_thread.h
+#define RTE_DECLARE_MUTEX(private_lock)          rte_thread_mutex private_lock
+
+#define RTE_DEFINE_MUTEX(private_lock)\
+RTE_INIT(__rte_ ## private_lock ## _init)\
+{\
+	RTE_VERIFY(rte_thread_mutex_init(&private_lock) == 0);\
+}
+
+#define RTE_STATIC_MUTEX(private_lock)\
+static RTE_DECLARE_MUTEX(private_lock);\
+RTE_DEFINE_MUTEX(private_lock)
This is not truly static.
It is a wrapper to init the mutex in the constructor.
Should we rename?
Agreed, I'll rename to RTE_MUTEX_INIT or something like this.
Thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help