thread: Eliminate use of pthread_self and thread_ids
SPDK threads are no longer mapped 1:1 to system threads. They are instead identified by the memory address of the spdk_thread object. Change-Id: I417f8376cebd2ee94f624f4436e6394b51486063 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/437999 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
9bef42f284
commit
5977aad8f7
@ -116,6 +116,4 @@ DECLARE_WRAPPER(pthread_mutex_init, int,
|
||||
DECLARE_WRAPPER(pthread_mutexattr_init, int,
|
||||
(pthread_mutexattr_t *attr));
|
||||
|
||||
DECLARE_WRAPPER(pthread_self, pthread_t, (void));
|
||||
|
||||
#endif /* SPDK_INTERNAL_MOCK_H */
|
||||
|
@ -103,7 +103,6 @@ struct spdk_poller {
|
||||
};
|
||||
|
||||
struct spdk_thread {
|
||||
pthread_t thread_id;
|
||||
spdk_thread_pass_msg msg_fn;
|
||||
spdk_start_poller start_poller_fn;
|
||||
spdk_stop_poller stop_poller_fn;
|
||||
@ -210,7 +209,6 @@ spdk_allocate_thread(spdk_thread_pass_msg msg_fn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
thread->thread_id = pthread_self();
|
||||
thread->msg_fn = msg_fn;
|
||||
thread->start_poller_fn = start_poller_fn;
|
||||
thread->stop_poller_fn = stop_poller_fn;
|
||||
|
@ -41,5 +41,3 @@ DEFINE_WRAPPER(pthread_mutex_init, int,
|
||||
|
||||
DEFINE_WRAPPER(pthread_mutexattr_init, int,
|
||||
(pthread_mutexattr_t *attr), (attr))
|
||||
|
||||
DEFINE_WRAPPER(pthread_self, pthread_t, (void), ())
|
||||
|
@ -33,5 +33,4 @@
|
||||
LDFLAGS += \
|
||||
-Wl,--wrap,calloc \
|
||||
-Wl,--wrap,pthread_mutexattr_init \
|
||||
-Wl,--wrap,pthread_mutex_init \
|
||||
-Wl,--wrap,pthread_self
|
||||
-Wl,--wrap,pthread_mutex_init
|
||||
|
@ -60,17 +60,15 @@ struct ut_thread *g_ut_threads;
|
||||
|
||||
#define INVALID_THREAD 0x1000
|
||||
|
||||
static uintptr_t g_thread_id = INVALID_THREAD;
|
||||
static uint64_t g_thread_id = INVALID_THREAD;
|
||||
|
||||
static void
|
||||
set_thread(uintptr_t thread_id)
|
||||
{
|
||||
g_thread_id = thread_id;
|
||||
if (thread_id == INVALID_THREAD) {
|
||||
MOCK_CLEAR(pthread_self);
|
||||
spdk_set_thread(NULL);
|
||||
} else {
|
||||
MOCK_SET(pthread_self, (pthread_t)thread_id);
|
||||
spdk_set_thread(g_ut_threads[thread_id].thread);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user