mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-19 21:36:30 +00:00
增加进程的调度policy属性 (#63)
* 添加进程的policy属性 * update * 修改设置进程策略 * 删除重复定义 * 更正注释及格式 Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
@ -1,9 +1,53 @@
|
||||
#include "sched.h"
|
||||
#include <common/kprint.h>
|
||||
#include <driver/video/video.h>
|
||||
#include <common/spinlock.h>
|
||||
#include <driver/video/video.h>
|
||||
#include <sched/cfs.h>
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param p pcb
|
||||
* @param attr 调度属性
|
||||
* @param user 请求是否来自用户态
|
||||
* @param pi
|
||||
* @return int
|
||||
*/
|
||||
static int __sched_setscheduler(struct process_control_block *p, const struct sched_attr *attr, bool user, bool pi)
|
||||
{
|
||||
int policy = attr->sched_policy;
|
||||
recheck:;
|
||||
// 这里policy的设置小于0是因为,需要在临界区内更新值之后,重新到这里判断
|
||||
if (!IS_VALID_SCHED_POLICY(policy))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
// 修改成功
|
||||
p->policy = policy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _sched_setscheduler(struct process_control_block *p, int policy, const struct sched_param *param, bool check)
|
||||
{
|
||||
struct sched_attr attr = {.sched_policy = policy};
|
||||
|
||||
return __sched_setscheduler(p, &attr, check, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* sched_setscheduler -设置进程的调度策略
|
||||
* @param p 需要修改的pcb
|
||||
* @param policy 需要设置的policy
|
||||
* @param param structure containing the new RT priority. 目前没有用
|
||||
*
|
||||
* @return 成功返回0,否则返回对应的错误码
|
||||
*
|
||||
*/
|
||||
int sched_setscheduler(struct process_control_block *p, int policy, const struct sched_param *param)
|
||||
{
|
||||
return _sched_setscheduler(p, policy, param, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 包裹shced_cfs_enqueue(),将PCB加入就绪队列
|
||||
*
|
||||
|
Reference in New Issue
Block a user