Use sched_yield() instead pthread_yield()

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2021-06-28 13:34:15 +02:00
committed by Compute-Runtime-Automation
parent af55117fa0
commit 1d3d32cf39
2 changed files with 6 additions and 3 deletions

View File

@@ -27,6 +27,7 @@
#include <iostream>
#include <memory>
#include <mutex>
#include <sched.h>
#include <thread>
using namespace NEO;
@@ -121,7 +122,7 @@ TEST_F(DrmGemCloseWorkerTests, GivenMultipleThreadsWhenClosingGemThenSucceeds) {
//wait for worker to complete or deadCnt drops
while (!worker->isEmpty() && (deadCnt-- > 0))
pthread_yield(); //yield to another threads
sched_yield(); //yield to another threads
worker->close(false);
@@ -142,7 +143,7 @@ TEST_F(DrmGemCloseWorkerTests, GivenMultipleThreadsAndCloseFalseWhenClosingGemTh
//wait for worker to complete or deadCnt drops
while (!worker->isEmpty() && (deadCnt-- > 0))
pthread_yield(); //yield to another threads
sched_yield(); //yield to another threads
//and check if GEM was closed
EXPECT_EQ(1, this->drmMock->gem_close_cnt.load());

View File

@@ -7,6 +7,8 @@
#include "shared/source/os_interface/linux/os_thread_linux.h"
#include <sched.h>
namespace NEO {
ThreadLinux::ThreadLinux(pthread_t threadId) : threadId(threadId){};
@@ -21,7 +23,7 @@ void ThreadLinux::join() {
}
void ThreadLinux::yield() {
pthread_yield();
sched_yield();
}
} // namespace NEO