1 /*
2  * Copyright (c) 2018 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "pthread_sched.h"
8 
9 #include <zephyr/kernel.h>
10 #include <zephyr/posix/sched.h>
11 
12 /**
13  * @brief Get minimum priority value for a given policy
14  *
15  * See IEEE 1003.1
16  */
sched_get_priority_min(int policy)17 int sched_get_priority_min(int policy)
18 {
19 	if (!valid_posix_policy(policy)) {
20 		errno = EINVAL;
21 		return -1;
22 	}
23 
24 	return 0;
25 }
26 
27 /**
28  * @brief Get maximum priority value for a given policy
29  *
30  * See IEEE 1003.1
31  */
sched_get_priority_max(int policy)32 int sched_get_priority_max(int policy)
33 {
34 	if (IS_ENABLED(CONFIG_COOP_ENABLED) && policy == SCHED_FIFO) {
35 		return CONFIG_NUM_COOP_PRIORITIES - 1;
36 	} else if (IS_ENABLED(CONFIG_PREEMPT_ENABLED) &&
37 		   (policy == SCHED_RR || policy == SCHED_OTHER)) {
38 		return CONFIG_NUM_PREEMPT_PRIORITIES - 1;
39 	}
40 
41 	errno = EINVAL;
42 	return -1;
43 }
44