Commit 50fdaa92 authored by Marco Maida's avatar Marco Maida 🌱
Browse files

Structure

parent 53e0d050
Pipeline #57968 failed with stages
in 43 seconds
use structopt::StructOpt;
use serde_yaml;
use std::fs::{
OpenOptions,
remove_file,
};
use std::path::PathBuf;
use std::io::Write;
use rbf_trace::util::helpers::*;
use rbf_trace::event_generation::evg::{
EventsGenerator,
};
use rbf_trace::config_detection::system::get_pids_with_policy;
use rbf_trace::config_detection::features::SchedPolicy;
fn main() {
/*
let args = Opt::from_args();
let traced_pids: Vec<Pid>;
let target_pids: Vec<Pid>;
/* Parsing */
if let Some(pids) = args.pids {
traced_pids = pids;
} else {
traced_pids = get_pids_with_policy(vec!(SchedPolicy::FIFO, SchedPolicy::RR), false);
}
if let Some(ref pids) = args.target_pids {
target_pids = pids.clone();
} else {
target_pids = traced_pids.clone();
}
let mut outputfile = None;
if let Some(ref path) = args.output {
if path.exists() {
remove_file(path).unwrap();
}
let file = OpenOptions::new()
.create_new(true)
.append(true)
.open(path)
.expect("Can't initialize file.");
outputfile = Some(file);
}
/* Tracing */
let mut evg = FTraceEVG::new(&target_pids, &traced_pids, args.ftrace_len, args.ftrace_bufsize);
evg.setup();
eprintln!("Traced pids: {:#?}", traced_pids);
if let Some(ref target_pids) = args.target_pids {
eprintln!("Target pids: {:#?}", target_pids);
}
while let Some(event) = evg.next_event() {
let serialized = serde_yaml::to_string(&event).expect("Can't serialize.");
if let Some(ref mut file) = outputfile {
write!(file, "{}", serialized).expect("I/O error.");
} else {
print!("{}", serialized);
}
} */
}
#[derive(Debug, StructOpt)]
pub struct Opt {
/// Period.
#[structopt(short = "p", u32)]
pub period: u32,
/// Jitter.
#[structopt(short = "j", u32)]
pub jitter: u32,
/// Burst of jobs per arrival.
#[structopt(short = "b", long)]
pub n_burst: u32,
/// Random seed. Specify it to obtain consistent results
#[structopt(short = "s", long)]
pub seed: u32,
}
// use crate::util::helpers::*;
// use crate::event_generation::evg::*;
// /* Generate a period constant pattern ARPRD, with only one process */
// use crate::params::PID;
// use crate::params::TIME_BETWEEN_ARRIVALS;
// use crate::params::TIME_BETWEEN_EVENTS;
// use crate::params::LIFETIME;
// pub struct DummyEVG {
// time_limit : Time,
// state : TraceEventType,
// time : Time,
// preempted : bool,
// }
// impl DummyEVG {
// pub fn new() -> DummyEVG {
// DummyEVG {
// time_limit : LIFETIME * 1000000,
// state : TraceEventType::Deactivation,
// time : 0,
// preempted : false }
// }
// }
// impl EventsGenerator for DummyEVG {
// fn next_event (&mut self) -> Option<TraceEvent> {
// let mut next_event = TraceEvent {
// etype : TraceEventType::Activation,
// pid : PID,
// instant : 0
// };
// self.time += TIME_BETWEEN_EVENTS * 1000000;
// next_event.instant = self.time;
// if self.time > self.time_limit {
// println!("Dummy events generator exited; event was requested.");
// return None;
// }
// //Make sequence [ARPRD] while there is time, then E.
// next_event.etype =
// match self.state {
// TraceEventType::Activation => { self.preempted = false; TraceEventType::Resume }
// TraceEventType::Deactivation => TraceEventType::Activation,
// TraceEventType::Preemption => { self.preempted = true; TraceEventType::Resume }
// TraceEventType::Resume => if self.preempted { TraceEventType::Deactivation } else { TraceEventType::Preemption },
// TraceEventType::Exit => TraceEventType::Exit
// };
// if self.time >= self.time_limit { next_event.etype = TraceEventType::Exit; }
// self.state = next_event.etype;
// Some(next_event)
// }
// fn setup (&mut self) {
// println!("Dummy events generator loaded.");
// }
// fn shutdown (&mut self) {
// println!("Dummy events generator shut down.");
// }
// }
\ No newline at end of file
use crate::util::helpers::*;
use crate::event_generation::evg::*;
pub struct DummyEVG {
time_limit : Time,
state : TraceEventType,
time : Time,
preempted : bool,
}
impl DummyEVG {
pub fn new() -> DummyEVG {
DummyEVG {
time_limit : LIFETIME * 1000000,
state : TraceEventType::Deactivation,
time : 0,
preempted : false }
}
}
impl EventsGenerator for DummyEVG {
fn next_event (&mut self) -> Option<TraceEvent> {
let mut next_event = TraceEvent {
etype : TraceEventType::Activation,
pid : PID,
instant : 0
};
self.time += TIME_BETWEEN_EVENTS * 1000000;
next_event.instant = self.time;
if self.time > self.time_limit {
println!("Dummy events generator exited; event was requested.");
return None;
}
//Make sequence [ARPRD] while there is time, then E.
next_event.etype =
match self.state {
TraceEventType::Activation => { self.preempted = false; TraceEventType::Resume }
TraceEventType::Deactivation => TraceEventType::Activation,
TraceEventType::Preemption => { self.preempted = true; TraceEventType::Resume }
TraceEventType::Resume => if self.preempted { TraceEventType::Deactivation } else { TraceEventType::Preemption },
TraceEventType::Exit => TraceEventType::Exit
};
if self.time >= self.time_limit { next_event.etype = TraceEventType::Exit; }
self.state = next_event.etype;
Some(next_event)
}
fn setup (&mut self) {
println!("Dummy events generator loaded.");
}
fn shutdown (&mut self) {
println!("Dummy events generator shut down.");
}
}
\ No newline at end of file
......@@ -44,12 +44,6 @@ pub static mut FILTER_KTHREADS: bool = true;
// Don't detect non-target threads
pub static mut FILTER_NONTARGETS: bool = true;
/* Dummy EVG */
pub static mut PID : Pid = 123;
pub static mut TIME_BETWEEN_ARRIVALS: Time = 1000; //ms - time between arrivals
pub static mut TIME_BETWEEN_EVENTS : Time = 1000/5;
pub static mut LIFETIME: Time = 100000; //ms - total duration of experiment
/* Event processing */
pub static mut EXTRACT_ARR_CURVE: bool = false;
......
#!/bin/bash
SCRIPT_DIR="$(dirname "$0")"
sudo "$SCRIPT_DIR"/../../target/debug/trace-sched-event "$@"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment