common
¶
Module Contents¶
Functions¶
versiontuple (v) |
Convert a string of package version in a tuple for future comparison. |
check_rms_edf (task_list) |
Parse the YAML for the required field for RMS and EDF algorithms. |
check_sched (sched) |
Parse the YAML for the resulting schedule of a scheduling algorithm. |
convert_to_datetime (x) |
Converts a natural number to date. |
plot_gantt (sched, verbose=False) |
Use the plotly lib to plot the gantt chart. |
sched_list_2_sched_dict (tasks, sched_list, verbose=False) |
Schedule format conversion. |
-
common.
versiontuple
(v)[source]¶ Convert a string of package version in a tuple for future comparison.
Parameters: v (str) – string version, e.g “2.3.1”.
Returns: The return tuple, e.g. (2,3,1).
Return type: tuple
Example: >>> versiontuple("2.3.1") > versiontuple("10.1.1") >>> False
-
common.
check_rms_edf
(task_list)[source]¶ Parse the YAML for the required field for RMS and EDF algorithms.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# example from https://en.wikipedia.org/wiki/Rate-monotonic_scheduling algo: - edf - rms tasks: - name: p1 exec_time: 1 deadline: 8 period: 8 - name: p2 exec_time: 2 deadline: 5 period: 5 - name: p3 exec_time: 2 deadline: 10 period: 10
Parameters: task_list (List of dictionaries.) – List of task descriptors, as in the example above. Returns: True for success, False otherwise. Return type: bool
-
common.
check_sched
(sched)[source]¶ Parse the YAML for the resulting schedule of a scheduling algorithm.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
title: Wikipedia taskset example with RMS algorithm sched: - color: blue jobs: - [ 2, 3] - [ 7, 8] - [16,17] - [23,24] - [31,32] name: p1 - color: blue jobs: - [ 0, 2] - [ 4, 6] - [ 9,11] - [14,16] - [19,21] - [24,26] - [29,31] - [34,36] name: p2 - color: blue jobs: - [ 3, 4] - [ 6, 7] - [11,13] - [21,23] - [32,34] name: p3 - color: green jobs: - [ 8, 9] - [13,14] - [17,19] - [26,29] - [36,39] name: idle
Parameters: task_list (List of dictionaries.) – List of sched descriptors, as in the example above. Returns: True for success, False otherwise. Return type: bool
-
common.
convert_to_datetime
(x)[source]¶ Converts a natural number to date.
It converts a natural number to date, where 0 corresponds to datetime(1970, 1, 1) (assuming, y/m/d). Value 1 corresponds to datetime(1970, 1, 2).
Parameters: x (int) – natural value Return type: datetime
-
common.
plot_gantt
(sched, verbose=False)[source]¶ Use the plotly lib to plot the gantt chart.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
title: Wikipedia taskset example with RMS algorithm sched: - color: blue jobs: - [ 2, 3] - [ 7, 8] - [16,17] - [23,24] - [31,32] name: p1 - color: blue jobs: - [ 0, 2] - [ 4, 6] - [ 9,11] - [14,16] - [19,21] - [24,26] - [29,31] - [34,36] name: p2 - color: blue jobs: - [ 3, 4] - [ 6, 7] - [11,13] - [21,23] - [32,34] name: p3 - color: green jobs: - [ 8, 9] - [13,14] - [17,19] - [26,29] - [36,39] name: idle
Parameters: - sched (List of dictionaries.) – The shedule YAML file, as in the example above.
- verbose (bool) – enable/disable verbose mode
Returns: None
Todo
provide an alternative plotting option with matplotlib
https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/broken_barh.html
Todo
other alternative plots
https://github.com/ehsan-elwan/RM-Task-Scheduling/blob/master/Plotter.py
https://github.com/johnharakas/scheduling-des/blob/sim-plotting/Qt_Canvas.py
https://github.com/esalehi1996/Realtime_Scheduling_python/blob/master/main.py
https://github.com/carlosgeos/uniprocessor-scheduler/blob/master/src/simulation.py
https://github.com/ksameersrk/rt-scheduler/blob/master/analysis/plot_graph.py
https://github.com/guilyx/gantt-trampoline/blob/master/lib/GanttPlot.py
Todo
export figure with the plot https://plotly.com/python/static-image-export/
-
common.
sched_list_2_sched_dict
(tasks, sched_list, verbose=False)[source]¶ Schedule format conversion.
Convert a scheduling in format of a list into a schedule in the format of list of dictionary.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# example from https://en.wikipedia.org/wiki/Rate-monotonic_scheduling algo: - edf - rms tasks: - name: p1 exec_time: 1 deadline: 8 period: 8 - name: p2 exec_time: 2 deadline: 5 period: 5 - name: p3 exec_time: 2 deadline: 10 period: 10
Parameters: - tasks (List of dictionaries.) – List of tasks descriptors, as in the example above.
- sched_list (List of str.) – List the execution order of the jobs, e.g. [“P1”,”P1”,”P1”,”idle”,”P3”,”P2”,”P3”, …].
- verbose (bool.) – Enable/disable the verbosity level.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
title: Wikipedia taskset example with RMS algorithm sched: - color: blue jobs: - [ 2, 3] - [ 7, 8] - [16,17] - [23,24] - [31,32] name: p1 - color: blue jobs: - [ 0, 2] - [ 4, 6] - [ 9,11] - [14,16] - [19,21] - [24,26] - [29,31] - [34,36] name: p2 - color: blue jobs: - [ 3, 4] - [ 6, 7] - [11,13] - [21,23] - [32,34] name: p3 - color: green jobs: - [ 8, 9] - [13,14] - [17,19] - [26,29] - [36,39] name: idle
Returns: List of schedule descriptors, as in the example above. Return type: List of dictionaries.