Multi-tasking with 1700 Tasks or more
Posted: 22 January 2008, 21:26 PM
So how many tasks can you run on your microcontroller? I have wanted to write this code for a long time. For those of who remember, the old BasicX-01 claimed it could do 1000 simultaneous tasks.
Here is the code to run 1700 tasks on your ZX-128e/ZX-1281e/ZX-1281/ZX-1280 with 64K RAM. The tasks are simple counters but who cares; this is a stress test and a good showcase of the ZX platform capabilities.
Here is some sample output (without the optional dump of all 1700 counters every 5 seconds).
Here is the code to run 1700 tasks on your ZX-128e/ZX-1281e/ZX-1281/ZX-1280 with 64K RAM. The tasks are simple counters but who cares; this is a stress test and a good showcase of the ZX platform capabilities.
Here is some sample output (without the optional dump of all 1700 counters every 5 seconds).
Code: Select all
ZBasic v2.3
RAM heap Size is 63019
Creating 1700 tasks:
....................................................................................................100
....................................................................................................200
....................................................................................................300
....................................................................................................400
....................................................................................................500
....................................................................................................600
....................................................................................................700
....................................................................................................800
....................................................................................................900
....................................................................................................1000
....................................................................................................1100
....................................................................................................1200
....................................................................................................1300
....................................................................................................1400
....................................................................................................1500
....................................................................................................1600
....................................................................................................1700
Elapsed time is 15.29688 seconds
***** Elapsed time is 0.0429687 seconds
Average count is 0.0
***** Elapsed time is 5.693359 seconds
Average count is 143.2771
***** Elapsed time is 5.640625 seconds
Average count is 79.12118
***** Elapsed time is 5.638672 seconds
Average count is 69.62706
***** Elapsed time is 5.642578 seconds
Average count is 74.13824