Own implementation of multithread



Dear all,

I am working on a multithread application.
I have already built the TCL using --enable-threads.

In c++ code, I am trying to create many threads, each thread will
create its own interpreter.
Each interpreter will need to eval a script.

For example,

void * func( void * null ){
Tcl_Interp* tcl_interp = Tcl_CreateInterp();
Tcl_Init(tcl_interp);
char * script = "set a 1\n"
"set b 2\n"
"puts $a\n"
"puts $b\n";
Tcl_EvalObjEx(tcl_interp, script , TCL_EVAL_GLOBAL);
delete tcl_interp;
}

int main (){
....
for (int i = 0; i < 10000; ++i)
pthread_create(&tid,NULL,func,NULL);
....
}

I would like to ask is this approach is wrong?

Stephen Lai
.



Relevant Pages

  • Re: Own implementation of multithread
    ... Beyond that I agree with Alexandre andwonder if instead you can make the main controlling flow of control Tcl, ... Each interpreter will need to eval a script. ... void * func{ ...
    (comp.lang.tcl)
  • Re: Own implementation of multithread
    ... I have already built the TCL using --enable-threads. ... Each interpreter will need to eval a script. ... void * func{ ... I also suggest not using a tcl prefix for most things. ...
    (comp.lang.tcl)
  • Re: Own implementation of multithread
    ... I have already built the TCL using --enable-threads. ... Each interpreter will need to eval a script. ... Tcl with --enable-threads, which is only necessary if Tcl ... manages the threads and communication between them. ...
    (comp.lang.tcl)
  • Tcl thread local storage memory problem
    ... I am working on an application that originally uses one thread, TCL ... and the C-library to initialize an interpreter and executing standard ... InitializeThreadLocalStorage(); /*If no threads, initialize ... able to get Tcl thread local storage ...
    (comp.lang.tcl)
  • Re: File data format
    ... This is how I always look at data processing with Tcl: ... then let the very effecient tcl interpreter do the parsing. ... Create procs that match the data keys. ... date, commit, and compile, that matched the same signature, then your ...
    (comp.lang.tcl)