This adds a P/V style semaphore mechanism to the resource graph. This enables the user to specify a number of "id:count" tags associated with each resource which will reduce the parallelism of the CheckApply operation to that maximum count. This is particularly interesting because (assuming I'm not mistaken) the implementation is dead-lock free assuming that no individual resource permanently ever blocks during execution! I don't have a formal proof of this, but I was able to convince myself on paper that it was the case. An actual proof that N P/V counting semaphores in a DAG won't ever dead-lock would be particularly welcome! Hint: the trick is to acquire them in alphabetical order while respecting the DAG flow. Disclaimer, this assumes that the lock count is always > 0 of course.
68 lines
1.0 KiB
YAML
68 lines
1.0 KiB
YAML
---
|
|
graph: parallel
|
|
resources:
|
|
exec:
|
|
- name: pkg10
|
|
meta:
|
|
sema: ['mylock:1', 'otherlock:42']
|
|
cmd: sleep 10s
|
|
shell: ''
|
|
timeout: 0
|
|
watchcmd: ''
|
|
watchshell: ''
|
|
ifcmd: ''
|
|
ifshell: ''
|
|
pollint: 0
|
|
state: present
|
|
- name: svc10
|
|
meta:
|
|
sema: ['mylock:1']
|
|
cmd: sleep 10s
|
|
shell: ''
|
|
timeout: 0
|
|
watchcmd: ''
|
|
watchshell: ''
|
|
ifcmd: ''
|
|
ifshell: ''
|
|
pollint: 0
|
|
state: present
|
|
- name: exec10
|
|
meta:
|
|
sema: ['mylock:1']
|
|
cmd: sleep 10s
|
|
shell: ''
|
|
timeout: 0
|
|
watchcmd: ''
|
|
watchshell: ''
|
|
ifcmd: ''
|
|
ifshell: ''
|
|
pollint: 0
|
|
state: present
|
|
- name: pkg15
|
|
meta:
|
|
sema: ['mylock:1', 'otherlock:42']
|
|
cmd: sleep 15s
|
|
shell: ''
|
|
timeout: 0
|
|
watchcmd: ''
|
|
watchshell: ''
|
|
ifcmd: ''
|
|
ifshell: ''
|
|
pollint: 0
|
|
state: present
|
|
edges:
|
|
- name: e1
|
|
from:
|
|
kind: exec
|
|
name: pkg10
|
|
to:
|
|
kind: exec
|
|
name: svc10
|
|
- name: e2
|
|
from:
|
|
kind: exec
|
|
name: svc10
|
|
to:
|
|
kind: exec
|
|
name: exec10
|