RE:Re: [ROOT] background job from ROOT/CINT

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Tue Apr 24 2001 - 14:42:55 MEST


Hello Prasad,


I understand your request. In fact, I thought of the same thing
for long time. 

Now, there are several ways to do such things with different limitations.

1) in ROOT
   Because ROOT system has really smart object management system, what is
  explained by Fons and Rene would be the best solution. (I do not go
  deeper here, because they already explained it)

2) with pure Cint, using fork
   If you use pure Cint only combined with your library, there are other
  choices. As Fons pointed out, if you accept to run the background job
  in a forked process, it can be easily performed by Cint too. Cint
  supports fork() system call in include/posix.dll.  In order to keep
  the result, you need to save it to a file.  Refer to the example in
  demo/mthread/fork.cxx

    #include <unistd.h>
    void doit() {
       pid_t pid = fork();
       if(0==pid) {
          RunBackGround();
          SaveResult();
          exit(0);
       }
       return;
    }

3) with pure Cint, multi thread library
   This is somewhat similar to 1) because you need to precompile background
  job. Refer to the example in demo/mthread/ptmain.cxx (pthread) and
  mtmain.cxx (Windows thread).

4) with pure Cint, using fork and shared memory
   This option is not implemented yet. Basically, you allocate a shared
  memory area, fork process and run the background job. When it is done,
  copy the result in the shared memory area so that the parent process can
  refer to.
   This option has a limitation that the result must not include any pointer
  to the forked process.
   Shared memory library is supported by <sys/ipc.dll>. Refer to the example
  in demo/ipc directory. 


Does any of above satisfy your needs?

Masaharu Goto



>Date: Tue, 24 Apr 2001 11:16:29 +0200
>From: Fons Rademakers <Fons.Rademakers@cern.ch>
>To: "B.V.L.S.Prasad" <shiva@mbu.iisc.ernet.in>
>Cc: Rene Brun <Rene.Brun@cern.ch>, Masaharu Goto <MXJ02154@nifty.ne.jp>,
>    roottalk@pcroot.cern.ch, rootdev@pcroot.cern.ch
>Subject: Re: [ROOT] background job from ROOT/CINT...
>
>Hi Prasad,
>
>  altough it looks natural to be able to run a script in the background
>the script can never run in the same ROOT session, just like in the shell
>a background job runs not in the same shell but in a newly forked shell.
>This feature was important in shells in the time one only had simple
>teletype terminals, but now in the time of windowing systems it is
>much easier to run different jobs in different windows instead of all jobs
>as background processes in a single window. Just run several ROOT sessions
>in several windows and you won't need the background option.
>
>Cheers, Fons.
>
>
>On Tue, Apr 24, 2001 at 02:38:14PM +0400, B.V.L.S.Prasad wrote:
>> Hi Rene, Masa and Others,
>> 
>>      I think my question is mis-INTERPRETED: as an example:
>> 
>> as everybody knows, in a shell we can give a background job:
>> suppose say minimization problem, which takes days to come to a stop..
>> (especially if its a simulated annealing method).
>> 
>> >>@user>>mimimize < someinput.file >somelog.file & //'&' is for 
backgrounding
>> >>@user>>bla!bla     //I can start doing some other work here without 
>>                      // waiting for the minimization results...
>> 
>> Now, my wish in CINT/ROOT:--
>> 
>> Root[0] .x myTest.C          // this will execute the program/script and 
only
>>      // then the prompt will be offered for the next command...
>> Root[1]
>> 
>> Instead of that :
>> 
>> Root[0] .x myTest.C &        // some backgrounding ability......
>> Root[1] .x myTest2.C    // etc...I concentrate on someother work, while
>>                      // present work is in background.....
>> 
>> did I make myself clear....?????
>>      I personally feel, this wish is more realizable in UNIX/LINUX
>> systems than in WINDOWS systems...even then its worth adding such a
>> facility...isnt it ????
>> 
>> why I got this thought :I work in MacroMolecular Crystallography, where 
>> refinement, energy minimization will go into ~500 cycles...etc...
>> so, I dont want to wait till 500 cycles are over. In the mean time,
>> I want to do some other analysis etc....but still being in the same
>> environment...i.e the CINT/ROOT environment...
>> and hence this wish ......
>> 
>> Root/Cint is ALMOST SHELL ( i feel better with this than other
>> conventional shells, I feel more handicapped with others..)....so I felt,
>> lets make a FULL SHELL.
>> 
>> Can Root/Cint handle such a heavy work..I hope its OOF&D is for such 
>> type of heavy tasks.
>> 
>> Hopefully, this wish is not stupid . :-) :-)
>> 
>> I will be glad, if my ignorance is pointed out in this wish..
>> 
>> thankyou for your time...
>> 
>> sincerly 
>> prasad.
>> 
>> > Hi,
>> > If you have a script, say myTest.C
>> > To execute this script with the interpreter in a Root session, you do:
>> >  root > .x myTest.C
>> > Within the Root environment, you can also use the ACLIC (Automatic 
Compiler
>> > Linker interface to CINT) to compile your script with the native compiler
,
>> > generate an intermediate shared lib, load it and execute with
>> >  root > .x myTest.C++
>> > In order to use ACLIC, your script must be a valid C++ piece of code with
>> > all the include statements. Note that the includes are ignored when 
executed via
>> > CINT if they refer to classes already known to the system.
>> > 
>> > I suggest you to read the Root Users Guide where all that is explained.
>> > 
>> > Rene Brun
>> > 
>> > 
>> > B.V.L.S.Prasad wrote:
>> > > 
>> > > Hello rooter/cinters,
>> > > 
>> > >         if the C++ script/analysis is very large, is
>> > > there any provision to send this particular job into background
>> > > processing within the INTERPRETOR ENVIRONMENT.
>> > > 
>> > >         this I personally feel, will make Root/Cint more
>> > > reallistic in its objectives....and more FULL in itself...
>> > > 
>> > > if such a provision is there, please inform me.
>> > > 
>> > > I could not locate in tutorials.
>> > > 
>> > > if this provision doesnt exist, can you put in the wishlist..??
>> > > it will really have a great impact on speed of programming
>> > > and continuity of programming.( mental block is reduced).
>> > > 
>> > > I would be glad to know the +ves/-ves of this wish.
>> > > 
>> > > Thanks in advance for the help...
>> > > 
>> > > Happy Day,
>> > > Prasad, B.V.L.S.,
>> > > Research Scholar.
>> > > 
*****************************************************************************
>> > >    AIM OF SCIENTIFIC ADVENTURE :          NATURE CRYSTALLOGRAPHY
>> > > 
*****************************************************************************
>> > > _________   __________   ________   ___________   ___________   
___________
>> > > |Thought|   | Fourier|   |      |   |Different|   | Fourier |   
|Structure|
>> > > | waves |-->|Analysis|-->|NATURE|-->|Forms of |-->|Synthesis|-->|   of 
   
|
>> > > |       |   |        |   |      |   |Knowledge|   |         |   | NATUR
E  
|
>> > > |_______|   |________|   |______|   |_________|   |_________|   
|_________|
>> > > 
>> > > 
*****************************************************************************
>> > > shiva@mbu.iisc.ernet.in         PROTEIN CRYSTALLOGRAPHY           
...Shiva
>> > > 
*****************************************************************************
>> > 
>
>-- 
>Org:    CERN, European Laboratory for Particle Physics.
>Mail:   1211 Geneve 23, Switzerland
>E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
>WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET