feat: P0-P6 kernel scheduler + relibc threading comprehensive implementation
P0-P2: Barrier SMP, sigmask/pthread_kill races, robust mutexes, RT scheduling, POSIX sched API P3: PerCpuSched struct, per-CPU wiring, work stealing, load balancing, initial placement P4: 64-shard futex table, REQUEUE, PI futexes (LOCK_PI/UNLOCK_PI/TRYLOCK_PI), robust futexes, vruntime tracking, min-vruntime SCHED_OTHER selection P5: setpriority/getpriority, pthread_setaffinity_np, pthread_setname_np, pthread_setschedparam (Redox) P6: Cache-affine scheduling (last_cpu + vruntime bonus), NUMA topology kernel hints + numad userspace daemon Stability fixes: make_consistent stores 0 (dead TID fix), cond.rs error propagation, SPIN_COUNT adaptive spinning, Sys::open &str fix, PI futex CAS race, proc.rs lock ordering, barrier destroy Patches: 33 kernel + 58 relibc patches, all tracked in recipes Docs: KERNEL-SCHEDULER-MULTITHREAD-IMPROVEMENT-PLAN.md updated, SCHEDULER-REVIEW-FINAL.md created Architecture: NUMA topology parsing stays userspace (numad daemon), kernel stores lightweight NumaTopology hints
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
diff --git a/src/sync/pthread_mutex.rs b/src/sync/pthread_mutex.rs
|
||||
index 2871a6149..3c8e73f15 100644
|
||||
--- a/src/sync/pthread_mutex.rs
|
||||
+++ b/src/sync/pthread_mutex.rs
|
||||
@@ -35,7 +35,7 @@ const FUTEX_OWNER_DIED: u32 = 1 << 30;
|
||||
const INDEX_MASK: u32 = !(WAITING_BIT | FUTEX_OWNER_DIED);
|
||||
// TODO: Lower limit is probably better.
|
||||
const RECURSIVE_COUNT_MAX_INCLUSIVE: u32 = u32::MAX;
|
||||
-const SPIN_COUNT: usize = 0;
|
||||
+const SPIN_COUNT: usize = 100;
|
||||
|
||||
impl RlctMutex {
|
||||
pub(crate) fn new(attr: &RlctMutexAttr) -> Result<Self, Errno> {
|
||||
diff --git a/src/sync/barrier.rs b/src/sync/barrier.rs
|
||||
index b5847b5..a8e3c2f0 100644
|
||||
--- a/src/sync/barrier.rs
|
||||
+++ b/src/sync/barrier.rs
|
||||
@@ -47,6 +47,9 @@ impl Barrier {
|
||||
cvar: FutexState::new(count.get()),
|
||||
}
|
||||
}
|
||||
+ pub fn destroy(&self) {}
|
||||
+
|
||||
pub fn wait(&self) -> WaitResult {
|
||||
let _ = &self.lock;
|
||||
let sense = self.cvar.sense.load(Ordering::Acquire);
|
||||
diff --git a/src/header/pthread/barrier.rs b/src/header/pthread/barrier.rs
|
||||
index 1a5df3a..e69e2b9 100644
|
||||
--- a/src/header/pthread/barrier.rs
|
||||
+++ b/src/header/pthread/barrier.rs
|
||||
@@ -24,10 +24,10 @@ pub(crate) struct RlctBarrierAttr {
|
||||
// Not async-signal-safe.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int {
|
||||
- // Behavior is undefined if any thread is currently waiting when this is called.
|
||||
-
|
||||
- // No-op, currently.
|
||||
- unsafe { core::ptr::drop_in_place(barrier.cast::<RlctBarrier>()) };
|
||||
+ let barrier = unsafe { &*barrier.cast::<RlctBarrier>() };
|
||||
+ barrier.destroy();
|
||||
|
||||
0
|
||||
}
|
||||
Reference in New Issue
Block a user