I am having a bug in my FORK routine for about half a year now, and I just cannot find the solution. I now hope that you might be able to find it, although it quite much code, and it assumes a certain "qualification". I will describe at first:
My FORK system call calls the function do_fork(). This one creates a new stack (malloc) for the child, and copies the parent's one onto it. Next, it just changes the relevant bits (EIP, EBP, EAX and so on) and puts it on the process queue. That is the simplified story of it and there are some more bits like getting CR3 and so on, but those are not interesting.
I attached my kernel/fork.c and added some more comments that may be useful for you.
The problem:
Code: Select all
void func(void)
{
int pid = fork();
if (pid > 0) { /* parent */
for (;;) printf("blabla");
}
else { /* child */
void *tmp = &pid;
for (;;)
if ((void*) &pid != tmp) panic("Stack changed");
}
}
Thanks,
Alexander
PS: Maybe Tim or Pype will be able to find the bug?
[attachment deleted by admin]