From 603a6de8d561784a018d37b3ca1ab70e2a4950fe Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 28 Aug 2018 16:27:18 -0700 Subject: [PATCH] thread: Add spdk_thread_lib_init and fini These don't do anything yet. Change-Id: I718c6fb19c059a39bc5cb360c3da47ec05bfa416 Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/423767 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Reviewed-by: Jim Harris --- include/spdk/thread.h | 12 ++++++++++++ lib/event/app.c | 4 ++++ lib/thread/thread.c | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/spdk/thread.h b/include/spdk/thread.h index 457df8bde..07352ba32 100644 --- a/include/spdk/thread.h +++ b/include/spdk/thread.h @@ -162,6 +162,18 @@ struct spdk_io_channel { */ }; +/** + * Initialize the threading library. Must be called once prior to allocating any threads. + * + * \return 0 on success. Negated errno on failure. + */ +int spdk_thread_lib_init(void); + +/** + * Release all resources associated with this library. + */ +void spdk_thread_lib_fini(void); + /** * Initializes the calling thread for I/O channel allocation. * diff --git a/lib/event/app.c b/lib/event/app.c index b09b1406f..cba61163e 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -38,6 +38,7 @@ #include "spdk/env.h" #include "spdk/log.h" #include "spdk/conf.h" +#include "spdk/thread.h" #include "spdk/trace.h" #include "spdk/string.h" #include "spdk/rpc.h" @@ -592,6 +593,8 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn, SPDK_NOTICELOG("Total cores available: %d\n", spdk_env_get_core_count()); + spdk_thread_lib_init(); + /* * If mask not specified on command line or in configuration file, * reactor_mask will be 0x1 which will enable core 0 to run one @@ -657,6 +660,7 @@ spdk_app_fini(void) spdk_reactors_fini(); spdk_conf_free(g_spdk_app.config); spdk_log_close(); + spdk_thread_lib_fini(); } static void diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 5fd05ba92..3e418a096 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -107,6 +107,17 @@ _set_thread_name(const char *thread_name) #endif } +int +spdk_thread_lib_init(void) +{ + return 0; +} + +void +spdk_thread_lib_fini(void) +{ +} + struct spdk_thread * spdk_allocate_thread(spdk_thread_pass_msg msg_fn, spdk_start_poller start_poller_fn,