Added buffer to the console
Added hotkeys to switch between console buffers and to return to the home one Added clear screen command Added debug text outputs to the hello command and when loading sh
This commit is contained in:
13
proc.c
13
proc.c
@ -112,7 +112,8 @@ static struct proc* allocproc(void) {
|
||||
p->context = (struct context*)sp;
|
||||
memset(p->context, 0, sizeof *p->context);
|
||||
p->context->eip = (uint)forkret;
|
||||
|
||||
p->consoleIndex = 0;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -141,6 +142,9 @@ void userinit(void) {
|
||||
safestrcpy(p->name, "initcode", sizeof(p->name));
|
||||
p->cwd = namei("/");
|
||||
|
||||
p->consoleIndex = 0;
|
||||
safestrcpy(p->title, "Shell (Root)", sizeof(p->title));
|
||||
|
||||
// this assignment to p->state lets other cores
|
||||
// run this process. the acquire forces the above
|
||||
// writes to be visible, and the lock is also needed
|
||||
@ -215,6 +219,7 @@ int fork(void) {
|
||||
acquire(&ptable.lock);
|
||||
|
||||
np->state = RUNNABLE;
|
||||
np->consoleIndex = curproc->consoleIndex;
|
||||
|
||||
release(&ptable.lock);
|
||||
|
||||
@ -255,12 +260,18 @@ void exit(void) {
|
||||
for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) {
|
||||
if (p->parent == curproc) {
|
||||
p->parent = initproc;
|
||||
p->consoleIndex = 0;
|
||||
if (p->state == ZOMBIE) {
|
||||
wakeup1(initproc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curproc->consoleIndex != 0 && curproc->consoleIndex == getcurrentconsoleindex())
|
||||
{
|
||||
closeconsole(curproc->consoleIndex);
|
||||
}
|
||||
|
||||
// Jump into the scheduler, never to return.
|
||||
curproc->state = ZOMBIE;
|
||||
sched();
|
||||
|
Reference in New Issue
Block a user