Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eintr: support for blocking syscall INTR (interrupted) mode #13

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernel/src/managers/interrupt/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ stack_frame_t *userisr_handler(stack_frame_t *frame, int IRQn)
* function only if needed
*/
mgr_time_delay_del_job(owner);
mgr_task_set_sysreturn(owner, STATUS_OK);
mgr_task_set_sysreturn(owner, STATUS_INTR);
mgr_task_set_state(owner, JOB_STATE_READY);
sched_schedule(owner);
}
Expand Down
3 changes: 1 addition & 2 deletions kernel/src/syscalls/sysgate_send_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ stack_frame_t *gate_send_ipc(stack_frame_t *frame, taskh_t target, uint32_t len)
* function only if needed
*/
mgr_time_delay_del_job(target);
/* FIXME: define a dedicated return code */
mgr_task_set_sysreturn(target, STATUS_OK);
mgr_task_set_sysreturn(target, STATUS_INTR);
mgr_task_set_state(target, JOB_STATE_READY);
sched_schedule(target);
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/syscalls/sysgate_send_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ stack_frame_t *gate_send_signal(stack_frame_t *frame,
*/
mgr_time_delay_del_job(target);
/* FIXME: define a dedicated return code */
mgr_task_set_sysreturn(target, STATUS_OK);
mgr_task_set_sysreturn(target, STATUS_INTR);
mgr_task_set_state(target, JOB_STATE_READY);
sched_schedule(target);
}
Expand Down
1 change: 1 addition & 0 deletions uapi/include/uapi/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ typedef enum Status {
STATUS_CRITICAL,
STATUS_TIMEOUT,
STATUS_AGAIN,
STATUS_INTR,
STATUS_NON_SENSE,
} Status;

Expand Down
5 changes: 4 additions & 1 deletion uapi/uapi/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ pub extern "C" fn sys_irq_disable(irq: u16) -> Status {
/// POSIX upper layer(s): select(2), poll(2)
#[no_mangle]
pub extern "C" fn sys_wait_for_event(mask: u8, timeout: i32) -> Status {
syscall!(Syscall::WaitForEvent, u32::from(mask), timeout).into()
match syscall!(Syscall::WaitForEvent, u32::from(mask), timeout).into() {
Status::Intr => syscall!(Syscall::WaitForEvent, u32::from(mask), timeout).into(),
any => return any,
}
}

/// Configure the CPU's sleep behaviour.
Expand Down
2 changes: 2 additions & 0 deletions uapi/uapi/systypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ pub enum Status {
Critical,
Timeout,
Again,
Intr,
}

impl From<u32> for Status {
Expand All @@ -141,6 +142,7 @@ impl From<u32> for Status {
7 => Status::Critical,
8 => Status::Timeout,
9 => Status::Again,
10 => Status::Intr,
_ => panic!(),
}
}
Expand Down
Loading