
Originally Posted by
sayzer
true Multitasking Processor – say four separate operations simultaneously.
Which is fine until you want to do six things simultaneously. 
As Melanie said
Even your desktop PC only executes one instruction at a time (ignoring the new dual-core CPU's), but it time-slices, so it appears like you are running multiple tasks.
My laptop is currently running many programs in the background and appears to be a speedy machine but when I first boot it up it takes forever due to the heavy processor demands for each of the applications starting up.
To achieve the appearance of effective multitasking you must prioritise each task and ensure that a routine to service that task is performed often enough for the program to work.
eg. Task levels "Critical", "Important", "Menial"
Code:
Main:
For MenialTasks = 0 to 5
For ImportantTasks = 0 to 3
Gosub CriticalTask
Select Case ImportantTasks
Case 0
Gosub MostImportantTask
Case 1
Gosub LessImportantTask1
Case 2
Gosub MostImportantTask
Case 3
Gosub LessImportantTask2
End Select
Next ImportantTasks
Select Case MenialTasks
Case 0
Gosub MenialTask1
Case 1
Gosub MenialTask2
Case 2
Gosub MenialTask3
Case 3
Gosub MenialTask4
Case 4
Gosub MenialTask5
Case 5
Gosub MenialTask6
End Select
Next MenialTasks
Goto Main
To complete both the nested loops takes 24 circuits.
(6 MenialTasks * 4 ImportantTasks).
If you look you will see that the subroutines called are...
CriticalTask - 24 times (once every loop of the ImportantTasks)
MostImportantTask - 12 times (every other loop of ImportantTasks)
LessImportantTask 1 & 2 - 6 times each (once per ImportantTasks loop)
Each MenialTask gets called once for every complete cycle of both loops.
You just need to figure out the most important things to do and how to keep track of what you are doing
Keith
www.diyha.co.uk
www.kat5.tv
Bookmarks