OS161 fork System Call
If you're not already familiar with UNIX fork system call, here is it's function description and its entry on Wikipedia.
Basically, in sys_fork
, we need to do the follow things:
- Copy parent's trap frame, and pass it to child thread
- Copy parent's address space
- Create child thread (using
thread_fork
) - Copy parent's file table into child
- Parent returns with child's pid immediately
- Child returns with 0
So, let's get started.
more ...