Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
13
Task/Metered-concurrency/J/metered-concurrency-1.j
Normal file
13
Task/Metered-concurrency/J/metered-concurrency-1.j
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
metcon=: {{
|
||||
sleep=: 6!:3
|
||||
task=: {{
|
||||
11 T. lock NB. wait
|
||||
sleep 2
|
||||
echo 'Task ',y,&":' has the semaphore'
|
||||
13 T. lock NB. release
|
||||
}}
|
||||
lock=: 10 T. 0
|
||||
0&T.@'' each i.0>.4-1 T.'' NB. ensure at least four threads
|
||||
> task t.''"0 i.10 NB. dispatch and wait for 10 tasks
|
||||
14 T. lock NB. discard lock
|
||||
}}
|
||||
11
Task/Metered-concurrency/J/metered-concurrency-2.j
Normal file
11
Task/Metered-concurrency/J/metered-concurrency-2.j
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
metcon''
|
||||
Task 0 has the semaphore
|
||||
Task 1 has the semaphore
|
||||
Task 2 has the semaphore
|
||||
Task 3 has the semaphore
|
||||
Task 4 has the semaphore
|
||||
Task 9 has the semaphore
|
||||
Task 5 has the semaphore
|
||||
Task 7 has the semaphore
|
||||
Task 8 has the semaphore
|
||||
Task 6 has the semaphore
|
||||
31
Task/Metered-concurrency/J/metered-concurrency-3.j
Normal file
31
Task/Metered-concurrency/J/metered-concurrency-3.j
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
scheduledumb=: {{
|
||||
id=:'dumb',":x:6!:9''
|
||||
wd 'pc ',id
|
||||
(t)=: u {{u 0{::n[y[erase 1{::n}} (y;t=. id,'_timer')
|
||||
wd 'ptimer ',":?100
|
||||
}}
|
||||
|
||||
sleep=: 6!:3 NB. seconds
|
||||
timestamp=: 6!:1 NB. seconds
|
||||
|
||||
acquire=: {{
|
||||
imprison y
|
||||
while. 1<count y do.
|
||||
release y
|
||||
sleep 0.1
|
||||
imprison y
|
||||
end.
|
||||
}}
|
||||
|
||||
release=: {{ counter=: (<:y{counter) y} counter }}
|
||||
imprison=: {{ counter=: (>:y{counter) y} counter }}
|
||||
count=: {{ y { counter }}
|
||||
|
||||
counter=: 0 0
|
||||
|
||||
demo=: {{
|
||||
acquire 0
|
||||
echo 'unit ',y,&":' acquired semaphore, t=',":timestamp''
|
||||
sleep 2
|
||||
release 0
|
||||
}}
|
||||
6
Task/Metered-concurrency/J/metered-concurrency-4.j
Normal file
6
Task/Metered-concurrency/J/metered-concurrency-4.j
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
demo scheduledumb"0 i.5
|
||||
unit 1 acquired semaphore, t=54683.6
|
||||
unit 0 acquired semaphore, t=54685.6
|
||||
unit 4 acquired semaphore, t=54687.7
|
||||
unit 2 acquired semaphore, t=54689.7
|
||||
unit 3 acquired semaphore, t=54691.7
|
||||
Loading…
Add table
Add a link
Reference in a new issue