Add resource locks
This development will allow programs (program threads actually) to block resources for it's exclusive use during its lifetime or until they release them.
Resources come in two shapes:
- Full bridges, a bridge can be blocked all at once if allows to do so (by sending this information on it's configuration).
- Sub-resources, elements from a bridge callback might be blockable if it is defined as possible.
New developments
-
Scratch block: "Block resource" (and unblock) will be automatically generated for the bridge if it when its sub-resources are blockable. -
Scratch block: "Block bridge" (and unblock) will be automatically generated if there are blockable bridges. -
The backend will keep track of which resources are blocked and halt the operations that require the usage of a blocked resource if its taken. -
The backend will detect deadlocks derived from this operation. In case of deadlock one of the two locked programs will be stopped (and it's resources liberated). A better conflict resolution will be defined later. -
Bridges can define blockable resources. -
Bridges can define if they can be blocked.
Tests
Same user blocking
-
A bridge is defined as non-blockable. A block is tried and fails. -
A bridge is defined as blockable. A block is tried and succeeds. -
A blocked bridge is tried to be called from the blocked thread and succeeds. -
A blocked bridge is tried to be called from other than the blocked thread and fails (halts). -
A thread that has blocked a bridge finishes. The block is lifted. -
A thread tries to block a blocked bridge, it can't.
Waiting for blocks
-
A thread waits for a blocked bridge, it does return. -
A thread waits for a blocked bridge, it does block. -
A thread waits for a non-blocked bridge, it returns immediately.
Different user blocking
-
A thread from a user tries to block a bridge blocked by another user, it succeeds. -
A thread from a user calls a bridge blocked by another user, it succeeds. -
A thread from a user A calls a bridge blocked by both A and another user, it halts.
Deadlocks
-
Two threads deadlock using blocks. The deadlock is detected and solved.
Final steps
-
Rename block
tolock
-
Implement frontend -
Implement tests for resources -
Test locking from programs
Edited by kenkeiras