To amplify what Eric said:
Two threads cannot have access to the same J namespaces. There are
currently no locking mechanisms to allow two tasks to modify the same
tables. Nor does the memory allocator work if one thread allocates a
block and another thread frees it.
You could share data between the threads using mapped files, or
communicate between them with sockets.
It might be interesting to have the notion of a shared locale. Names
within a shared locale could be accessed by multiple threads. It might
also be interesting to have facilities for putting threads to sleep and
waking them up. We don't have any plans for features like these,
because we have never had a concrete proposal for how to use them.
Henry Rich
On 7/24/2018 10:31 AM, Eric Iverson wrote:
You have an unusual, but interesting scenario. I apologize as I really do
not have the time to think about this properly.
Is this what you are trying to do:
Main - normal J task - for example, in jconsole
Main J task starts a sub task (which we will call A) with: p=. (libj,'
JInit x') cd ''
The name spaces of tasks Main and A are separate.
You want to run J code in task A to call J code in task M.
***
An interesting idea. Threads is an additional complication.
If this were allowed to happen, you'd have 2 ways (jconsole keyboard and A
use of JDo) to run sentences in MAIN.
This has some serious problems.
I think if you could get the MAIN jt, you'd just have more problems down
the road.
***
Perhaps other forum members with an interest in this type of problem can
help.
On Tue, Jul 24, 2018 at 9:45 AM, Sergey Kamenev <jsof...@inetstar.ru> wrote:
Hi, Eric!
Why not just load your main script and then use the functions and variables
directly.
You offer me using a trick.
This trick make debug more complicated.
Perhaps you could give a very simple example of exactly what you want to
do. It is not clear what you meany by "return of a session of the main J
script'.
Short example:
Typical use:
Initialize the DLL, returning a J session number:
p=. (libj,' JInit x') cd ''
┌────────┐
│53024912│
└────────┘
I need this:
p=. (libj,' JCurrSession x') cd ''
┌────────┐
│23452342│
└────────┘
Main script:
var1=: ...
var2=: ...
function1=: ...
After I load libj.so:
(libj,' JDo i x *c') cd p,<cmd NB. send to J DLL
┌─┬────────┬────────────────────┐
│0 │23452342│ echo var1 function1 var2│
└─┴────────┴────────────────────┘
In session 53024912 my variables var1 and var2 inaccesible, and function1
also.
If I'm know session of main script then I can using var1, var2, function1.
*Details about my task:*
I write the optimizer of trade strategy on J - test.ijs script which load
trade advisers also written in J.
This is massive computer job requires multiple processes or threads.
I have wanted to use threads in J.
Linux have libpthread.so
J has support of using shared libraries.
Thread have multiple advantages: memory economy (shared data for all
threads) and lower CPU consumption against processes.
I want to make the following:
Get libj.so entering address:
'/lib/libdl.so.2 dlopen x *c i' cd 'libj.so';2
┌────────┬───────┬─┐
│27652176│libj.so│2│
└────────┴───────┴─┘
Get JDo procedure address:
'/lib/libdl.so.2 dlsym x x *c' cd 27652176; 'JDo'
┌───────────────┬────────┬───┐
│139689066604876│27652176│JDo│
└───────────────┴────────┴───┘
Create thread:
Adr=: 0
'/lib/libpthread.so.0 pthread_create x x x x x' cd Adr; NULL;
139689066604876; NULL
In this example do not shown hot to pass parameter for JDo. But this is
possible with function mema and memw.
I need real access for JDo to varibles and function of main script.
Sergey.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
---
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