mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
增加进程的调度policy属性 (#63)
* 添加进程的policy属性 * update * 修改设置进程策略 * 删除重复定义 * 更正注释及格式 Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
@ -36,29 +36,29 @@
|
||||
|
||||
struct thread_struct
|
||||
{
|
||||
// 内核层栈基指针
|
||||
ul rbp; // in tss rsp0
|
||||
// 内核层代码指针
|
||||
ul rip;
|
||||
// 内核层栈指针
|
||||
ul rsp;
|
||||
// 内核层栈基指针
|
||||
ul rbp; // in tss rsp0
|
||||
// 内核层代码指针
|
||||
ul rip;
|
||||
// 内核层栈指针
|
||||
ul rsp;
|
||||
|
||||
ul fs, gs;
|
||||
ul fs, gs;
|
||||
|
||||
ul cr2;
|
||||
// 异常号
|
||||
ul trap_num;
|
||||
// 错误码
|
||||
ul err_code;
|
||||
ul cr2;
|
||||
// 异常号
|
||||
ul trap_num;
|
||||
// 错误码
|
||||
ul err_code;
|
||||
};
|
||||
|
||||
// ========= pcb->flags =========
|
||||
// 进程标志位
|
||||
#define PF_KTHREAD (1UL << 0) // 内核线程
|
||||
#define PF_KTHREAD (1UL << 0) // 内核线程
|
||||
#define PF_NEED_SCHED (1UL << 1) // 进程需要被调度
|
||||
#define PF_VFORK (1UL << 2) // 标志进程是否由于vfork而存在资源共享
|
||||
#define PF_KFORK (1UL << 3) // 标志在内核态下调用fork(临时标记,do_fork()结束后会将其复位)
|
||||
#define PF_NOFREEZE (1UL << 4) // 当前进程不能被冻结
|
||||
#define PF_VFORK (1UL << 2) // 标志进程是否由于vfork而存在资源共享
|
||||
#define PF_KFORK (1UL << 3) // 标志在内核态下调用fork(临时标记,do_fork()结束后会将其复位)
|
||||
#define PF_NOFREEZE (1UL << 4) // 当前进程不能被冻结
|
||||
|
||||
/**
|
||||
* @brief 进程控制块
|
||||
@ -66,70 +66,70 @@ struct thread_struct
|
||||
*/
|
||||
struct process_control_block
|
||||
{
|
||||
// 进程的状态
|
||||
volatile long state;
|
||||
// 进程标志:进程、线程、内核线程
|
||||
unsigned long flags;
|
||||
int64_t preempt_count; // 持有的自旋锁的数量
|
||||
long signal;
|
||||
long cpu_id; // 当前进程在哪个CPU核心上运行
|
||||
// 内存空间分布结构体, 记录内存页表和程序段信息
|
||||
struct mm_struct *mm;
|
||||
// 进程的状态
|
||||
volatile long state;
|
||||
// 进程标志:进程、线程、内核线程
|
||||
unsigned long flags;
|
||||
int64_t preempt_count; // 持有的自旋锁的数量
|
||||
long signal;
|
||||
long cpu_id; // 当前进程在哪个CPU核心上运行
|
||||
// 内存空间分布结构体, 记录内存页表和程序段信息
|
||||
struct mm_struct *mm;
|
||||
|
||||
// 进程切换时保存的状态信息
|
||||
struct thread_struct *thread;
|
||||
// 进程切换时保存的状态信息
|
||||
struct thread_struct *thread;
|
||||
|
||||
// 连接各个pcb的双向链表
|
||||
struct List list;
|
||||
// 连接各个pcb的双向链表
|
||||
struct List list;
|
||||
|
||||
// 地址空间范围
|
||||
// 用户空间: 0x0000 0000 0000 0000 ~ 0x0000 7fff ffff ffff
|
||||
// 内核空间: 0xffff 8000 0000 0000 ~ 0xffff ffff ffff ffff
|
||||
uint64_t addr_limit;
|
||||
// 地址空间范围
|
||||
// 用户空间: 0x0000 0000 0000 0000 ~ 0x0000 7fff ffff ffff
|
||||
// 内核空间: 0xffff 8000 0000 0000 ~ 0xffff ffff ffff ffff
|
||||
uint64_t addr_limit;
|
||||
|
||||
long pid;
|
||||
long priority; // 优先级
|
||||
int64_t virtual_runtime; // 虚拟运行时间
|
||||
long pid;
|
||||
long priority; // 优先级
|
||||
int64_t virtual_runtime; // 虚拟运行时间
|
||||
|
||||
// 进程拥有的文件描述符的指针数组
|
||||
// todo: 改用动态指针数组
|
||||
struct vfs_file_t *fds[PROC_MAX_FD_NUM];
|
||||
// 进程拥有的文件描述符的指针数组
|
||||
// todo: 改用动态指针数组
|
||||
struct vfs_file_t *fds[PROC_MAX_FD_NUM];
|
||||
|
||||
// 链表中的下一个pcb
|
||||
struct process_control_block *next_pcb;
|
||||
// 父进程的pcb
|
||||
struct process_control_block *parent_pcb;
|
||||
// 链表中的下一个pcb
|
||||
struct process_control_block *next_pcb;
|
||||
// 父进程的pcb
|
||||
struct process_control_block *parent_pcb;
|
||||
|
||||
int32_t exit_code; // 进程退出时的返回码
|
||||
wait_queue_node_t wait_child_proc_exit; // 子进程退出等待队列
|
||||
int32_t exit_code; // 进程退出时的返回码
|
||||
uint32_t policy; // 进程调度策略标志位
|
||||
wait_queue_node_t wait_child_proc_exit; // 子进程退出等待队列
|
||||
|
||||
/* PF_kTHREAD | PF_IO_WORKER 的进程,worker_private不为NULL*/
|
||||
void *worker_private;
|
||||
/* PF_kTHREAD | PF_IO_WORKER 的进程,worker_private不为NULL*/
|
||||
void *worker_private;
|
||||
};
|
||||
|
||||
// 将进程的pcb和内核栈融合到一起,8字节对齐
|
||||
union proc_union
|
||||
{
|
||||
struct process_control_block pcb;
|
||||
ul stack[STACK_SIZE / sizeof(ul)];
|
||||
union proc_union {
|
||||
struct process_control_block pcb;
|
||||
ul stack[STACK_SIZE / sizeof(ul)];
|
||||
} __attribute__((aligned(8)));
|
||||
|
||||
struct tss_struct
|
||||
{
|
||||
unsigned int reserved0;
|
||||
ul rsp0;
|
||||
ul rsp1;
|
||||
ul rsp2;
|
||||
ul reserved1;
|
||||
ul ist1;
|
||||
ul ist2;
|
||||
ul ist3;
|
||||
ul ist4;
|
||||
ul ist5;
|
||||
ul ist6;
|
||||
ul ist7;
|
||||
ul reserved2;
|
||||
unsigned short reserved3;
|
||||
// io位图基地址
|
||||
unsigned short io_map_base_addr;
|
||||
unsigned int reserved0;
|
||||
ul rsp0;
|
||||
ul rsp1;
|
||||
ul rsp2;
|
||||
ul reserved1;
|
||||
ul ist1;
|
||||
ul ist2;
|
||||
ul ist3;
|
||||
ul ist4;
|
||||
ul ist5;
|
||||
ul ist6;
|
||||
ul ist7;
|
||||
ul reserved2;
|
||||
unsigned short reserved3;
|
||||
// io位图基地址
|
||||
unsigned short io_map_base_addr;
|
||||
} __attribute__((packed)); // 使用packed表明是紧凑结构,编译器不会对成员变量进行字节对齐。
|
@ -45,7 +45,8 @@
|
||||
.parent_pcb = &proc, \
|
||||
.exit_code = 0, \
|
||||
.wait_child_proc_exit = 0, \
|
||||
.worker_private = NULL \
|
||||
.worker_private = NULL, \
|
||||
.policy = SCHED_NORMAL \
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,7 +184,7 @@ void process_exit_notify();
|
||||
* @return int
|
||||
*/
|
||||
|
||||
pid_t kernel_thread(int (*fn)(void*), void* arg, unsigned long flags);
|
||||
pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
|
||||
|
||||
int process_fd_alloc(struct vfs_file_t *file);
|
||||
|
||||
|
Reference in New Issue
Block a user