summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-06-03 17:59:17 -0400
committerRobert Morris <[email protected]>2019-06-03 17:59:17 -0400
commitcefe223bf5e4b68e5c1202f2f089a164ad656621 (patch)
treeb2bf9fdb2c94e3159ce595c6b4a88daf5c35e878 /proc.c
parentefecbee7c0c265b0b2fe956f308e1a73cc63eda6 (diff)
downloadxv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.tar.gz
xv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.tar.bz2
xv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.zip
console input and sbrk
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c66
1 files changed, 2 insertions, 64 deletions
diff --git a/proc.c b/proc.c
index 36b767d..f1558d0 100644
--- a/proc.c
+++ b/proc.c
@@ -184,8 +184,6 @@ userinit(void)
release(&ptable.lock);
}
-#if 0
-
// Grow current process's memory by n bytes.
// Return 0 on success, -1 on failure.
int
@@ -196,17 +194,15 @@ growproc(int n)
sz = p->sz;
if(n > 0){
- if((sz = allocuvm(p->pagetable, sz, sz + n)) == 0)
+ if((sz = uvmalloc(p->pagetable, sz, sz + n)) == 0)
return -1;
} else if(n < 0){
if((sz = uvmdealloc(p->pagetable, sz, sz + n)) == 0)
return -1;
}
p->sz = sz;
- switchuvm(p);
return 0;
}
-#endif
// Create a new process, copying p as the parent.
// Sets up child kernel stack to return as if from system call.
@@ -363,24 +359,7 @@ scheduler(void)
c->proc = 0;
for(;;){
// Enable interrupts on this processor.
- // XXX riscv
- //sti();
-
- if(0){ uint x = * (uint*) 0xc001000;
- if(x != 0){
- printf("pending %x\n", x);
- }
- x = *(uint*)0xc001004;
- if(x != 0)
- printf("pending %x\n", x);
- }
-
- if(0){
- uint uartgetc(void);
- uint x = uartgetc();
- if(x != 0)
- printf("%x ", x);
- }
+ intr_on();
// Loop over process table looking for process to run.
acquire(&ptable.lock);
@@ -394,9 +373,7 @@ scheduler(void)
c->proc = p;
p->state = RUNNING;
- printf("switch...\n");
swtch(&c->scheduler, &p->context);
- printf("switch returned\n");
// Process is done running for now.
// It should have changed its p->state before coming back.
@@ -450,8 +427,6 @@ forkret(void)
// Still holding ptable.lock from scheduler.
release(&ptable.lock);
- printf("entering forkret\n");
-
if (first) {
// Some initialization functions must be run in the context
// of a regular process (e.g., they call sleep), and thus cannot
@@ -550,41 +525,4 @@ kill(int pid)
return -1;
}
-//PAGEBREAK: 36
-// Print a process listing to console. For debugging.
-// Runs when user types ^P on console.
-// No lock to avoid wedging a stuck machine further.
-void
-procdump(void)
-{
- static char *states[] = {
- [UNUSED] "unused",
- [EMBRYO] "embryo",
- [SLEEPING] "sleep ",
- [RUNNABLE] "runble",
- [RUNNING] "run ",
- [ZOMBIE] "zombie"
- };
- int i;
- struct proc *p;
- char *state;
- uint64 pc[10];
-
- for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){
- if(p->state == UNUSED)
- continue;
- if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
- state = states[p->state];
- else
- state = "???";
- printf("%d %s %s", p->pid, state, p->name);
- if(p->state == SLEEPING){
- getcallerpcs((uint64*)p->context->rbp+2, pc);
- for(i=0; i<10 && pc[i] != 0; i++)
- printf(" %p", pc[i]);
- }
- printf("\n");
- }
-}
-
#endif