3 This file contains a demonstration program that runs some tasks, an
4 inter-task shared variable, and a queue. The tasks don't really @b do
5 anything; the example just shows how these elements are created and run.
8@date 2021-Dec-15 JRR Created from the remains of previous example
9@copyright (c) 2015-2021 by JR Ridgely and released under the GNU
10 Public License, Version 2.
21 Task which puts things into a share and a queue.
22 @param shares A list holding the share and queue used by this task
25 my_share, my_queue = shares
38 Task which takes things out of a queue and share and displays them.
39 @param shares A tuple of a share and queue from which this task gets data
42 the_share, the_queue = shares
46 print(f
"Share: {the_share.get ()}, Queue: ", end=
'')
48 print(f
"{the_queue.get ()} ", end=
'')
57if __name__ ==
"__main__":
58 print(
"Testing ME405 stuff in cotask.py and task_share.py\r\n"
59 "Press Ctrl-C to stop and show diagnostics.")
70 task1 =
cotask.Task(task1_fun, name=
"Task_1", priority=1, period=400,
71 profile=
True, trace=
False, shares=(share0, q0))
72 task2 =
cotask.Task(task2_fun, name=
"Task_2", priority=2, period=1500,
73 profile=
True, trace=
False, shares=(share0, q0))
74 cotask.task_list.append(task1)
75 cotask.task_list.append(task2)
84 cotask.task_list.pri_sched()
85 except KeyboardInterrupt:
89 print(
'\n' + str (cotask.task_list))
91 print(task1.get_trace())
Implements multitasking with scheduling and some performance logging.
A queue which is used to transfer data from one task to another.
An item which holds data to be shared between tasks.
task1_fun(shares)
Task which puts things into a share and a queue.
task2_fun(shares)
Task which takes things out of a queue and share and displays them.
show_all()
Create a string holding a diagnostic printout showing the status of each queue and share in the syste...