From 7143a8ec8e57786cc4d73c70680f248bec113167 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 29 Oct 2018 14:08:07 +0000 Subject: [PATCH] attemping to add qse_sched_yield() --- qse/lib/si/os.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/qse/lib/si/os.c b/qse/lib/si/os.c index b28bd0ca..3568c7d1 100644 --- a/qse/lib/si/os.c +++ b/qse/lib/si/os.c @@ -34,6 +34,9 @@ #if defined(HAVE_SYS_TIME_H) # include #endif +#if defined(HAVE_SCHED_H) +# include +#endif void qse_sleep (const qse_ntime_t* interval) { @@ -60,3 +63,22 @@ int qse_set_proc_name (const qse_char_t* name) ::prctl(PR_SET_NAME, name, 0, 0, 0); }*/ + +void qse_sched_yield (void) +{ +#if defined(_WIN32) + SwitchToThread (); + /* or Sleep (0) */ +#elif defined(__OS2__) + DosSleep (0); +#elif defined(HAVE_SCHED_YIELD) + sched_yield(); +#elif defined(HAVE_NANOSLEEP) + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 0; + nanosleep (&ts, &ts); +#else + sleep (0); +#endif +}