1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include <kernel.h>
- #include <posix/posix_sched.h>
- static bool valid_posix_policy(int policy)
- {
- if (policy != SCHED_FIFO && policy != SCHED_RR) {
- return false;
- }
- return true;
- }
- int sched_get_priority_min(int policy)
- {
- if (valid_posix_policy(policy) == false) {
- errno = EINVAL;
- return -1;
- }
- if (IS_ENABLED(CONFIG_COOP_ENABLED)) {
- if (policy == SCHED_FIFO) {
- return 0;
- }
- }
- if (IS_ENABLED(CONFIG_PREEMPT_ENABLED)) {
- if (policy == SCHED_RR) {
- return 0;
- }
- }
- errno = EINVAL;
- return -1;
- }
- int sched_get_priority_max(int policy)
- {
- if (valid_posix_policy(policy) == false) {
- errno = EINVAL;
- return -1;
- }
- if (IS_ENABLED(CONFIG_COOP_ENABLED)) {
- if (policy == SCHED_FIFO) {
-
- return (CONFIG_NUM_COOP_PRIORITIES - 1);
- }
- }
- if (IS_ENABLED(CONFIG_PREEMPT_ENABLED)) {
- if (policy == SCHED_RR) {
- return CONFIG_NUM_PREEMPT_PRIORITIES;
- }
- }
- errno = EINVAL;
- return -1;
- }
|