help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PThread + Feval


From: Søren Hauberg
Subject: Re: PThread + Feval
Date: Thu, 30 Dec 2010 12:16:23 +0100

tor, 30 12 2010 kl. 11:29 +0100, skrev Surfing:
> Hi all,
> I'm writing some code in C++, compiling it with mkoctfile from Octave.
> 
> I used pthread to obtain a multithread calculations and it works for 
> almost everything.
> But now I've a problem ...
> 
> I want to do simply this:
> 
> double func1(double first, double second)
> {
>      octave_value_list fargs;
>      fargs(0) = octave_value(first);
>      fargs(1) = octave_value(second);
>      return feval(func2,fargs)(0).double_value();
> }
> 
> If I execute this in a single thread mode, it works... but when I run in 
> in multithread mode (so more threads calls that function in the same 
> time), it gives me a segmentation fault at the assignment fargs(0) = 
> ...  after some iterations...
> 
> If I try to assign those value to a simple double array it works...but 
> obviously then I can't pass that array to feval ....
> 
> Any suggestions?

I hate to say this, but the best suggestion is: don't do that!

Octave is *not* thread-safe. You may find that a good part of liboctave
is thread-safe (though I don't think all of it is), but the interpreter
(which you invoke with 'feval') is highly unsafe.

Søren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]