Книга: Advanced PIC Microcontroller Projects in C
10.5.2 Declaring a Task
10.5.2 Declaring a Task
A task is declared just like any other C function, but tasks in a multi-tasking application do not have any arguments and do not return any values. Before a task is declared, a #task preprocessor command is needed to specify the task options. The format of this preprocessor command is:
#task(rate=n, max=m, queue=p)
where rate specifies how often the task should be called. The number specified must be followed by s, ms, us, or ns. max specifies how much processor time a task will use in one execution of the task. The time specified here must be equal to or less than the time specified by minor_cycle. queue is optional and if present specifies the number of bytes to be reserved for the task to receive messages from other tasks. The default value is 0.
In the following example, a task called my_ticks is every 20ms and is expected to use no more than 100ms of processor time. This task is specified with no queue option:
#task(rate=20ms, max=100ms)
void my_ticks() {
...........
...........
}
- 10.5.1 Preparing for RTOS
- CHAPTER 11 Automating Tasks
- Scheduling Tasks
- Using at and batch to Schedule Tasks for Later
- Модуль RobotTaskMaker
- Using a Simple Script to Automate Tasks
- 15.4. Debugging Multiple Tasks
- 17.3.1.2. ISRs as Kernel Tasks
- CHAPTER 10 Multi-Tasking and Real-Time Operating Systems
- Maintenance Tools and Tasks
- Chapter 5: Tasks
- 4.4.2 Multitasking