实现设置pcb名字和vsnprintf (#72)

* 实现pcb设置名字

* 实现设置pcb名字,实现vsnprintf

* 修改set_pcb_name和va_end

* bugfix: 修正一些小问题

Co-authored-by: longjin <longjin@RinGoTek.cn>
This commit is contained in:
houmkh
2022-10-31 20:46:20 +08:00
committed by GitHub
parent 8a080f3cce
commit 8e3f5674f8
10 changed files with 174 additions and 47 deletions

View File

@ -135,8 +135,10 @@ void __switch_to(struct process_control_block *prev, struct process_control_bloc
// initial_tss[0].ist2, initial_tss[0].ist3, initial_tss[0].ist4, initial_tss[0].ist5,
// initial_tss[0].ist6, initial_tss[0].ist7);
__asm__ __volatile__("movq %%fs, %0 \n\t" : "=a"(prev->thread->fs));
__asm__ __volatile__("movq %%gs, %0 \n\t" : "=a"(prev->thread->gs));
__asm__ __volatile__("movq %%fs, %0 \n\t"
: "=a"(prev->thread->fs));
__asm__ __volatile__("movq %%gs, %0 \n\t"
: "=a"(prev->thread->gs));
__asm__ __volatile__("movq %0, %%fs \n\t" ::"a"(next->thread->fs));
__asm__ __volatile__("movq %0, %%gs \n\t" ::"a"(next->thread->gs));
@ -1194,4 +1196,29 @@ int process_fd_alloc(struct vfs_file_t *file)
}
}
return fd_num;
}
}
/**
* @brief 给pcb设置名字
*
* @param pcb 需要设置名字的pcb
* @param pcb_name 保存名字的char数组
*/
static void __set_pcb_name(struct process_control_block *pcb, const char *pcb_name)
{
//todo:给pcb加锁
// spin_lock(&pcb->alloc_lock);
strncpy(pcb->name,pcb_name,PCB_NAME_LEN);
// spin_unlock(&pcb->alloc_lock);
}
/**
* @brief 给pcb设置名字
*
* @param pcb 需要设置名字的pcb
* @param pcb_name 保存名字的char数组
*/
void process_set_pcb_name(struct process_control_block *pcb, const char *pcb_name)
{
__set_pcb_name(pcb, pcb_name);
}