Added code to get the consoles to be split into their own
Fixed issue where exiting a shell would not close the parent console properly Changed the way the consoles are linked to the processes by making it a pointer to the console Added all the console changes for the above Added a slow maze drawing program similar to the c64 version
This commit is contained in:
13
proc.c
13
proc.c
@ -112,7 +112,7 @@ 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;
|
||||
p->consoleptr = getbaseconsoleptr();
|
||||
|
||||
return p;
|
||||
}
|
||||
@ -142,7 +142,7 @@ void userinit(void) {
|
||||
safestrcpy(p->name, "initcode", sizeof(p->name));
|
||||
p->cwd = namei("/");
|
||||
|
||||
p->consoleIndex = 0;
|
||||
p->consoleptr = getbaseconsoleptr();
|
||||
safestrcpy(p->title, "Shell (Root)", sizeof(p->title));
|
||||
|
||||
// this assignment to p->state lets other cores
|
||||
@ -219,7 +219,7 @@ int fork(void) {
|
||||
acquire(&ptable.lock);
|
||||
|
||||
np->state = RUNNABLE;
|
||||
np->consoleIndex = curproc->consoleIndex;
|
||||
np->consoleptr = curproc->consoleptr;
|
||||
|
||||
release(&ptable.lock);
|
||||
|
||||
@ -260,16 +260,16 @@ void exit(void) {
|
||||
for (p = ptable.proc; p < &ptable.proc[NPROC]; p++) {
|
||||
if (p->parent == curproc) {
|
||||
p->parent = initproc;
|
||||
p->consoleIndex = 0;
|
||||
p->consoleptr = getbaseconsoleptr();
|
||||
if (p->state == ZOMBIE) {
|
||||
wakeup1(initproc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (curproc->consoleIndex != 0 && curproc->consoleIndex == getcurrentconsoleindex())
|
||||
if (curproc->consoleptr != getbaseconsoleptr())
|
||||
{
|
||||
closeconsole(curproc->consoleIndex);
|
||||
closeconsole();
|
||||
}
|
||||
|
||||
// Jump into the scheduler, never to return.
|
||||
@ -305,6 +305,7 @@ int wait(void) {
|
||||
p->name[0] = 0;
|
||||
p->killed = 0;
|
||||
p->state = UNUSED;
|
||||
p->consoleptr = 0;
|
||||
release(&ptable.lock);
|
||||
return pid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user