[ROOT] Questions about thread and Apache

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Wed Jul 19 2000 - 14:09:36 MEST


Dear Yap,

I am happy to answer your questions.

>i wrote a small program which do a million loop
>EiC takes 14second and CINT only take 3.8 seconds,
>and PHP4 takes more than 30 second, so i think CINT is amazing
>and perhaps the fastest interpreted enviroment available,

In fact, Cint has incremental bytecode compiler which compiles loops
and simple functions. This makes program loading and execution. 
However, cint's incremental bytecode compiler has limitations. So,
a small difference can make it slow. Please refer to doc/bytecode.txt
for more detail.

>i would like to ask that if you have plan to
>make CINT as a standard extension in Apache (like Perl and PHP)?
>so that more people will benefit from it .

There was a gentleman who implemented Cint-Apache. However, I lost
his e-mail address.  I am quite ignorant to Apache, and unable
to comment this directly.

>for the time being, i will try to use the second approach
>you suggest, because in Win32 enviroment, thank you.
>one more thing to ask , beside G__calc ,
>could G__loadfile and G__exec_tempfile take benefit in this
>(CrititalSection) model?

G__exec_tempfile() is already protected by G__LockCriticalSection().
G__loadfile() is not, but it is easy to do so. Before doing so, I 
need to check if it is OK for other applications.

BTW, I attach example for thread protecting functions below.

Thank you
Masaharu Goto

/************************************************************************
* Thread Safe protection for ROOT
*
* You need to write 4 functions. In case of Windows
*
*************************************************************************
* #include <windows.h>
* static DWORD R__ProtectThreadId;
* static CRITICAL_SECTION R__ProtectCriticalSection;
*
* void R__StoerLockThread() {
*   R__ProtectThreadId=GetCurrentThreadId();
* }
*
* int R__IsSameThread() {
*   if(R__ProtectThreadId==GetCurrentThreadId()) return(1);
*   else return(0);
* }
*
* void R__EnterCriticalSection() {
*   EnterCriticalSection(&R__ProtectCriticalSection);
* }
*
* void R__LeaveCriticalSection() {
*   LeaveCriticalSection(&R__ProtectCriticalSection);
* }
*************************************************************************
* 
* and then initialize the library as follows. You need to register above
* 4 functions to G__SetCriticalSectionEnv().
*
*************************************************************************
* #include <G__ci.h>
* void InitThreadLock() {
*   InitializeCriticalSection(&R__ProtectCriticalSection);
*   G__SetCriticalSectionEnv(R__IsSameThread,R__StoreLockThread
*                            ,R__EnterCriticalSection,R__LeaveCriticalSection)
;
* }
*
************************************************************************/




>----- Original Message -----
>From: Masaharu Goto <MXJ02154@nifty.ne.jp>
>To: <yap@jethyper.com.tw>
>Cc: <roottalk@pcroot.cern.ch>
>Sent: Monday, July 17, 2000 6:23 PM
>Subject: RE:MOD_CINT: problem with Win32 version of
>
>
>> Hello Yap,
>>
>> Thank you for your message.
>>
>> Making cint thread safe is really difficult. So, for Win32, you need
>> to find workaround. One way is to emurate pre-forking model in the
>> thread. I am not sure what information you need to pass from server loop
>> process to thread process. If it is not too much, this method can work.
>> Basically, you start separate MOD_CINT process in created thread and pass
>> common information. Then let cint run the script.
>>
>> Another way is to block your threads by following CINT API. First, you
>> create 4 functions to 1) check identity of thread, 2) store current thread
>> ID, 3) enter critical section, 4) leave critical section. Then you
>> give pointer to those functions to G__SetCriticalSectionEnv() API.
>> If you use G__calc(char *expr) API, the thread will be protected.
>>
>> void G__SetCrititalSectionEnv(int (*issamethread)()
>>                              ,void (*storelockthread)()
>>                              ,void (*entercs)()
>>                              ,void (*leavecs)()) ;
>> void G__LockCriticalSection();    // just as reference
>> void G__UnlockCriticalSection();  // just as reference
>>
>> Drawback of this method is that 2nd thread waits until the first thread
>> finishs.
>>
>> Thank you
>> Masaharu Goto
>>
>> P.S.
>>  Rooters,
>>
>>   If you have suggestion, please let us know.
>>
>>
>>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET