diff --git a/examples/resource.rs b/examples/resource.rs index 1fa9a8075058f9426667381bdec0c7b7d404feaa..30b453e191a47a9f74345eea88f0beb87e3c2686 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -11,7 +11,7 @@ extern crate stm32f413; #[macro_use] extern crate klee; use klee::*; -use rtfm::{bkpt_1, bkpt_2, bkpt_3}; +// use rtfm::{bkpt_1, bkpt_2, bkpt_3}; // import the procedural macro use rtfm::{app, Resource, Threshold}; @@ -70,22 +70,6 @@ fn exti2(t: &mut Threshold, mut r: EXTI2::Resources) { }); } -#[inline(never)] -#[no_mangle] -fn enter() { - unsafe { - rtfm::bkpt_1(); - } -} - -#[inline(never)] -#[no_mangle] -fn exit() { - unsafe { - rtfm::bkpt_2(); - } -} - #[allow(non_snake_case)] fn exti3(t: &mut Threshold, mut r: EXTI3::Resources) { r.X.claim_mut(t, |x, _| { @@ -99,8 +83,6 @@ fn init(_p: init::Peripherals, _r: init::Resources) {} #[inline(never)] #[allow(dead_code)] -#[allow(private_no_mangle_fns)] -#[no_mangle] fn idle() -> ! { loop { rtfm::nop(); diff --git a/gdb.py b/gdb.py index 989b3c5900939feb1994e0a9b89b37466d7042b4..051bca0da44474077afaf75d07cf2dd97f228a90 100644 --- a/gdb.py +++ b/gdb.py @@ -25,11 +25,15 @@ object_index_current = 0 tasks = [] +priorities = [] + task_to_test = 0 task_name = "" -# Name, Cyccnt, ceiling +priority = 0 + +# [[ Test, Task, Cyccnt, priority/ceiling] Info] outputdata = [] """ Max number of events guard """ @@ -39,6 +43,31 @@ object_index_max = 100 original_pwd = os.getcwd() +def gather_data(): + + global outputdata + global file_index_current + global file_list + global init_done + + """ + If not all ktest-files done yet, proceed + """ + if file_index_current < len(file_list): + file_index_current += 1 + # print("Current file: %s" % file_list[file_index_current]) + gdb.post_event(posted_event_init) + + else: + print("Finished everything") + + print(outputdata) + + """ ... call your analysis here ... """ + + gdb.execute("quit") + + class KTestError(Exception): pass @@ -128,6 +157,7 @@ def stop_event(evt): global task_name global file_index_current global file_list + global priority file_name = file_list[file_index_current].split('/')[-1] @@ -167,7 +197,7 @@ def stop_event(evt): gdb.post_event(posted_event_init) outputdata.append([file_name, task_name, - gdb_cyccnt_read(), 0, "Finish"]) + gdb_cyccnt_read(), priority, "Finish"]) if file_index_current < len(file_list) - 1: gather_data() @@ -204,6 +234,8 @@ def posted_event_init(): global file_index_current global file_list global outputdata + global priority + global priorities """ Load the variable data """ ktest_setdata(file_index_current) @@ -226,9 +258,10 @@ def posted_event_init(): file_name = file_list[file_index_current].split('/')[-1] task_name = tasks[task_to_test] + priority = priorities[task_to_test] outputdata.append([file_name, task_name, - gdb_cyccnt_read(), 0, "Start"]) + gdb_cyccnt_read(), priority, "Start"]) gdb.write('Task to call: %s \n' % ( tasks[task_to_test] + "()")) @@ -377,7 +410,7 @@ def tasklist_get(): for line in fin: # print(line) if not line == "// autogenerated file\n": - return [x.strip().strip("[]\"") for x in line.split(',')] + return [x.strip().strip("[]\"").split(' ') for x in line.split(',')] """ Run xargo for building """ @@ -520,11 +553,23 @@ file_list = ktest_iterate() print(file_list) """ Get all the tasks to jump to """ -tasks = tasklist_get() +task_list = tasklist_get() +print("task_list {}".format(task_list)) + +""" Split into tasks and priorities """ +for x in task_list: + priorities.append(x.pop()) + tasks.append(x.pop()) + print("Available tasks:") for t in tasks: print(t) +print("At priorities:") +for t in priorities: + print(t) + + """ Subscribe stop_event_ignore to Breakpoint notifications """ gdb.events.stop.connect(stop_event) @@ -535,28 +580,67 @@ gdb.events.stop.connect(stop_event) gdb.execute("continue") -def gather_data(): - - global outputdata - global file_index_current - global file_list - global init_done - - """ - If not all ktest-files done yet, proceed - """ - if file_index_current < len(file_list): - file_index_current += 1 - # print("Current file: %s" % file_list[file_index_current]) - gdb.post_event(posted_event_init) - - else: - print("Finished everything") - - print(outputdata) - - """ ... call your analysis here ... """ - - gdb.execute("quit") - # Home exam, response time analysis +# +# 1. run the example and study the output +# it generates `output data`, a list of list, something like: +# Claims: +# ['test000001.ktest', '', 22095438, 0, 'Finish'] Total time: 22095438 +# ['test000002.ktest', 'EXTI2', 0, '3', 'Start'] +# ['test000002.ktest', 'EXTI2', 11, '3', 'Finish'] Total time: 11 +# ['test000003.ktest', 'EXTI2', 0, '3', 'Start'] +# ['test000003.ktest', 'EXTI2', 11, '3', 'Finish'] Total time: 11 +# ['test000004.ktest', 'EXTI3', 0, '2', 'Start'] +# ['test000004.ktest', 'EXTI3', 7, '2', 'Finish'] Total time: 7 +# ['test000005.ktest', 'EXTI1', 0, '1', 'Start'] +# ['test000005.ktest', 'EXTI1', 15, 2, 'Enter'] +# ['test000005.ktest', 'EXTI1', 19, 3, 'Enter'] +# ['test000005.ktest', 'EXTI1', 28, 3, 'Exit'] Claim time: 9 +# ['test000005.ktest', 'EXTI1', 29, 2, 'Exit'] Claim time: 14 +# ['test000005.ktest', 'EXTI1', 32, '1', 'Finish'] Total time: 32 +# ['test000006.ktest', 'EXTI1', 0, '1', 'Start']... +# +# first entry +# ['test000001.ktest', .... +# is our bogus test, not of interest for the analysis) +# +# next entries: +#['test000002.ktest', 'EXTI2', 0, 3, 'Start'] +#['test000002.ktest', 'EXTI2', 11, 3, 'Finish'] Total time: 11 +# amounts to the first real task +# broken down, the first measurement +# -'test000002.ktest' the ktest file +# -'EXTI2' the task +# -'0' the time stamp (start from zero) +# -'3' the threshold (priority 3) +# -'Start' the 'Start' event +# +# broken down, the second measurement +# -'test000002.ktest' the ktest file +# -'EXTI2' the task +# -'11' the time stamp (start from zero) +# -'3' the threshold (priority 3) +# -'Finish' the 'Start' event +# +# followed by +# Total time: 11 +# +# let us look at the following measurements +# +# 'test000003.ktest' +# recall from the lab that we had two cases for EXTI2 +# both with the same result +# +# 'test000004.ktest' +# recall from the lab that we had a singel test for EXTI3 +# +# and finally +# +# 'test000005.ktest' and on ... for EXTI1 +# here at prio 1, and after 15 cycles claim X, raising threshold to 2 +# after 19 cycles we clam Y, raising treshold to 3 +# after 28 cycles we exit the Y claim, threshold 3 *before unlock Y* +# after 29 cycles we exit the X claim, threshold 2 *before unlock X* +# and finally we finish at 34 clock cycles +# +# (recall we had some 38 in the lab, this is due mesuring) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index aad020f5ccd0f205617e9cfe73e2591d22fa0486..f2d63c8d11ec3457b07c514e2757184945d1f2b5 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -192,9 +192,9 @@ fn run(ts: TokenStream) -> Result<TokenStream> { if cfg!(feature = "klee_mode") { println!("tasks"); let mut tasks = Vec::new(); - for (id, _task) in app.tasks { + for (id, task) in app.tasks { println!("{}", id); - tasks.push(format!("{}", id)); + tasks.push(format!("{} {}", id, task.priority)); } let path = Path::new("klee/tasks.txt"); diff --git a/macros/src/trans.rs b/macros/src/trans.rs index 426e708d917ed5ebc7ec525e5b054a73a106655d..cd6c024b2dddee13ff168a10f2fe14b9a0c51889 100644 --- a/macros/src/trans.rs +++ b/macros/src/trans.rs @@ -709,7 +709,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) { // call the task unsafe { #_tname(); } // break for finish wcet measurement - unsafe { bkpt_3(); } + unsafe { rtfm::bkpt_3(); } } }); } @@ -745,7 +745,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) { #[inline(never)] pub fn wcet_start() { // break for starting wcet measurement - unsafe { bkpt_3() }; + unsafe { rtfm::bkpt_3() }; // call each stub to avoind optimizing out #(#stubs)* }