All Manuals > LispWorks User Guide and Reference Manual > 19 Multiprocessing

NextPrevUpTopContentsIndex

19.12 Native threads and foreign code

Support for native threads differs between platforms as described in this section.

19.12.1 Native threads on Windows, Mac OS X, Linux, x86/x64 Solaris and FreeBSD

Each Lisp mp:process has a separate native thread and in LispWorks 6.0 and later versions these threads can run simultaneously.

Note: In LispWorks 5.1 and earlier versions, you can have many runnable mp:process objects/native threads, but Lisp code can only run in one thread at a time and a lock is used to enforce this. This can limit performance on a computer with multiple CPU cores. When a foreign function is called using the FLI, the lock is released until the function returns. This allows other Lisp threads to run, for instance while waiting for a database query to execute.

You can call back into Lisp using fli:define-foreign-callable in any thread, without any other setup.

Threads running Lisp code can be rescheduled preemptively, so if you call into Lisp from more than one thread simultaneously and one request takes a long time then it will not delay the requests in other threads.

19.12.2 Native threads on other platforms

Lisp uses a single native thread and implements user level threads to support mp:process.

You can only call back into Lisp from its single native thread.

Note: This section applies only to LispWorks for AIX/PowerPC and SPARC Solaris (not LispWorks for Linux, FreeBSD, x86/x64 Solaris or Macintosh).

19.12.3 Foreign callbacks on threads not created by Lisp

If a foreign callback occurs on a thread that was not created by LispWorks, then some data is kept on the Lisp side to make the foreign callback entry faster next time. This data is removed when the thread dies, but you force it to be removed sooner by calling last-callback-on-thread.


LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex