ramanbull / byte-unixbench

Automatically exported from code.google.com/p/byte-unixbench
0 stars 0 forks source link

Pipe-based Context Switching - slave write failed: Broken pipe #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Execute the test harness with ./Run
2. Notice that while the Pipe-based Context Switching test is running, it
fails with the error message: "slave write failed: Broken pipe; aborting"
3. This only happens on certain platforms, as I don't see this occur on all
hardware/software configurations. But I have seen it happen on certain
Ubuntu releases.

I'm currently seeing this with Ubuntu Karmic derivative with the 2.6.30
kernel, i686, running on an ASUS EEE PC with INtel Atom CPU N280 @ 1.66ghz.

Original issue reported on code.google.com by kdlu...@gmail.com on 3 Nov 2009 at 12:00

GoogleCodeExporter commented 9 years ago
Did you find a solution to this problem?  I'm experiencing it too, but only 
when run from the python subprocess module.

uname:  Linux brasil 2.6.28-18-generic #60-Ubuntu SMP Fri Mar 12 04:40:52 UTC 
2010 i686 GNU/Linux
cpu: GenuineIntel Pentium(R) Dual-Core CPU       T4200  @ 2.00GHz
distro: xubuntu jaunty
python: 2.6.2

Here's a code snippet showing how I'm running it:

        p = subprocess.Popen(cmd, shell=True)
        retval = p.wait()

and cmd looks like this:

/usr/local/bench/unixbench-5.1.2/Run context1 > 
/usr/local/bench/archive/2010-06-07_08:53:55/context1.out 2> 
/usr/local/bench/archive/2010-06-07_08:53:55/context1.err

stderr looks like this:

**********************************************
Run: "Pipe-based Context Switching": slave write failed: Broken pipe; aborting

Thanks!
Jacob

Original comment by jaco...@gmail.com on 7 Jun 2010 at 11:41

GoogleCodeExporter commented 9 years ago
No, I haven't found a solution in UnixBench or in Python. So, to solve this 
issue, I implemented a work around using a java program. Here is the java 
source, and what I do is package this java code with UnixBench, and then 
compile it during the step where I compile UnixBench, and then simply call this 
java program from Python with subprocess.Popen() using a command of java 
runbench (my java file name). Just modify the String args command with how you 
want to run UnixBench, and this should work, assuming you have a java installed.

runbench.java:
==================================================
import java.io.*;
import java.util.*;

class StreamGobbler extends Thread {

  InputStream is;
  String type;

  StreamGobbler(InputStream is, String type) {
    this.is = is;
    this.type = type;
  }

  public void run() {
    try {
      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      String line=null;
      while((line = br.readLine()) != null)
        System.out.println(type + ">" + line);
    } catch (IOException ioe) {
        ioe.printStackTrace();
        }
  }
}

public class runbench extends Thread {

  static void runbench() {
    try {
      Runtime runtime = Runtime.getRuntime();
      String[] args = new String[] {"bash", "-c", "./Run -c 16"};
      Process p = runtime.exec(args);
      StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR");
      StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT");
      errorGobbler.start();
      outputGobbler.start();
      int exitVal = p.waitFor();
      System.out.println("ExitValue: " + exitVal);
    }
  catch (Throwable t) {
    t.printStackTrace();
    }
  }

  public static void main(String[] args) throws IOException {
    runbench();
  }
}
===============================================================

Original comment by kdlu...@gmail.com on 7 Jun 2010 at 11:50