Skip to content
Snippets Groups Projects
Commit 5070918f authored by Samuel Karlsson's avatar Samuel Karlsson
Browse files

start

parent a8b6f47b
Branches
No related tags found
No related merge requests found
Pipeline #232 failed
......@@ -62,11 +62,6 @@ dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "base64"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bit-set"
version = "0.5.1"
......@@ -286,10 +281,6 @@ dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ktest"
version = "0.1.0"
[[package]]
name = "lazy_static"
version = "1.4.0"
......@@ -407,6 +398,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "probe-rs"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)",
"capstone 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -425,7 +417,8 @@ dependencies = [
"maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"object 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"probe-rs-t2rust 0.1.0",
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rental 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rusb 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -434,17 +427,6 @@ dependencies = [
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "probe-rs-t2rust"
version = "0.1.0"
dependencies = [
"base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"scroll 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.30"
......@@ -516,8 +498,7 @@ name = "runner"
version = "0.1.0"
dependencies = [
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"ktest 0.1.0",
"probe-rs 0.3.0",
"probe-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -726,7 +707,6 @@ dependencies = [
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)" = "924c76597f0d9ca25d762c25a4d369d51267536465dc5064bdf0eb073ed477ea"
"checksum backtrace-sys 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)" = "5d6575f128516de27e3ce99689419835fce9643a9b215a14d2b5b685be018491"
"checksum base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
"checksum bit-set 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e84c238982c4b1e1ee668d136c510c67a13465279c0cb367ea6baf6310620a80"
"checksum bit-vec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f59bbe95d4e52a6398ec21238d31577f2b28a9d86807f06ca59d191d8440d0bb"
"checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
......@@ -771,6 +751,7 @@ dependencies = [
"checksum parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc878dac00da22f8f61e7af3157988424567ab01d9920b962ef7dcbd7cd865"
"checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
"checksum probe-rs 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05b639d22ce87304e58630d819d2c1a2c23c862d4fe57efc83c56ffa7b8e52cd"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
......
......@@ -7,9 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
probe-rs = { path = "../../probe-rs/probe-rs", version = "0.3.0" }
ktest = { path = "../ktest", version = "0.1.0" }
probe-rs = { version = "0.3.0" }
#ktest = { version = "0.1.0" }
failure = "0.1.6"
[lib]
name = "runner"
\ No newline at end of file
name = "runner"
......@@ -68,9 +68,42 @@ fn main() {
let tasks: Tasks = vec![t1, t2, t3];
println!("tasks {:?}", &tasks);
// println!("tot_util {}", tot_util(&tasks));
// println!("tot_util {}", tot_util(&tasks));
let (ip, tr) = pre_analysis(&tasks);
println!("ip: {:?}", ip);
println!("tr: {:?}", tr);
let c = c_times(&tasks);
println!("C(t): {:?}", c);
let (l, l_tot) = load(&tasks, &c);
println!("L(t): {:?}",l);
println!("L(T): {:?}",l_tot);
let b = block(&tasks, ip, tr);
println!("B(t): {:?}", b);
}
/*
TODO
for eatch task
c(t), r(t), b(t), i(t), l(t)
all
l_tot
HOW
c(t) = stop - start
l(t) = c(t) / a(t)
r(t) = c(t) + b(t) + i(t)
b(t) = sum {for eatch max(R) where pi(r) > p(t)
i(t) = sum { (ph(h)/bp(t) * c(h)) where p(h) > p(t)
ip: {"R1": 2, "T2": 2, "R2": 3, "T1": 1, "T3": 3}
tr: {"T2": {"R1", "R2"}, "T3": {"R2"}}
*/
......@@ -29,7 +29,12 @@ pub type Tasks = Vec<Task>;
pub type IdPrio = HashMap<String, u8>;
// A map from Task identifiers to a set of Resource identifiers
pub type TaskResources = HashMap<String, HashSet<String>>;
// id_task, {id_res, longest}
pub type TaskResources = HashMap<String, Vec<HashMap<String, u32>>>;
pub type C = HashMap<String, u32>;
pub type L = HashMap<String, f32>;
pub type B = HashMap<String, u32>;
// Derives the above maps from a set of tasks
pub fn pre_analysis(tasks: &Tasks) -> (IdPrio, TaskResources) {
......@@ -58,15 +63,86 @@ fn update_prio(prio: u8, trace: &Trace, hm: &mut IdPrio) {
}
}
// (s = task id, trace = on res, trmap = tr)
fn update_tr(s: String, trace: &Trace, trmap: &mut TaskResources) {
if let Some(seen) = trmap.get_mut(&s) {
seen.insert(trace.id.clone());
let mut hm = HashMap::new();
let time = trace.end - trace.start;
let mut found = false;
for mut t in seen {
if let Some(mut exist) = t.get_mut(&trace.id) {
if *exist < time {
*exist = time;
}
found = true;
}
}
if !found {
hm.insert(trace.id.clone(), time);
trmap.get_mut(&s).unwrap().push(hm);
}
} else {
let mut hs = HashSet::new();
hs.insert(trace.id.clone());
trmap.insert(s.clone(), hs);
let mut hm = HashMap::new();
hm.insert(trace.id.clone(), trace.end - trace.start);
trmap.insert(s.clone(), vec![hm]);
}
for trace in &trace.inner {
update_tr(s.clone(), trace, trmap);
}
}
pub fn c_times(tasks: &Tasks) -> C {
let mut c = HashMap::new();
for t in tasks {
c.insert(t.id.clone(), t.trace.end - t.trace.start);
}
c
}
pub fn load(tasks: &Tasks, c: &C) -> (L, f32){
let mut l = HashMap::new();
let mut tot = 0.0;
for t in tasks {
let usages =
*c.get(&t.id).unwrap() as f32 / t.inter_arrival as f32;
l.insert(t.id.clone(), usages);
tot += usages;
}
(l, tot)
}
pub fn block(tasks: &Tasks, ip: IdPrio, tr: TaskResources) -> B {
let mut b = HashMap::new();
for t in tasks {
let mut block_time = 0;
let resourses = tr.get(&t.id);
match resourses {
Some(res) => {
for vectorn in res {
for (id, _) in vectorn {
// iter this, all res
for (tr_id, tr_has) in &tr {
if ip.get(tr_id).unwrap() < &t.prio {
for bl in tr_has {
if let Some(time) = bl.get(id) {
block_time += time;
}
}
}
}
}
}
b.insert(t.id.clone(), block_time);
},
None => {
b.insert(t.id.clone(), 0);
},
}
}
b
}
use ktest::{read_ktest, KTEST};
//use ktest::{read_ktest, KTEST};
pub mod common;
use probe_rs::{
config::registry::{Registry, SelectionStrategy},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment