in reply to Re: Runing "regular" code with threaded perl
in thread Runing "regular" code with threaded perl

Yes, that's what happening, the instructions aren't being carried out sequentially. It is a multi-core system, but why does this matter? If I run a c program it runs as a single thread, it seems to have something to do with how perl is running the script. I don't know if it will be much help, but here's the explicit code fragment that fails:

bjmsys("xspec - ${tmp}.xcm", $v);

open(DAT, "${tmp}xsfit.dat") || die ("Could not open file!");

my @kT=<DAT>; close DAT;

It dies when it tries to open the file because it hasn't been created yet.
  • Comment on Re^2: Runing "regular" code with threaded perl

Replies are listed 'Best First'.
Re^3: Runing "regular" code with threaded perl
by moritz (Cardinal) on Jul 10, 2008 at 07:30 UTC
    bjmsys("xspec - ${tmp}.xcm", $v);

    Now it would be interesting to know what this mysterious sub bjmsys does.

    I somehow suspect that it launches an external application in the background, while it really should just launch it and wait for it to finish.

      I don't understand it at all, but it seems like that was the problem. bjmsys is my own routine, it's just a wrapper around system(), where it prints the argument to the screen before calling system() if $v > 0. If I replace bjmsys with system in the top level code things seem to run fine.

      As I said, I don't get it at all, but I just wanted the stupid thing to work and I guess I have my quick and dirty fix, so thanks!
Re^3: Runing "regular" code with threaded perl
by pc88mxer (Vicar) on Jul 10, 2008 at 07:28 UTC
    The problem seems to be with the bjmsys() function. What does it do and who wrote it?

    You should ask whoever is responsible for maintaining bjmsys() why it's returning before producing its output file on a multicore system.

Re^3: Runing "regular" code with threaded perl
by Anonymous Monk on Jul 10, 2008 at 13:44 UTC
    If it's a timing issue, you could just keep trying. Something like
    bjmsys("xspec - ${tmp}.xcm", $v); my $tries = 10; until ( open(DAT, "${tmp}xsfit.dat") || --$tries <= 0 ) { sleep 1; } die ("Could not open file: $!") if ($tries <= 0); my @kT=<DAT>; close DAT;
    Not quick, but dirty :)