Re: Race condition on loading packages from 2 maxima processes in parallel?

David Scherfgen via Maxima-discuss <[email protected]> Thu, 18 Jun 2026 17:43:27 +0200
Newsgroups gmane.comp.mathematics.maxima.general
Message-ID <CAMTHLKhufhKwb2UMTzq=do7iKaep2f_hbJngGW2DNuJMrRx2=A@mail.gmail.com>
Raymond Toy <[email protected]>:

> The timeout mechanism seems dependent on the support from lisp. Is it
> reasonably portable?
>
We just need SLEEP, which is in CL.
The idea is: Try to acquire the lock. If it fails, wait one second and try
again. Repeat until succesful or total waiting time exceeds timeout.

> So basically, this is for locking operations when loading a file causes
> other files to be compiled? So a user in general won’t know what keyword to
> use unless they’ve already determined that it compiles other files? IIRC
> sometimes such things are silently compiled so there’s no indication that
> lots of things are being compiled.
>
> Perhaps such information could be passed to the file being loaded (via a
> defvar or something?) to acquire the lock when mk:oos (or asdf:oos) is used
> or if files are manually compiled? This is really the issue being solved
> here, right?
>
Yes, the issue arises when a call like "load(lapack)" is executed by
multiple processes in parallel, and files are compiled. Basically, this is
what happens during a "cold start".

Yes, in general, the user doesn't know. But it's sufficient if the package
itself knows. Take the LAPACK package for example: The lapack.mac file just
contains one line:

load("load-lapack.lisp");

So lapack.mac is just a proxy. This is ideal for our case, because we could
change it to:

load("load-lapack.lisp", lock=true);

Or it could check whether it actually needs to compile files (is that
possible using some MK-DEFSYSTEM API?) and only then use the lock. Other
packages could do it the same way.

Exposing the functionality via the proposed "with-lock" is just a
nice-to-have for users who may need it.

Alternative &#8203;

> &#8203;
>

_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss