diff options
| author | Hanjie Wu <hanjiew@andrew.cmu.edu> | 2023-04-18 02:21:10 -0400 |
|---|---|---|
| committer | Hanjie Wu <hanjiew@andrew.cmu.edu> | 2023-04-18 02:21:10 -0400 |
| commit | c71294cdd3581c3738d24ffd65414f8644a1094d (patch) | |
| tree | c86245d50fad9eee4163dbba169bd1839edbf88f /user/libthread/thread_fork.S | |
initial commit
Diffstat (limited to 'user/libthread/thread_fork.S')
| -rw-r--r-- | user/libthread/thread_fork.S | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/user/libthread/thread_fork.S b/user/libthread/thread_fork.S new file mode 100644 index 0000000..143f17b --- /dev/null +++ b/user/libthread/thread_fork.S @@ -0,0 +1,26 @@ +#include <syscall_int.h> + +// int thread_fork(tcb_t* tcb, +// void* (*f)(void*), +// void* args); +.global thread_fork +.type thread_fork, %function +thread_fork: + mov 0x4(%esp), %edi // tcb + mov 0x8(%esp), %esi // f + mov 0xc(%esp), %edx // arg + int $THREAD_FORK_INT + cmp $0, %eax + jne .parent // both failure and success returns non-zero for parent + mov 0x8(%edi), %esp // read tcb.stack_hi and set stack + push %edx + push %esi + call thr_begin // thread entry point and this will not return +.parent: + ret + +.global get_esp +.type get_esp, %function +get_esp: + lea -0x4(%esp), %eax + ret |
