kernel: add thread_wait, thread_block and mtx
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
071a5651e0
commit
9c50a1df92
6 changed files with 49 additions and 3 deletions
|
|
@ -138,9 +138,28 @@ _timer_handler:
|
|||
|
||||
.global sched_restore_state
|
||||
sched_restore_state:
|
||||
mov rsp, [rdi + 8] /* load RSP from thread->kstack_ptr */
|
||||
pop_all
|
||||
ret
|
||||
mov rsp, [rdi + 8] /* load RSP from thread->kstack_ptr */
|
||||
pop_all
|
||||
ret
|
||||
|
||||
.global thread_wait
|
||||
thread_wait:
|
||||
push_all
|
||||
mov rax, qword ptr gs:[24] /* cur_thread */
|
||||
mov [rax + 8], rsp /* save rsp to kstack_ptr */
|
||||
mov qword ptr [rax + 32], 1 /* state = PROC_STATE_WAITING */
|
||||
call sched_add_thread /* re-add to run queue */
|
||||
call schedule
|
||||
/* not reached */
|
||||
|
||||
.global thread_block
|
||||
thread_block:
|
||||
push_all
|
||||
mov rax, qword ptr gs:[24] /* cur_thread */
|
||||
mov [rax + 8], rsp /* save rsp to kstack_ptr */
|
||||
mov qword ptr [rax + 32], 3 /* state = PROC_STATE_BLOCKED */
|
||||
call schedule
|
||||
/* not reached */
|
||||
|
||||
.global _syscall_enter
|
||||
_syscall_enter:
|
||||
|
|
|
|||
Loading…
Reference in a new issue