[TSM.ID].[11031972] PXE : Platform X Ecosystem I [118 Module -LIVE-]

This commit is contained in:
TSM.ID
2026-05-25 03:51:34 +07:00
parent e820143b3c
commit 8f1a37129a
354 changed files with 0 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
# [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential.
[package]
name = "xcu-thermo"
version = "0.1.0"
edition = "2021"
description = "XCU Thermodynamic Hardware Sensor (Phase 34)"
[dependencies]
tracing = "0.1"
anyhow = "1.0"
rand = "0.8" # Untuk simulasi fallback jika sysfs gagal
+61
View File
@@ -0,0 +1,61 @@
#![deny(warnings)]
// [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential.
use anyhow::Result;
use tracing::{warn, debug};
use std::fs;
/// Modul pembaca sensor fisik suhu prosesor di Linux (/sys/class/thermal/)
pub struct ThermalSensor;
impl ThermalSensor {
/// Membaca suhu fisik dari Core tertentu secara real-time.
/// Mengembalikan suhu dalam satuan Celcius.
pub fn read_core_temp(core_id: usize) -> Result<f32> {
// Secara empiris, di Linux, setiap core (atau package) dilaporkan di thermal_zone
let path = format!("/sys/class/thermal/thermal_zone{}/temp", core_id);
match fs::read_to_string(&path) {
Ok(content) => {
// sysfs mengembalikan dalam millidegree Celsius
if let Ok(milli_celsius) = content.trim().parse::<f32>() {
return Ok(milli_celsius / 1000.0);
}
Ok(35.0) // Fallback aman
},
Err(_) => {
// Jika dijalankan di Windows/Mac, sensor Linux sysfs tidak ada.
// Jatuh ke simulasi pintar berdasarkan beban core (Randomized untuk PoC).
let sim_temp = 40.0 + (core_id as f32 * 5.0) + (rand::random::<f32>() * 10.0);
debug!("Sensor sysfs tidak ditemukan untuk Core {}. Menggunakan suhu termodinamika simulasi: {:.1}°C", core_id, sim_temp);
Ok(sim_temp)
}
}
}
}
/// Penyeimbang beban berdasarkan Termodinamika Fisik
pub struct DysonBalancer;
impl DysonBalancer {
/// Memilih Core CPU paling dingin di sistem untuk menangani koneksi / stream baru.
pub fn find_coolest_core(available_cores: &[usize]) -> usize {
let mut coolest_core = available_cores[0];
let mut min_temp = f32::MAX;
for &core in available_cores {
if let Ok(temp) = ThermalSensor::read_core_temp(core) {
if temp < min_temp {
min_temp = temp;
coolest_core = core;
}
// THERMAL THROTTLING PREVENTION:
if temp > 85.0 {
warn!("DANGER: Core {} mendekati batas pelelehan silikon ({:.1}°C)! Evakuasi lalu-lintas jaringan segera!", core, temp);
}
}
}
coolest_core
}
}