From: Tomas Mudrunka Date: Tue, 29 Jun 2021 14:39:06 +0000 (+0200) Subject: extra yield X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=8df6da88c80f10cb96ed53233ce6c4d414368059;p=mirrors%2FPrograms.git extra yield --- 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;