From 85de8a1591855db0bc0608b67532515df12e65cc Mon Sep 17 00:00:00 2001 From: weiyu Date: Wed, 20 Nov 2019 12:40:46 -0800 Subject: [PATCH] Implement both pthread_yield and c++ thread yield --- pthread.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pthread.cc b/pthread.cc index d6067eb2..4b5e3d37 100644 --- a/pthread.cc +++ b/pthread.cc @@ -52,6 +52,12 @@ int pthread_detach(pthread_t t) { return 0; } +/* Take care of both pthread_yield and c++ thread yield */ +int sched_yield() { + model->switch_to_master(new ModelAction(THREAD_YIELD, std::memory_order_seq_cst, thread_current(), VALUE_NONE)); + return 0; +} + void pthread_exit(void *value_ptr) { Thread * th = thread_current(); th->set_pthread_return(value_ptr); -- 2.34.1