Replies: 4 comments 6 replies
-
I'll try and answer a few of them here for now, with the aim to get them into documentation over time. I'll start with the easy answers and work through the others as I have time.
It is an unfair scheduler, a work queue ordered by time, nearest time wins always. If you've used Java before consider this somewhat like
In such a task use
It is very easy to implement whatever low power modes your board supports, there's even an example in the documentation for SAMD: https://www.thecoderscorner.com/products/arduino-libraries/taskmanager-io/task-manager-low-power-samd-example/ You just effectively add a couple of lines to the main run loop to check how long to the next task, and if the threshold for sleeping is met, then do so. |
Beta Was this translation helpful? Give feedback.
-
Task manager is designed really to block as little as possible, it is unfortunate though that many embedded APIs are synchronous and make this harder. At the moment the best way to handle external signals is to use an event, see the events section of: https://www.thecoderscorner.com/products/arduino-libraries/taskmanager-io/ There is also SCCircularBuffer built into SimpleCollections, you can use this like a queue of work, and have an event that takes work from the buffer. IE an above mentioned event would contain a circular buffer, and it would trigger whenever there was work in the queue. See the examples in SimpleCollections library for that. If you need a native critical section or mutex, be very careful using that in task-manager that it does not lock the task thread completely. Task Manager tasks run on a single-thread (but scheduling. event triggering, and submitting is thread-safe). The idea is, that you can push longer-running work away from taskmanager in an RTOS environment, IE create other threads with a circular buffer or other taskManager instance that acts like a queue. |
Beta Was this translation helpful? Give feedback.
-
So in terms of storage arrangements, there are two possibilities, you set Otherwise, you can either rely on the defaults (large 32bit board is usually 16 blocks with 16 tasks each) and then one block will be allocated at start up. If another block is needed, it will be allocated, up until the maximum block is reached. Once allocated the memory is kept until the task manager is destructed. This gives an arrangement of tasks organized into blocks. Each task has a next task pointer within it. For performance, task pointers are then arranged in a linked list by time order, this list signifies what runs next. It is fast for execution, slower for insertion. The only exclusion to that is events and interrupt handling. Where events can be triggered at any point by using |
Beta Was this translation helpful? Give feedback.
-
I'll aim to get this lot into the documentation at some point, but at least for now, it's documented to some extent here. |
Beta Was this translation helpful? Give feedback.
-
TaskManagerIO (and IoAbstraction) look like very useful abstraction layers that allows easy portability of applications, hardware changes and portability to new platforms, while assisting in producing more declarative code.
However, I have been unable to find any documentation that explains a number of implementation details and recommended usage of TaskManagerIO:
Scheduling
How does TaskManagerIO scheduling work?
yield()
- declared weak in Arduino coredelay(millis)
- declared in Arduino core, callsyield()
if millis>=1yieldForMicros(micros)
(the only one documented)Low Power (Sleep) Support
Does TaskManagerIO support entering low power sleep (hardware) modes, if no tasks are scheduled to run for a number of milliseconds?
Signalling, Events, Semaphores, Messages
Documenting inter-task signalling, events, semaphores, messaging: how to create/obtain and how a task tells the scheduler to suspend execution until a resource is available, possibly using a lambda:
waitFor(lambda, timeoutMillis)
Execution Stack
Documenting how stacks and execution contexts are allocated and maintained across tasks.
Beta Was this translation helpful? Give feedback.
All reactions