修复进程终止的BUG

This commit is contained in:
xiaoyi1212 2024-04-13 22:22:25 +08:00
parent f4519da582
commit a118bbec58
4 changed files with 22 additions and 6 deletions

View File

@ -32,4 +32,7 @@ int vsprintf(char *buf, const char *fmt, va_list args);
int sprintf(char *buf, const char *fmt, ...); int sprintf(char *buf, const char *fmt, ...);
long int strtol(const char *str,char **endptr,int base); long int strtol(const char *str,char **endptr,int base);
void reset_kernel();
void shutdown_kernel();
#endif //CRASHPOWEROS_COMMON_H #endif //CRASHPOWEROS_COMMON_H

View File

@ -15,6 +15,16 @@ extern uint32_t end;
extern int status; extern int status;
uint32_t placement_address = (uint32_t) & end; uint32_t placement_address = (uint32_t) & end;
void reset_kernel(){
printf("Restart %s for x86...",OS_NAME);
clock_sleep(10);
outb(0x64,0xfe);
}
void shutdown_kernel(){
//TODO ACPI Driver
}
void kernel_main(multiboot_t *multiboot) { void kernel_main(multiboot_t *multiboot) {
io_cli(); io_cli();
vga_install(); vga_install();

View File

@ -62,7 +62,7 @@ void print_proc(){
printf("Name Pid Status [All Proc: %d]\n\n",index); printf("Name Pid Status [All Proc: %d]\n\n",index);
} }
static void found_task(int pid,struct task_struct *base,struct task_struct *argv){ static void found_task(int pid,struct task_struct *head,struct task_struct *base,struct task_struct *argv,int first){
struct task_struct *t = base; struct task_struct *t = base;
if(t == NULL){ if(t == NULL){
argv = NULL; argv = NULL;
@ -72,13 +72,18 @@ static void found_task(int pid,struct task_struct *base,struct task_struct *argv
*argv = *t; *argv = *t;
return; return;
} else{ } else{
found_task(pid,t->next,argv); if(!first)
if(head->pid == t->pid){
argv = NULL;
return;
}
found_task(pid,head,t->next,argv,0);
} }
} }
void task_kill(int pid){ void task_kill(int pid){
struct task_struct *argv; struct task_struct *argv;
found_task(pid,running_proc_head,argv); found_task(pid,running_proc_head,running_proc_head,argv,1);
if(argv == NULL){ if(argv == NULL){
printf("Cannot found task Pid:[%d].\n",pid); printf("Cannot found task Pid:[%d].\n",pid);
return; return;

View File

@ -181,9 +181,7 @@ void cmd_del(int argc, char **argv) {
} }
void cmd_reset(){ void cmd_reset(){
printf("Restart %s for x86...",OS_NAME); reset_kernel();
clock_sleep(10);
outb(0x64,0xfe);
} }
void setup_shell(){ void setup_shell(){