xref: /haiku/src/system/libroot/posix/scheduler.cpp (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2009, Michael Franz
3  * Copyright 2008, Andreas Färber, andreas.faerber@web.de
4  * Distributed under the terms of the MIT license.
5  */
6 
7 
8 #include <errno.h>
9 #include <sched.h>
10 
11 #include <OS.h>
12 
13 #include <errno_private.h>
14 #include <syscalls.h>
15 
16 
17 int
18 sched_yield(void)
19 {
20 	_kern_thread_yield();
21 	return 0;
22 }
23 
24 
25 int
26 sched_get_priority_min(int policy)
27 {
28 	switch (policy) {
29 		case SCHED_RR:
30 			return B_FIRST_REAL_TIME_PRIORITY;
31 
32 		case SCHED_OTHER:
33 			return B_LOW_PRIORITY;
34 
35 		default:
36 			__set_errno(EINVAL);
37 			return -1;
38 	}
39 }
40 
41 
42 int
43 sched_get_priority_max(int policy)
44 {
45 	switch (policy) {
46 		case SCHED_RR:
47 			return B_REAL_TIME_PRIORITY;
48 
49 		case SCHED_OTHER:
50 			return B_URGENT_DISPLAY_PRIORITY;
51 
52 		default:
53 			__set_errno(EINVAL);
54 			return -1;
55 	}
56 }
57