From 58fefac9f5691fa5f46339d89d66b296df2313f7 Mon Sep 17 00:00:00 2001 From: R Aadarsh Date: Wed, 10 Jun 2026 21:18:13 +0530 Subject: [PATCH] Enable sched params change --- Cargo.lock | 6 ++++-- Cargo.toml | 5 +---- redox-ioctl/Cargo.toml | 3 --- src/header/spawn/cbindgen.toml | 2 +- src/header/spawn/file_actions.rs | 10 ++-------- src/platform/redox/mod.rs | 27 +++++++++++++++++++++++---- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 402d28e3ac..47568e432f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -462,7 +462,8 @@ dependencies = [ [[package]] name = "redox_event" version = "0.4.7" -source = "git+https://gitlab.redox-os.org/EuclidDivisionLemma/event?branch=spawn#9126b9b1166e4633877feacf109720481e814e2e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c07d0d6d291e3a951bd847b1cd4af32fc6243d64116cf7702838c02797688b7" dependencies = [ "bitflags", "libredox", @@ -472,7 +473,8 @@ dependencies = [ [[package]] name = "redox_syscall" version = "0.8.1" -source = "git+https://gitlab.redox-os.org/redox-os/syscall/#79cb6d9057642be31623677458a93aa88145864f" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7" dependencies = [ "bitflags", ] diff --git a/Cargo.toml b/Cargo.toml index 1b5f3d4312..7a7682e825 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -121,9 +121,7 @@ sc = "0.2.7" redox_syscall.workspace = true redox-rt = { path = "redox-rt" } redox-path.workspace = true -redox_event = { git = "https://gitlab.redox-os.org/EuclidDivisionLemma/event", branch = "spawn", default-features = false, features = [ - "redox_syscall", -] } +redox_event = { version = "0.4.7", default-features = false, features = ["redox_syscall"] } ioslice.workspace = true redox-ioctl = { path = "redox-ioctl" } redox_protocols.workspace = true @@ -145,4 +143,3 @@ panic = "abort" [patch.crates-io] cc-11 = { git = "https://github.com/tea/cc-rs", branch = "riscv-abi-arch-fix", package = "cc" } -redox_syscall = {git = "https://gitlab.redox-os.org/redox-os/syscall/"} diff --git a/redox-ioctl/Cargo.toml b/redox-ioctl/Cargo.toml index 88778d300c..5c89dfd6b6 100644 --- a/redox-ioctl/Cargo.toml +++ b/redox-ioctl/Cargo.toml @@ -10,7 +10,4 @@ description = "Ioctl definitions and (de)serialization for Redox" drm-sys = "0.8.0" redox_syscall = "0.8.1" -[patch.crates-io] -redox_syscall = {git = "https://gitlab.redox-os.org/EuclidDivisionLemma/syscall/", branch = "spawn"} - [features] diff --git a/src/header/spawn/cbindgen.toml b/src/header/spawn/cbindgen.toml index fdf8013426..baba99bf2f 100644 --- a/src/header/spawn/cbindgen.toml +++ b/src/header/spawn/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["sched.h", "bits/sigset-t.h", "bits/mode-t.h"] +sys_includes = ["sched.h", "bits/sigset-t.h", "bits/mode-t.h", "bits/size-t.h"] include_guard = "_RELIBC_SPAWN_H" language = "C" cpp_compat = true diff --git a/src/header/spawn/file_actions.rs b/src/header/spawn/file_actions.rs index c9c34f9579..74b84e5509 100644 --- a/src/header/spawn/file_actions.rs +++ b/src/header/spawn/file_actions.rs @@ -3,7 +3,7 @@ use core::ptr; use crate::{ header::errno::EBADF, - platform::types::{c_char, c_int, mode_t, size_t}, + platform::types::{c_char, c_int, c_uchar, mode_t, size_t}, }; #[derive(Debug, Clone)] @@ -25,7 +25,7 @@ struct FileActions(Vec); #[repr(C)] #[derive(Debug, Clone, Copy)] pub struct posix_spawn_file_actions_t { - __relibc_internal_size: [u8; 24], + __relibc_internal_size: [c_uchar; 24], __relibc_internal_align: size_t, } @@ -124,9 +124,6 @@ pub unsafe extern "C" fn posix_spawn_file_actions_addopen( mode: mode_t, ) -> c_int { let file_actions = unsafe { file_actions.as_mut().expect("file_actions cannot be NULL") }; - if path.is_null() { - panic!("path cannot be NULL"); - } if fd < 0 { return EBADF; } @@ -174,9 +171,6 @@ pub unsafe extern "C" fn posix_spawn_file_actions_addchdir( path: *const c_char, ) -> c_int { let file_actions = unsafe { file_actions.as_mut().expect("file_actions cannot be NULL") }; - if path.is_null() { - panic!("path cannot be NULL"); - } file_actions.add_action(Action::Chdir(unsafe { if path.is_null() { CString::new("").unwrap() diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 72fa26d513..6cdb71f37d 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -44,7 +44,7 @@ use crate::{ sys_file, sys_mman::{MAP_ANONYMOUS, PROT_READ, PROT_WRITE}, sys_random, - sys_resource::{RLIM_INFINITY, rlimit, rusage}, + sys_resource::{PRIO_PROCESS, RLIM_INFINITY, rlimit, rusage, setpriority}, sys_select::timeval, sys_stat::{S_ISGID, S_ISUID, S_ISVTX, stat}, sys_statvfs::statvfs, @@ -60,7 +60,7 @@ use crate::{ ld_so::tcb::OsSpecific, out::Out, platform::{ - free, + ERRNO, free, sys::timer::{TIMERS, timer_routine, timer_update_wake_time}, }, sync::rwlock::RwLock, @@ -1358,8 +1358,27 @@ impl Pal for Sys { } } - if flags.contains(Flags::POSIX_SPAWN_SETSCHEDPARAM) { - todo!() + let set_schedparam = || -> Result<()> { + if setpriority( + PRIO_PROCESS, + proc_fd.as_raw_fd() as id_t, + attr.param.sched_priority, + ) as usize + != 0 + { + Err(Errno(ERRNO.get())) + } else { + Ok(()) + } + }; + let set_scheduler = || -> Result<()> { todo!() }; + + // scheduling paramters must be set regardless of whether the flag POSIX_SPAWN_SETSCHEDPARAM is set + if flags.contains(Flags::POSIX_SPAWN_SETSCHEDULER) { + set_schedparam()?; + set_scheduler()?; + } else if flags.contains(Flags::POSIX_SPAWN_SETSCHEDPARAM) { + set_schedparam()?; } let set_resugid = || -> Result<()> {