- Simple Tasks
- Multiple Tasks
- Communicating Tasks
- Communicating Values
- Synchronising Tasks
- Buffered Communication
- Multiple Senders
- Conditional Tasks
As the Arduino IDE complies a library's source every time it complies a program that uses it, it is possible to adjust some of the limits in the multitasking library simply by changing selected constant definitions in the library source. It is recommended that the Tasks library folder is copied before doing this in case anything else is changed by accident.
• The total number of tasks allowed can be increased or decreased by changing the definition of max_tasks defined in task.h. By default, it is set to 10, and can be no larger than 16 without changing the implementation of the set type. Even if the set type implementation is modified to permit it, an upper limit of 256 is imposed as task identifiers are represented by byte values 0 to 255. The amount of RAM required to store task records is max_tasks multiplied by the size of a task_record.
• The total number of channels allowed can be increased or decreased by changing the definition of max_channels defined in channel.h. By default it is set to 10, and can be no larger than 256 as channel identifiers are represented as byte values 0 to 255. The amount of RAM required to store channels is max_channels multiplied by the size of the channel type.
• The number of actions defined in all tasks, plus the number of parameters passed to these actions, plus the number of tasks must be no greater than the code_size defined in virtual_machine.h. The extra entry per task is to account for the loop action added at the end of the code for each task by the end_task function. The size of the code array can be altered by changing the value of code_size. By default this is set to to 100. The amount of RAM required to the code array is code_size multiplied by the size of an integer, i.e. 2 bytes.
As an example of the library's space requirements, the single blinker example given given in the Simple Tasks section uses 767 bytes (37%) of RAM out of a maximum of 2048 bytes on an Arduino Uno with the default settings for max_tasks (10), max_channels (10) and code_size (100). In addition, it uses 4896 bytes (15%) of program storage space out of a maximum is 30720 bytes.