Oops, yes. That explains why I wasn't getting threads. Fixing that gives me:
metcon'' 4 threads Task 4 waiting... Task 4 has the semaphore Task 9 waiting... Task 9 has the semaphore |value error: metcon But, you are right: it does not explain why some tasks were not running. Thanks, -- Raul On Wed, Jun 1, 2022 at 5:45 PM Elijah Stone <[email protected]> wrote: > > Looking. There is at least one typo: < should be <., presumably. But that is > not the issue. > > On Wed, 1 Jun 2022, Raul Miller wrote: > > > Oops, bad copy and paste > > > > Ignore the first (incomplete) declaration of metcon. > > > > Actually, please treat the declaration at > > http://www.jsoftware.com/pipermail/beta/2022-June/010566.html as > > canonical for this issue. > > > > Thanks, > > > > -- > > Raul > > > > On Wed, Jun 1, 2022 at 3:57 PM Raul Miller <[email protected]> wrote: > >> > >> https://www.rosettacode.org/wiki/Metered_concurrency > >> > >> I wanted to put together a more serious J implementation of the > >> rosettacode metered concurrency task. > >> > >> Unfortunately, either (a) I do not understand how the threading > >> primitives are supposed to work, or (b) they are not working properly. > >> > >> metcon=: {{ > >> lock=: 10 T. 0 > >> sleep=: 6!:3 > >> metcon=: {{ > >> lock=: 10 T. 0 > >> sleep=: 6!:3 > >> task=. {{ > >> 11 T. lock;_ NB. wait > >> sleep 2 > >> echo r=.'Task ',y,&":' has the semaphore' > >> 13 T. lock NB. release > >> r rplc 'has';'had' > >> }} > >> 0&T.@'' each i.0>4-1 T.'' NB. ensure at least four threads > >> r=. task t.''"0 i.10 NB. dispatch 10 tasks > >> #each r NB. wait for completion > >> 14 T. lock NB. discard lock > >> r > >> }} > >> I expect this to take about 20 seconds (because of the use of 6!:3) > >> and run ten tasks in 3 of the four guaranteed threads. > >> > >> Instead, what I get is this: > >> > >> metcon'' > >> Task 1 has the semaphore > >> Task 3 has the semaphore > >> Task 5 has the semaphore > >> Task 7 has the semaphore > >> Task 9 has the semaphore > >> |value error > >> | #each r > >> > >> So it looks like half of my tasks are getting lost somewhere, and it > >> looks like all of the results from those tasks are getting lost > >> somewhere. > >> > >> JVERSION > >> Engine: j904/j64avx2/windows > >> Beta-d: commercial/2022-05-19T20:39:35 > >> Library: 9.04.01 > >> Qt IDE: 2.0.3/6.2.4(6.2.4) > >> Platform: Win 64 > >> Installer: J904 install > >> InstallPath: c:/other/j904 > >> Contact: www.jsoftware.com > >> > >> Thanks, > >> > >> -- > >> Raul > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
