Nonblocking mail_receive, fix proc_kill scheduling issues
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m15s

This commit is contained in:
2026-03-17 21:36:09 +01:00
parent 57abf96daf
commit 0b85d3a0da
14 changed files with 121 additions and 60 deletions

View File

@@ -274,6 +274,35 @@ DEFINE_SYSCALL (sys_mail_receive) {
return SYSRESULT (ST_OK);
}
/* int mail_receive_nonblock (void* recv_mesg, size_t mesg_size) */
DEFINE_SYSCALL (sys_mail_receive_nonblock) {
uint64_t fp;
uintptr_t uvaddr_mesg = a1;
size_t mesg_size = (size_t)a2;
spin_lock (&proc->lock, &fp);
struct procgroup* procgroup = proc->procgroup;
spin_unlock (&proc->lock, fp);
void* mesg = sys_get_user_buffer (procgroup, uvaddr_mesg, mesg_size);
if (mesg == NULL)
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
struct proc_resource* mail_resource = proc_find_resource (procgroup, 0);
if (mail_resource == NULL)
return SYSRESULT (-ST_NOT_FOUND);
bool r = proc_mail_receive_nonblock (proc, &mail_resource->u.mail, rctx, mesg, mesg_size);
if (r)
return SYSRESULT (ST_OK);
else
return SYSRESULT (-ST_TRY_AGAIN);
}
/* int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4) */
DEFINE_SYSCALL (sys_device_do) {
uint64_t fpg, fd, fp;
@@ -1025,6 +1054,7 @@ static syscall_handler_func_t handler_table[] = {
[SYS_ENV_GET] = &sys_env_get,
[SYS_EXEC_PARTIAL] = &sys_exec_partial,
[SYS_EXEC_PARTIAL_FINI] = &sys_exec_partial_fini,
[SYS_MAIL_RECEIVE_NONBLOCK] = &sys_mail_receive_nonblock,
};
syscall_handler_func_t syscall_find_handler (int syscall_num) {