I just released MultiTaskingClass.f
This is an update of the previous MultiTask.f
Changes in the MultiTaskingClass.f:
- Moved the task-block out of the dictionary for the taskobjects
- Added cells+@ cells+! #ActiveTasks: task>cfa task>&StkParams
and the waitobject wTask including a demo for wTask.
- Removed the tasks in a chain.
The object wTask does this better and easier.
- ExitTask is now handled by the objects.
Remove ExitTask from your code when it is still there.
- Now maximal 8 parameters can be passed to a task without much
overhead.
All in all it means that many definitions are now able to run
in a submitted task without having to change the submitted definition.
Background information for MultiTaskingClass.f:
CPU's with multiple cores can execute a program faster than cpu's with
a single core. This is done by breaking up a program in smaller
pieces
and than execute all pieces simultaneously.
In multiTaskingClass.f this idea is supported as follows:
Breaking up is possible at the definition level or at the program
level by
the 2 classes iTask and wTask.
Then the pieces are submitted and simultaneously executed in a number
of tasks. The Tasks are clustered in an object for easy access.
Objects defined with iTask can be used as soon as ONE definition
should
be executed in a parallel way and the definition uses a do...loop.
The method Parallel: divides, distributes and submits for execution
the
specified cfa over a number of tasks.
Parallel: takes in account the number of hardware threads, so all
these
threads wil be used during execution.
A started task can pickup its range for the do...loop part by using
the
method GetTaskRange: The initialization of the objects defined with
iTask is automatic.
It is possible to change the number of simultaneous tasks before they
run.
Objects defined with wTask can be used to execute concurrently one or
more
different definitions.
These objects must be initialized with the method Start:
The method Start: takes the number of simultaneous tasks as a
parameter.
It does not start any task.
Use the method SubmitTask: for starting a definition as a task.
When a new task is submitted and the maximum number of simultaneous
tasks
is reached the following will happen:
1) The system will wait till one or more tasks are complete.
2) Then it will submit the task.
At this moment the system is limited to 63 simultaneous tasks for each
taskobject
that is defined with wTask or iTask.
Tasks of both classes will get their parameters at the start on the
stack as soon as
the method To&Task: is used just before the task is submitted.
MultiTaskingClass.f uses preemptive multitasking system of windows.
No need to use pause.
MultiTaskingClass.f can be downloaded at
http://home.planet.nl/~josv
I hope you like this new extension for Win32Forth.
Jos