Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marco Perronet
rbf-trace
Commits
50fdaa92
Commit
50fdaa92
authored
Nov 26, 2021
by
Marco Maida
🌱
Browse files
Structure
parent
53e0d050
Pipeline
#57968
failed with stages
in 43 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/dummy-sched-event.rs
0 → 100644
View file @
50fdaa92
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
,
}
src/event_generation/dummy.rs
View file @
50fdaa92
// 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
src/params.rs
View file @
50fdaa92
...
...
@@ -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
;
...
...
src/tools/dummy-sched-event
0 → 100755
View file @
50fdaa92
#!/bin/bash
SCRIPT_DIR
=
"
$(
dirname
"
$0
"
)
"
sudo
"
$SCRIPT_DIR
"
/../../target/debug/trace-sched-event
"
$@
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment