1 /* 2 * Copyright 2022, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT license. 4 */ 5 6 #include <compat/sys/systm.h> 7 #include <compat/sys/kernel.h> 8 #include <compat/sys/mutex.h> 9 #include <compat/sys/condvar.h> 10 11 12 int 13 msleep(void* identifier, struct mtx* mutex, int priority, 14 const char* description, int timeout) 15 { 16 struct cv channel; 17 channel.condition.Publish(identifier, description); 18 19 int status = cv_timedwait(&channel, mutex, timeout); 20 21 channel.condition.Unpublish(); 22 return status; 23 } 24 25 26 void 27 wakeup(void* identifier) 28 { 29 ConditionVariable::NotifyAll(identifier, B_OK); 30 } 31 32 33 void 34 wakeup_one(void* identifier) 35 { 36 ConditionVariable::NotifyOne(identifier, B_OK); 37 } 38