env: Add wrappers to launch and wait for threads
Change-Id: Ied778fc41ddc5ff7563408eccafc0e0654287b19 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/363608 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
e889c6e715
commit
ef60d87b84
@ -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);
|
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
|
* Return true if the calling process is primary process
|
||||||
*/
|
*/
|
||||||
|
@ -71,3 +71,19 @@ spdk_env_get_socket_id(uint32_t core)
|
|||||||
{
|
{
|
||||||
return rte_lcore_to_socket_id(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();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user