cancel
Showing results for 
Search instead for 
Did you mean: 

Environment Locking

SurajJadhav
Level 5
Hello guys, I am just trying to understand what is environment locking and how it works. I read the help section but didn't understand if anyone can help me to understand this. Thank You
3 REPLIES 3

Anonymous
Not applicable
It is the methodology to avoid the situation where multiple sessions of BP tries to access same instance of file/application and create deadlock. This should be used when the instance should be accessed by only one session at a time. e.g. the files saved at shared drive to be opened in write mode First acquire lock, check if token is granted if yes then continue else stop for some time and then again check. Once the work is done release the lock.

John__Carter
Staff
Staff
An environment lock is a generic permission token, that can be applied to any situation where you want to control the number of instances able to execute particular steps at the same time. As GM says, the most common example is reading an input file; if you have 10 robots running, you don't want them all loading the same file. Instead, you make all 10 compete for possession of an environment lock; only 1 can win and the other 9 will lose. The winner loads the file while the others wait; after loading the winner releases the lock and then all 10 proceed. Another synopsis is that you want all 10 to perform an action 'one at a time'. Again all 10 compete for the lock and the winner performs the steps. After the lock is released the remaining 9 compete again and 1 of them wins. The 8 compete, then 7, then 6 etc.

DexterWhelan1
Level 4
Environment locking is a great tool to get your head around, especially in automation/robotics. If you'd like some more resources on said topic try here https://en.wikipedia.org/wiki/Lock_(computer_science) (for some technical insight into it if that's your bag) and here https://stackoverflow.com/questions/34524/what-is-a-mutex (for less technical jargon but more examples of same)