void
pipe_close(struct pipe *p, int writeable)
{
+ acquire(&p->lock);
+
if(writeable){
p->writeopen = 0;
wakeup(&p->readp);
p->readopen = 0;
wakeup(&p->writep);
}
+
+ release(&p->lock);
+
if(p->readopen == 0 && p->writeopen == 0)
kfree((char *) p, PAGE);
}
// Set up new jmpbuf to start executing at forkret (see below).
memset(&np->jmpbuf, 0, sizeof np->jmpbuf);
np->jmpbuf.eip = (uint)forkret;
- np->jmpbuf.esp = (uint)np->tf;
+ np->jmpbuf.esp = (uint)np->tf - 4;
// Copy file descriptors
for(i = 0; i < NOFILE; i++){
* System call number in %eax.
* Arguments on the stack, from the user call to the C
* library system call function. The saved user %esp points
- * to a saved frame pointer, a program counter, and then
- * the first argument.
+ * to a saved program counter, and then the first argument.
*
* Return value? Error indication? Errno?
*/
}
int
-putint(struct proc *p, uint addr, int ip)
+putint(struct proc *p, uint addr, int x)
{
if(addr > p->sz - 4)
return -1;
- memmove(p->mem + addr, &ip, 4);
+ memmove(p->mem + addr, &x, 4);
return 0;
}
int num = cp->tf->eax;
int ret = -1;
- //cprintf("%x sys %d\n", cp, num);
switch(num){
case SYS_fork:
ret = sys_fork();