Merge branch 'riscv-killed' into riscv
This commit is contained in:
commit
cd6207a972
|
@ -89,7 +89,7 @@ consoleread(int user_dst, uint64 dst, int n)
|
|||
// wait until interrupt handler has put some
|
||||
// input into cons.buffer.
|
||||
while(cons.r == cons.w){
|
||||
if(myproc()->killed){
|
||||
if(killed(myproc())){
|
||||
release(&cons.lock);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -90,6 +90,8 @@ void proc_mapstacks(pagetable_t);
|
|||
pagetable_t proc_pagetable(struct proc *);
|
||||
void proc_freepagetable(pagetable_t, uint64);
|
||||
int kill(int);
|
||||
int killed(struct proc*);
|
||||
void setkilled(struct proc*);
|
||||
struct cpu* mycpu(void);
|
||||
struct cpu* getmycpu(void);
|
||||
struct proc* myproc();
|
||||
|
|
|
@ -81,7 +81,7 @@ pipewrite(struct pipe *pi, uint64 addr, int n)
|
|||
|
||||
acquire(&pi->lock);
|
||||
while(i < n){
|
||||
if(pi->readopen == 0 || pr->killed){
|
||||
if(pi->readopen == 0 || killed(pr)){
|
||||
release(&pi->lock);
|
||||
return -1;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ piperead(struct pipe *pi, uint64 addr, int n)
|
|||
|
||||
acquire(&pi->lock);
|
||||
while(pi->nread == pi->nwrite && pi->writeopen){ //DOC: pipe-empty
|
||||
if(pr->killed){
|
||||
if(killed(pr)){
|
||||
release(&pi->lock);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -424,7 +424,7 @@ wait(uint64 addr)
|
|||
}
|
||||
|
||||
// No point waiting if we don't have any children.
|
||||
if(!havekids || p->killed){
|
||||
if(!havekids || killed(p)){
|
||||
release(&wait_lock);
|
||||
return -1;
|
||||
}
|
||||
|
@ -603,6 +603,25 @@ kill(int pid)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
setkilled(struct proc *p)
|
||||
{
|
||||
acquire(&p->lock);
|
||||
p->killed = 1;
|
||||
release(&p->lock);
|
||||
}
|
||||
|
||||
int
|
||||
killed(struct proc *p)
|
||||
{
|
||||
int k;
|
||||
|
||||
acquire(&p->lock);
|
||||
k = p->killed;
|
||||
release(&p->lock);
|
||||
return k;
|
||||
}
|
||||
|
||||
// Copy to either a user address, or kernel address,
|
||||
// depending on usr_dst.
|
||||
// Returns 0 on success, -1 on error.
|
||||
|
|
|
@ -58,7 +58,7 @@ sys_sleep(void)
|
|||
acquire(&tickslock);
|
||||
ticks0 = ticks;
|
||||
while(ticks - ticks0 < n){
|
||||
if(myproc()->killed){
|
||||
if(killed(myproc())){
|
||||
release(&tickslock);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ usertrap(void)
|
|||
if(r_scause() == 8){
|
||||
// system call
|
||||
|
||||
if(p->killed)
|
||||
if(killed(p))
|
||||
exit(-1);
|
||||
|
||||
// sepc points to the ecall instruction,
|
||||
|
@ -70,10 +70,10 @@ usertrap(void)
|
|||
} else {
|
||||
printf("usertrap(): unexpected scause %p pid=%d\n", r_scause(), p->pid);
|
||||
printf(" sepc=%p stval=%p\n", r_sepc(), r_stval());
|
||||
p->killed = 1;
|
||||
setkilled(p);
|
||||
}
|
||||
|
||||
if(p->killed)
|
||||
if(killed(p))
|
||||
exit(-1);
|
||||
|
||||
// give up the CPU if this is a timer interrupt.
|
||||
|
|
Loading…
Reference in a new issue