kernel: Add sleep_task
This commit is contained in:
parent
c2960e8fd7
commit
d61c54d985
|
@ -20,6 +20,7 @@ get_current_task_id: jmp [0x00000A1C]
|
|||
get_unused_task_id: jmp [0x00000A20]
|
||||
is_task_id_used: jmp [0x00000A24]
|
||||
save_state_and_yield_task: jmp [0x00000A28]
|
||||
sleep_task: jmp [0x00000A2C]
|
||||
|
||||
; memory jump table
|
||||
allocate_memory: jmp [0x00000B10]
|
||||
|
|
|
@ -42,6 +42,7 @@ jump_table:
|
|||
data.32 get_unused_task_id
|
||||
data.32 is_task_id_used
|
||||
data.32 save_state_and_yield_task
|
||||
data.32 sleep_task
|
||||
|
||||
; memory jump table
|
||||
org.pad 0x00000310
|
||||
|
|
|
@ -122,6 +122,27 @@ save_state_and_yield_task:
|
|||
pop rfp
|
||||
ret
|
||||
|
||||
; yield for at least the specified number of ms
|
||||
; inputs:
|
||||
; r0: minimum ms to yield for
|
||||
; outputs:
|
||||
; none
|
||||
sleep_task:
|
||||
push r0
|
||||
push r1
|
||||
|
||||
in r1, 0x80000706
|
||||
add r0, r1
|
||||
sleep_task_loop:
|
||||
call save_state_and_yield_task
|
||||
in r1, 0x80000706
|
||||
cmp r1, r0
|
||||
iflt jmp sleep_task_loop
|
||||
|
||||
pop r1
|
||||
pop r0
|
||||
ret
|
||||
|
||||
; switch to the next task without adding the current task back into the queue
|
||||
; this will automatically free the task's code and stack blocks
|
||||
; inputs:
|
||||
|
|
Loading…
Reference in New Issue
Block a user