zephyr/lib/posix/sched.c
Dmitrii Golovanov 68d1a52417 posix: sched: Implement get APIs for scheduling parameters
Initial implementation of `sched_getparam()` and `sched_getscheduler()`
POSIX APIs as a part of PSE53 `_POSIX_PRIORITY_SCHEDULING` option group.
Both functions are actually placeholders and just return `ENOSYS`
since Zephyr does not yet support processes or process scheduling.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
2024-01-15 09:57:44 +01:00

72 lines
1.1 KiB
C

/*
* Copyright (c) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "pthread_sched.h"
#include <zephyr/kernel.h>
#include <zephyr/posix/sched.h>
/**
* @brief Get minimum priority value for a given policy
*
* See IEEE 1003.1
*/
int sched_get_priority_min(int policy)
{
if (!valid_posix_policy(policy)) {
errno = EINVAL;
return -1;
}
return 0;
}
/**
* @brief Get maximum priority value for a given policy
*
* See IEEE 1003.1
*/
int sched_get_priority_max(int policy)
{
if (IS_ENABLED(CONFIG_COOP_ENABLED) && policy == SCHED_FIFO) {
return CONFIG_NUM_COOP_PRIORITIES - 1;
} else if (IS_ENABLED(CONFIG_PREEMPT_ENABLED) &&
(policy == SCHED_RR || policy == SCHED_OTHER)) {
return CONFIG_NUM_PREEMPT_PRIORITIES - 1;
}
errno = EINVAL;
return -1;
}
/**
* @brief Get scheduling parameters
*
* See IEEE 1003.1
*/
int sched_getparam(pid_t pid, struct sched_param *param)
{
ARG_UNUSED(pid);
ARG_UNUSED(param);
errno = ENOSYS;
return -1;
}
/**
* @brief Get scheduling policy
*
* See IEEE 1003.1
*/
int sched_getscheduler(pid_t pid)
{
ARG_UNUSED(pid);
errno = ENOSYS;
return -1;
}