1/*
2 * Copyright 2009 Colin Günther, coling@gmx.de
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5
6
7#include <compat/sys/systm.h>
8#include <compat/sys/kernel.h>
9#include <compat/sys/mutex.h>
10#include <compat/sys/condvar.h>
11
12#include "Condvar.h"
13
14
15int
16msleep(void* identifier, struct mtx* mutex, int priority,
17	const char* description, int timeout)
18{
19	int status;
20	struct cv sleep;
21
22	conditionPublish(&sleep, identifier, description);
23
24	mtx_unlock(mutex);
25	status = publishedConditionTimedWait(identifier, timeout);
26	mtx_lock(mutex);
27
28	conditionUnpublish(&sleep);
29
30	return status;
31}
32
33
34void
35wakeup(void* identifier)
36{
37	publishedConditionNotifyAll(identifier);
38}
39
40
41int
42_pause(const char* waitMessage, int timeout)
43{
44	int waitChannel;
45	KASSERT(timeout != 0, ("pause: timeout required"));
46	return tsleep(&waitChannel, 0, waitMessage, timeout);
47}
48