Henry,
Here is the MVF - minimum viable failure. It looks like the culprit is
"read_image" which is just a cover for "readimg_jqtide_". I'm running
under jconsole.
Set up in a directory with some .JPG files:
FLS=: 0{"1 dir '*.jpg'
createThreads 5
MUTEX=: 10 T. 1 NB. Recursive mutex; either fails.
mtFileWork=: 3 : 0
tm=. 6!:1''
while. 0<#FLS do.
tn=. ":3 T. '' NB. Thread number as char
varnm=. ' '-.~'threadVar',tn
smoutput 'Thread ',tn,' locking at ',":qts''
11 T. y
smoutput 'Thread ',tn,' locked at ',":qts''
(varnm,' FLS')=: split FLS
smoutput 'Thread ',tn,' unlocking at ',(":qts''),' for file ',flnm=.
>".varnm
13 T. y
smoutput 'Thread ',tn,' unlocked at ',":qts''
#read_image flnm NB. ¡Fails here!
end.
tm=. tm,~6!:1''
NB.EG mtFileWork t. '' MUTEX [ mtFileWork t. '' MUTEX [ mtFileWork t. ''
MUTEX [ mtFileWork t. '' MUTEX [ mtFileWork t. '' MUTEX
)
Any help is appreciated!
Thanks,
Devon
On Tue, May 10, 2022 at 4:46 PM Henry Rich <[email protected]> wrote:
> If you can get me a version that fails on Windows I'll look at it.
>
> Henry Rich
>
> On 5/10/2022 4:20 PM, Devon McCormick wrote:
> > Hi,
> >
> > Has anyone had success using the multi-threading mutex primitives? I've
> > had limited success - I'll be presenting some basic routines at NYCJUG
> this
> > evening (18:00 EDT -
> > https://www.meetup.com/J-Dynamic-Functional-Programming/) - but have
> been
> > unable to run multiple threads on a real-life process without crashing J.
> >
> > The following simplified demo seems to work OK but the version of this
> > where I do actual work crashes - with "Process shell<1> exited abnormally
> > with code 5" - after two to thirty repetitions.
> >
> > MUTEX=: 10 T. 0 NB. Fast mutex
> > createThreads=: 3 : '{{ 0 T. '''' }} ^:y]'''''
> > qts=: 6!:0
> > createThreads 5
> > GVAR=: 100?@$1e6 NB. Initialize global threads
> will
> > consume
> >
> > multiLockMsgUnlock=: 3 : 0
> > while. 0<#GVAR do.
> > tn=. ":3 T. '' NB. Thread number as char
> > varnm=: ' '-.~'threadVar',tn
> > smoutput 'Thread ',tn,' locking at ',":qts''
> > 11 T. y
> > smoutput 'Thread ',tn,' locked at ',":qts''
> > (varnm,' GVAR')=: split GVAR
> > smoutput 'Thread ',tn,' unlocking at ',(":qts''),' with
> > ',tn,'=',":".varnm
> > 13 T. y
> > smoutput 'Thread ',tn,' unlocked at ',(":qts''),';
> #GVAR=',":#GVAR
> > end.
> > )
> > NB. Start five processes (one line):
> > multiLockMsgUnlock t. '' MUTEX [ multiLockMsgUnlock t. '' MUTEX [
> > multiLockMsgUnlock t. '' MUTEX [ multiLockMsgUnlock t. '' MUTEX [
> > multiLockMsgUnlock t. '' MUTEX
> >
> > The actual work I'm doing is on files, a list of whose names corresponds
> to
> > the GVAR vector above.
> >
> > Any suggestions are welcome.
> >
> > Cheers,
> >
> > Devon
> >
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm