Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Glennlee on July 18, 2014, 11:02:25 AM
-
Hi Everyone.
I have written three tasks that work great. I need to create a fourth task and I want to re-use one of the existing tasks by calling it from within my new task. I will allow the calling task to continue, or exit the task depending on the results from the called task.
My question is: will the calling task wait to complete its' code until the called task has completed?
The called task is a loop that scans a database for a matching part number. It returns either the index of a match, or a bit that states "no match found".
If there is no match, then the calling task has an index pointing to an empty space at the end of the database. It will then write the new entry and exit.
If the called task indicates a match, I trigger a pop-up screen and exit the task.
I await breathlessly for your reply!
Glenn
-
Tasks are not subroutines and are not called or executed in-line. They are enabled and run independently in the execution order defined in the Project Browser.
If you are trying to do subroutine-style execution, the preferred way would be to use a Program block with stages to sequence the Task execution. In the Task execution stage put an ENTASK instruction, and then on the next rung use the .Done member of the Task structure to enable a JMP to the next stage.
We are actively developing function and subroutines, which are both called and executed in-line, and these will be a part of DmD 2.0 due out next year.
-
Like Bobo said, the best way is probably to use a program block as the supervisor... but... you can make it work...
------------------------------------ENTASK (MyTask)
REPEAT
YIELD
UNTIL (MyTask.done)
remaining code...
-
I hope I didn't scare you too bad there Bob... ;)
-
I hope I didn't scare you too bad there Bob... ;)
Hmmm...hadn't thought of doing it that way, but that would work just fine.