mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-24 20:00:22 +00:00
scx_lavd: proper handling of ctrl-c in a monitoring mode
Ctrl-c wasn't properly handled in the monitoring mode (`--monitor-sched-samples`), so the scheduler could not be terminated by pressing ctrl-c. The missing ctrl-c handling is added to the monitor thread. Signed-off-by: Changwoo Min <changwoo@igalia.com>
This commit is contained in:
parent
9c4428fd8b
commit
95272ae910
@ -704,7 +704,8 @@ fn main() -> Result<()> {
|
||||
.context("Error setting Ctrl-C handler")?;
|
||||
|
||||
if let Some(nr_samples) = opts.monitor_sched_samples {
|
||||
let jh = std::thread::spawn(move || stats::monitor_sched_samples(nr_samples).unwrap());
|
||||
let shutdown_copy = shutdown.clone();
|
||||
let jh = std::thread::spawn(move || stats::monitor_sched_samples(nr_samples, shutdown_copy).unwrap());
|
||||
let _ = jh.join();
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Write;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
use std::thread::ThreadId;
|
||||
use std::time::Duration;
|
||||
|
||||
@ -202,9 +204,13 @@ pub fn server_data(nr_cpus_onln: u64) -> StatsServerData<StatsReq, StatsRes> {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn monitor_sched_samples(nr_samples: u64) -> Result<()> {
|
||||
println!(
|
||||
" stat: ('L'atency-critical, 'R'egular) (performance-'H'ungry, performance-'I'nsensitive) ('B'ig, li'T'tle) ('E'ligigle, 'G'reedy) ('P'reempting, 'N'ot)");
|
||||
pub fn monitor_sched_samples(nr_samples: u64, shutdown: Arc<AtomicBool>) -> Result<()> {
|
||||
println!("## stats");
|
||||
println!(" LR: 'L'atency-critical or 'R'egular");
|
||||
println!(" HI: performance-'H'ungry or performance-'I'nsensitive");
|
||||
println!(" BT: 'B'ig or li'T'tle");
|
||||
println!(" EG: 'E'ligigle or 'G'reedy");
|
||||
println!(" PN: 'P'reempting or 'N'ot");
|
||||
|
||||
scx_utils::monitor_stats::<SchedSamples>(
|
||||
&vec![
|
||||
@ -212,7 +218,7 @@ pub fn monitor_sched_samples(nr_samples: u64) -> Result<()> {
|
||||
("nr_samples".into(), nr_samples.to_string()),
|
||||
],
|
||||
Duration::from_secs(0),
|
||||
|| !crate::RUNNING.load(Ordering::Relaxed),
|
||||
|| shutdown.load(Ordering::Relaxed),
|
||||
|ts| {
|
||||
let mut stdout = std::io::stdout();
|
||||
for sample in ts.samples.iter() {
|
||||
|
Loading…
Reference in New Issue
Block a user