Commit ef60d87b authored by Ben Walker's avatar Ben Walker Committed by Daniel Verkamp
Browse files

env: Add wrappers to launch and wait for threads



Change-Id: Ied778fc41ddc5ff7563408eccafc0e0654287b19
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/363608


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent e889c6e7
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -207,6 +207,24 @@ uint32_t spdk_env_get_next_core(uint32_t prev_core);
 */
uint32_t spdk_env_get_socket_id(uint32_t core);

typedef int (*thread_start_fn)(void *);

/**
 * \brief Launch a thread pinned to the given core. Only a single pinned thread
 * may be launched per core. Subsequent attempts to launch pinned threads on
 * that core will fail.
 *
 * \param core The core to pin the thread to.
 * \param fn Entry point on the new thread.
 * \param arg Argument apssed to thread_start_fn
 */
int spdk_env_thread_launch_pinned(uint32_t core, thread_start_fn fn, void *arg);

/**
 * \brief Wait for all threads to exit before returning.
 */
void spdk_env_thread_wait_all(void);

/**
 * Return true if the calling process is primary process
 */
+16 −0
Original line number Diff line number Diff line
@@ -71,3 +71,19 @@ spdk_env_get_socket_id(uint32_t core)
{
	return rte_lcore_to_socket_id(core);
}

int
spdk_env_thread_launch_pinned(uint32_t core, thread_start_fn fn, void *arg)
{
	int rc;

	rc = rte_eal_remote_launch(fn, arg, core);

	return rc;
}

void
spdk_env_thread_wait_all(void)
{
	rte_eal_mp_wait_lcore();
}