[Ecls-list] Multithreaded globals

Juan Jose Garcia Ripoll lisp at arrakis.es
Mon Nov 7 05:07:18 UTC 2005


On Mon, 2005-11-07 at 23:56 +1100, Dean O'Connor wrote:
> Hi
> 
> I am still dualling with our multithreaded C app. So far 
> ecl_import_current_thread() is working well :)
> 
> I have been finding dynamic variables very useful and am keen to know 
> what happens over multiple threads.
> 
> In what way can I create a variable to be:
> -  global across all threads ?
> -  global within a thread ?
> 
> So what happens to defparameter/var variables in the main thread vs ones 
> created after calling ecl_import_current_thread() ?

Currently there is no such distinction between _main_ and _other_
threads. This has an immediate consequence, which is that DEFPARAMETER
and DEFVAR always establish global variable bindings which are common to
_all_ threads.

There are two situations in which you get local bindings:

1) When you create a process with MAKE-PROCESS. There you can specify a
list of variables that you want to be local to the process.

2) When you make a LET/LET*/DO... binding, it is local to the thread.

It may be a little bit inconvenient, but I did not come up with a better
alternative without changing the syntax of DEFPARAMETER/DEFVARIABLE.

Regards,

Juanjo





More information about the ecl-devel mailing list