Exemplo n.º 1
0
void resultAvailable (int jobID) {
  pthread_mutex_lock(&end_mutex);
  if (jobID < 0) {
    Job tmpJob;
    tmpJob.jobID = jobID;
    tmpJob.returnTo = defaultRCID;
    JobResults *jr = getResults(&tmpJob);
    printf("JM  (%i): got profiling result number %i\n", myid, jobID);
    deleteResults(jr);
    printf("JM  (%i): deleted profiling result number %i.\n", myid, jobID);
    profilesReceived++;
    pthread_cond_signal(&profile_over);
    pthread_mutex_unlock(&end_mutex);
    return;
  }
//  printf("JM  (%i): jobID %i's results arrived. GONNA FETCH'EM.\n", myid, jobID);

  jobRes[jobID] = getResults(job[jobID]);


//  printf("JM  (%i): jobID %i's results fetched. Job %s (%i).\n", myid, jobID,
//      jobRes[jobID]->returnStatus == JOB_RETURN_STATUS_FAILURE ? "FAILED to execute" : "executed successfully",
//      jobRes[jobID]->returnStatus);

  if (jobRes[jobID]->returnStatus == JOB_RETURN_STATUS_FAILURE)
    exit (EXIT_FAILURE);


  nArrivals++;
  pthread_mutex_unlock(&end_mutex);

  if (nArrivals == NJOBS)
    savePic();
}
Exemplo n.º 2
0
void savePic () {

  if (gettimeofday(&end, NULL)) { //TODO a ver: clock_getres
    perror("gettimeofday");
    return;
  }
  timeval_subtract(&result, &end, &start);

  double timeWaited = result.tv_sec + (result.tv_usec / 1000000.0);
  printf("JM  (%i): Done! Time waited: %f.\n", myid, timeWaited);

//  for (int i = 0; i < NJOBS; i++)
//    fprintf(stderr,"JM  (%i): Number of iterations: %i\n", myid, *((int *) jobRes[i]->results[0]));



  printf("JM  (%i): Saving image.\n", myid);
  FILE *fd = fopen ("file.ppm", "w");
  if (fd == NULL) {
    fprintf (stderr,"Couldn't open 'file.ppm' for writing! Aborting...\n");
    exit (EXIT_FAILURE);
  }


  int *p;

  fprintf (fd, "P6\n%d %d\n255\n", WIDTH, HEIGHT);
  for (int j = 0; j < NJOBS; j++) {

    p = (int *) jobRes[j]->results[0];

    for (int i = 0; i < WIDTH*jobHeight; i++) {
      fputc(rgb[p[i]][0], fd);
      fputc(rgb[p[i]][1], fd);
      fputc(rgb[p[i]][2], fd);
    }
  }

  fclose (fd);


  printf("JM  (%i): All jobs done.\n", myid);

  for (int i = 0; i < NJOBS; i++) {
    deleteJob(job[i]);
    deleteResults(jobRes[i]);
  }



  pthread_mutex_lock(&end_mutex);
  program_over = true;
  pthread_cond_signal(&end_condition);
  pthread_mutex_unlock(&end_mutex);
}
Exemplo n.º 3
0
BOOL CSearchResultDlg::OnSetActive() 
{
	CPropertySheet *wiz = (CPropertySheet *) GetParent();
	wiz->SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);

	int n = getUdpSession()->sessionCount;
	if (n > 0) {
		CString str;
		str.Format(IDS_TITLE_SEARCH_RESULT, n);
		wiz->SetTitle(str);
	}

	if (!isActiveFromNext) {
		m_ctlResult.DeleteAllItems();
		deleteResults();
		OnSearchNext();
	}
	return CPropertyPage::OnSetActive();
}
Exemplo n.º 4
0
CSearchResultDlg::~CSearchResultDlg()
{
	deleteResults();
}