Have you considered using a initial J session to launch your “main script”?
(Which would then start jhs or whatever, for development purposes...) That said, virtual address randomization (or other anti-malware practices) might defeat this approach. (So you might also have to disable that.) Anyways, if all processes use the same address layout for the relevant shared libraries, this should work. Thanks, — Raul On Tuesday, July 24, 2018, 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