Multithreading -- numbervars and autoload

Arun Lakhotia <[email protected]> Wed, 18 Jun 2014 19:12:13 -0500
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <CAPwrbFraJhoMtgj8N079q1-kOwpYuVKkbmkXmUXtyA+m3m9Gug@mail.gmail.com>
Hi Jan:

I got bumped from the swipl mailing list due to too many bounced mails. May
have been due to some mailer error. I have just subscribed with my gmail
address. This should be more reliable.

I am running into some issues that are most likely related to
multithreading.

My application is a webservice, developed using the http/json libraries. I
am not using an database operations -- no assert, retract, etc.

Issues:

1)  numbervars gives different ordering of printed symbol names when there
are multiple simultaneous accesses to the server, as compared when there is
only one client connection at any time.

The online document indicates that all library predicates are thread safe,
so I am assuming numbervars is also thread safe. However, to be on the safe
side I wrapped the call with a  "with_mutex(...)" call. Unless I have
goofed up in the use of with_mutex, I see that the numbering is still
messed.

So is numbervars inherently non-deterministic.

I should add I am comparing results from different runs with exactly the
same input.

2) Autoloading of library predicates doesn't seem to do well with threads.
I  use "format_to_chars/3" in a portray clause.  When the application is
run with multiple simultaneous clients, several of its threads would give
error that this predicate was not known. I never had any issue when I had a
single client connecting to the server at a time.

Thanks,

Arun
-------------- next part --------------
HTML attachment scrubbed and removed