From 8df6da88c80f10cb96ed53233ce6c4d414368059 Mon Sep 17 00:00:00 2001 From: Tomas Mudrunka Date: Tue, 29 Jun 2021 16:39:06 +0200 Subject: [PATCH] extra yield --- c/pthread_extra/pthread_extra.h | 1 + c/pthread_extra/pthread_pause.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/c/pthread_extra/pthread_extra.h b/c/pthread_extra/pthread_extra.h index 15e4d8b..58a98e3 100644 --- a/c/pthread_extra/pthread_extra.h +++ b/c/pthread_extra/pthread_extra.h @@ -47,6 +47,7 @@ void pthread_pause_enable(); int pthread_pause(pthread_t thread); int pthread_unpause(pthread_t thread); int pthread_pause_reschedule(pthread_t thread); +int pthread_extra_yield(); // Message queues diff --git a/c/pthread_extra/pthread_pause.c b/c/pthread_extra/pthread_pause.c index c0d4350..d168121 100644 --- a/c/pthread_extra/pthread_pause.c +++ b/c/pthread_extra/pthread_pause.c @@ -63,6 +63,12 @@ int pthread_pause_reschedule(pthread_t thread) { return 0; } +int pthread_extra_yield() { + //Yield to both schedulers + pthread_pause_reschedule(pthread_self()); + return pthread_yield(); +} + int pthread_pause(pthread_t thread) { //Set thread as paused and notify it via signal (wait when queue full) pthread_user_data_internal(thread)->running = 0; -- 2.30.2