This commit is contained in:
Remzi Arpaci-Dusseau
2018-04-04 13:42:13 -05:00
parent dbecc97f4f
commit 2413114247

View File

@@ -16,22 +16,22 @@ library, with a `thread_create()` call and `lock_acquire()` and
Your new clone system call should look like this: `int Your new clone system call should look like this: `int
clone(void(*fcn)(void*), void *arg1, void *arg2, void *stack)`. This call clone(void(*fcn)(void*), void *arg1, void *arg2, void *stack)`. This call
creates a new kernel thread which shares the calling process's address creates a new kernel thread which shares the calling process's address
space. File descriptors are copied as in fork. The new process uses `stack` as space. File descriptors are copied as in `fork()`. The new process uses
its user stack, which is passed two arguments (`arg1` and `arg2`) and uses a `stack` as its user stack, which is passed two arguments (`arg1` and `arg2`)
fake return PC (`0xffffffff`); a proper thread will simply call `exit()` when and uses a fake return PC (`0xffffffff`); a proper thread will simply call
it is done (and not `return`). The stack should be one page in size and `exit()` when it is done (and not `return`). The stack should be one page in
page-aligned. The new thread starts executing at the address specified by size and page-aligned. The new thread starts executing at the address
`fcn`. As with `fork()`, the PID of the new thread is returned to the parent specified by `fcn`. As with `fork()`, the PID of the new thread is returned to
(for simplicity, threads each have their own process ID). the parent (for simplicity, threads each have their own process ID).
The other new system call is int `join(void **stack)`. This call waits for a The other new system call is `int join(void **stack)`. This call waits for a
child thread that shares the address space with the calling process to child thread that shares the address space with the calling process to
exit. It returns the PID of waited-for child or -1 if none. The location of exit. It returns the PID of waited-for child or -1 if none. The location of
the child's user stack is copied into the argument `stack` (which can then be the child's user stack is copied into the argument `stack` (which can then be
freed). freed).
You also need to think about the semantics of a couple of existing system You also need to think about the semantics of a couple of existing system
calls. For example, int `wait()` should wait for a child process that does not calls. For example, `int wait()` should wait for a child process that does not
share the address space with this process. It should also free the address share the address space with this process. It should also free the address
space if this is last reference to it. Also, `exit()` should work as before space if this is last reference to it. Also, `exit()` should work as before
but for both processes and threads; little change is required here. but for both processes and threads; little change is required here.