"Thread safe" task

Post comments and suggestions for RoboTask here

"Thread safe" task

Postby Vara04 » Tue Feb 05, 2013 5:54 am

It would be interesting tasks initiated from another task (with Start Task) runs in its
context and independently.
This is to have no deadlocks between tasks.

Example of use:
I do a common task that makes a series of operations with parameters.
I called this task in various other tasks that I do not control the trigger.
Currently, if two tasks require the common task of the two tasks lock.

So ideally, it should be that each can perform the common task of its own.
Vara04
 
Posts: 54
Joined: Fri Feb 24, 2012 8:02 pm
Location: France

"Thread safe" task

Postby Oleg » Tue Feb 05, 2013 9:00 am

You can get deadlock effect when tasks waits each other infinite.
Suppose Task1 starts Task2 with waiting and Task2 starts Task1 with waiting.
Task1 waits Task2, and Task2 waits Task1. This is deadlock.

Your example:
Task1 starts CommonTask
Task2 starts CommonTask

If you want to guarantee that CommonTask will performed for each caller you should start CommoTask so:
Wait CommonTask
Start CommonTask with waiting

Wait For task waits until the task finished.
If CommonTask is not running then Wait For task will not wait.
In this case CommonTask will performed for each caller.

I can send you small examples if it's necessary
Oleg
Site Admin
 
Posts: 2420
Joined: Thu Jan 01, 1970 1:00 am

Re: "Thread safe" task

Postby Denli » Tue Mar 31, 2015 11:27 pm

Oleg wrote:I can send you small examples if it's necessary


example please
Denli
 
Posts: 2
Joined: Tue Mar 31, 2015 10:59 pm

Re: "Thread safe" task

Postby Oleg » Wed Apr 01, 2015 9:57 am

Import these 3 tasks, please:
WaitForTaskExample.zip
(1.97 KiB) Downloaded 1696 times
Oleg Yershov
Oleg
Site Admin
 
Posts: 2420
Joined: Thu Jan 01, 1970 1:00 am

Re: "Thread safe" task

Postby Denli » Wed Apr 01, 2015 11:28 am

Example helped me :D Thank you so much!
Denli
 
Posts: 2
Joined: Tue Mar 31, 2015 10:59 pm

Re: "Thread safe" task

Postby Vara04 » Fri May 13, 2016 12:37 pm

Yes but :
- if the commonTask must be call by a lot of tasks
- and the common task run during "long time",
all tasks are waiting... and there is a risk that at least, 2 tasks launch commonTask at the same time after waiting :D

For the moment I copy all steps in all tasks :roll:
Chris
(Robotask v6.4.2 on Win2008 x64)
Vara04
 
Posts: 54
Joined: Fri Feb 24, 2012 8:02 pm
Location: France


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron