package emulatorinterface.communication.mmap; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.nio.IntBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; import java.util.ArrayList; import config.SimulationConfig; import config.SystemConfig; import emulatorinterface.communication.*; import generic.CircularPacketQueue; /*XXX * Caution, this code has not been tested. * */ public class MemMap extends IpcBase { // Must ensure that this is same as in mmap.h public static final int COUNT = 1000; static final String FILEPATH = "pfile"; File aFile; RandomAccessFile ioFile; FileChannel ioChannel; private IntBuffer ibuf; private IntBuffer lockBuf; MappedByteBuffer buf; MappedByteBuffer lBuf; public MemMap(){ super(); aFile = new File (FILEPATH); try { ioFile = new RandomAccessFile (aFile, "rw"); ioChannel = ioFile.getChannel (); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public Process startPIN(String cmd) throws Exception{ Runtime rt = Runtime.getRuntime(); try { Process p = rt.exec(cmd); StreamGobbler s1 = new StreamGobbler ("stdin", p.getInputStream ()); StreamGobbler s2 = new StreamGobbler ("stderr", p.getErrorStream ()); s1.start (); s2.start (); return p; } catch (Exception e) { return null; } } public void waitForJavaThreads() { try { // this takes care if no thread started yet. free.acquire(); // if any thread has started and not finished then wait. for (int i=0; i fromPIN) { return 0; // TODO Auto-generated method stub } public ArrayList fetchManyPackets(int tidApp, int readerLocation, int numReads) { // TODO Auto-generated method stub return null; } @Override public void errorCheck(int tidApp, long totalReads) { // TODO Auto-generated method stub } @Override public int fetchManyPackets(int tidApp, CircularPacketQueue fromEmulator) { // TODO Auto-generated method stub return 0; } }