in reply to Runing "regular" code with threaded perl

Can you give us an example of a script which doesn't work on your new box but used to work on your old one?

Is it possible that your new box is a multicore system, and now things are happening concurrently whereas before they were being performed sequentially? In any case, we'd probably need to see some code in order to tell you what's going on.

  • Comment on Re: Runing "regular" code with threaded perl

Replies are listed 'Best First'.
Re^2: Runing "regular" code with threaded perl
by kingskot (Sexton) on Jul 10, 2008 at 07:15 UTC
    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.
      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!
      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.

      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 :)