|
|
@ -31,6 +31,7 @@ optional_int ecall_handle_spawn_thread(int* args_ptr, ProcessControlBlock* pcb)
|
|
|
|
optional_int ecall_handle_sleep(int* args, ProcessControlBlock* pcb)
|
|
|
|
optional_int ecall_handle_sleep(int* args, ProcessControlBlock* pcb)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int len = args[0];
|
|
|
|
int len = args[0];
|
|
|
|
|
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
if (len < 0) {
|
|
|
|
return (optional_int) { .error = EINVAL };
|
|
|
|
return (optional_int) { .error = EINVAL };
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -59,10 +60,12 @@ optional_int ecall_handle_join(int* args, ProcessControlBlock* pcb)
|
|
|
|
pcb->waiting_for_process = target;
|
|
|
|
pcb->waiting_for_process = target;
|
|
|
|
|
|
|
|
|
|
|
|
int timeout = args[1];
|
|
|
|
int timeout = args[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (timeout <= 0)
|
|
|
|
if (timeout <= 0)
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int len = (unsigned int) timeout;
|
|
|
|
unsigned int len = (unsigned int) timeout;
|
|
|
|
|
|
|
|
|
|
|
|
pcb->asleep_until = read_time() + len;
|
|
|
|
pcb->asleep_until = read_time() + len;
|
|
|
|
|
|
|
|
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|
return (optional_int) { .value = 0 };
|
|
|
|