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:

  1. Copy parent's trap frame, and pass it to child thread
  2. Copy parent's address space
  3. Create child thread (using thread_fork)
  4. Copy parent's file table into child
  5. Parent returns with child's pid immediately
  6. Child returns with 0

So, let's get started.

more ...