예제 #1
0
void Window::runProgram(void)
{
  if(x < 1600)
  {
  createInputFile(matrixSize);
  char *thr_Path = "/home/rohit/fibthread";
  char *sin_Path = "/home/rohit/fibsingle";
  char *jthr_Path = "/home/rohit/fibjthread.jar";

  long sin = spoof(1, sin_Path);
  long thr = spoof(1, thr_Path);
  long jthr = spoof(2, jthr_Path);

  qDebug() << "Single: "<< sin;
  qDebug() << "PThread:" << thr;
  qDebug() << "JavaThread:" << jthr;

  sin = sin * 600 / 500;
  thr = thr * 600 / 500;
  jthr = jthr * 600 / 500;

  display->drawPixel(x, 500 - sin - 10, 0, matrixSize);
  display->drawPixel(x, 500 - thr - 10, 1, matrixSize);
  display->drawPixel(x, 500 - jthr - 10, 2, matrixSize);

  if(thr < sin){
      display->drawSpot(x, 500-sin-10, 500-thr - 10);
  }

  matrixSize += 10;
  x += 40;
}
}
예제 #2
0
OJInt32_t WindowsProcess::create(const OJString &cmd,
								const OJInt32_t timeLimit,
								const OJInt32_t memoryLimit,
								bool startImmediately)
{
    ILogger *logger = LoggerFactory::getLogger(LoggerId::AppInitLoggerId);

    {
        logger->logTraceX(OJStr("[process] - create - CMD='%s' T=%dms, M=%dbytes"),
            cmd.c_str(), timeLimit, memoryLimit);
    }

    if(!createInputFile())
    {
        logger->logError(OJStr("[process] - create - can't creat inputFile"));
        return -1;
    }

    if(!createOutputFile())
    {
        logger->logError(OJStr("[process] - create - can't creat outputFile"));
        return -1;
    }

    if (!jobHandle_.create(useToExcuter_))
    {
        logger->logError(OJStr("[process] - create - can't creat job"));
        return -1;
    }

    if (!jobHandle_.setLimit(timeLimit, memoryLimit))
    {
        logger->logError(OJStr("[process] - create - set job limit failed"));
        return -1;
    }
    
	OJChar_t cmdline[1024];
	wcscpy_s(cmdline, cmd.c_str());

	STARTUPINFO   si;
	PROCESS_INFORMATION   pi;
    ZeroMemory(&si, sizeof(si));
    ZeroMemory(&pi, sizeof(pi)); 
	
	si.cb = sizeof(si); 
	si.wShowWindow = SW_HIDE;//隐藏窗口
    si.hStdInput = inputFileHandle_;
    si.hStdOutput = si.hStdError = outputFileHandle_;
    si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; //使用handel项和wShowWindow项。

    DWORD createFlag = CREATE_SUSPENDED | CREATE_NO_WINDOW | CREATE_BREAKAWAY_FROM_JOB;

	bool res =  createProcess(
        NULL,    //   No module name (use command line).   
		cmdline, //   Command line.   
		NULL,    //   Process handle not inheritable.   
		NULL,    //   Thread handle not inheritable.   
		TRUE,   //   Set handle inheritance to ...
		createFlag, // creation  flags.  
		NULL,    //   Use parent 's environment block.   
		NULL,    //   Use parent 's starting  directory.   
		&si,     //   Pointer to STARTUPINFO structure. 
		&pi);    //   Pointer to PROCESS_INFORMAT\ION structure.

    
	if (!res)
    {
        logger->logErrorX(OJStr("[process] - can't creat process. last error: %u"), 
            GetLastError());
        return -1;
    }
		
    alive_ = true;
	processHandle_ = pi.hProcess;
	threadHandle_ = pi.hThread;

	if(startImmediately)
        return start();

	return 1;
}