예제 #1
0
파일: sched.c 프로젝트: dikerex/theqvd
/*------------------------------------------------------------------------
------------------------- Execute the photoflo ---------------------------
------------------------------------------------------------------------*/
static Bool execute(floDefPtr flo, peTexPtr importer)
{
  bandMsk ready;
  peTexPtr  pet;
  peDefPtr  ped;
  pedLstPtr lst = ListEmpty(&flo->optDAG) ? &flo->defDAG : &flo->optDAG;
  CARD32    sched_count = SCHED_BAIL_OUT;
  CARD32    strip_count = flo->floTex->putCnt;

  if(importer) {
    /* Put the ImportClient element at the head of the ready-list */
    InsertMember(importer,&flo->floTex->schedHead);
    importer->scheduled = importer->receptor[IMPORT].ready;
  }
  do {
    /* execute elements from the head of the ready-list until it's empty
     *    (calls to schedule from the data manager may prepend
     *     additional elements to the ready-list)
     */
    while(!ListEmpty(&flo->floTex->schedHead)) {
      pet = flo->floTex->schedHead.flink;
      
      if(Activate(flo,pet->peDef,pet) && (ready = runnable(flo,pet))) {
	pet->scheduled = ready;	/* remember which bands keep us alive */
      } else {
	/* element is no longer runnable, remove it and check for errors
	 */
	RemoveMember(pet,pet);
	pet->scheduled = 0;
	if(ferrCode(flo))
	  return(flo->flags.active = FALSE);
      }
      if(strip_count != flo->floTex->putCnt) {
	sched_count = SCHED_BAIL_OUT;
	strip_count = flo->floTex->putCnt;
      } else if( !--sched_count)
	ImplementationError(flo,pet->peDef, return(FALSE));
    }
    /* Load all the elements onto the ready-list that can keep producing
     * output without requiring any additional input (e.g. ImportResource
     * elements).
     */
    for(ped = lst->flink; !ListEnd(ped,lst); ped = ped->flink)
      if(ped->peTex->emitting && !ped->peTex->admissionCnt)
	InsertMember(ped->peTex,&flo->floTex->schedHead);
    /*
     *  keep on trucking if there's nothing expected from the client
     */
  } while(!flo->floTex->imports && !ListEmpty(&flo->floTex->schedHead));
  
  /* if we still have stuff to do, count another round, otherwise shut it down
   */
  if(flo->floTex->imports || flo->floTex->exports)
    ++flo->floTex->exitCnt;
  else
    ddShutdown(flo);

  return(flo->flags.active);
}                               /* end execute */
예제 #2
0
void CSISController::InsertMembers ()
	{
	// if you change these, change Read and Write (for SignSIS) and KRawSkipCount
	InsertMember (iInfo);
	InsertMember (iSupportedOptions);
	InsertMember (iSupportedLanguages);
	InsertMember (iPrerequisites);
	InsertMember (iProperties);
	InsertMember (iLogo);
	InsertMember (iInstallBlock);
	InsertMember (iSignatures);
	InsertMember (iDataIndex);
	}
예제 #3
0
void CSISInfo::InsertMembers ()
	{
	InsertMember (iUid);
	InsertMember (iVendorUniqueName);
	InsertMember (iNames);
	InsertMember (iVendorNames);
	InsertMember (iVersion);
	InsertMember (iCreationTime);
	InsertMember (iInstallType);
	InsertMember (iInstallFlags);
	}
예제 #4
0
int main(int argc, const char* argv[])
{
    CudaInit();

    while (1) {
        unsigned int seed = time(NULL);
        srand(seed); //init random seed

        MEMBER population[POPULATION_SIZE];

        for (int i = 0; i < POPULATION_SIZE; i++) {
            InitializeRandomMember(&population[i]);
        }

        SortInitialPopulation(population, 0, POPULATION_SIZE - 1);

        for (int i = 0; i < POPULATION_PADDING; i++) {
            MEMBER member;
            InitializeRandomMember(&member);
            InsertMember(population, member);
            //PrintPopulation(population);
        }

        /* breed children */
        int best = 999999;
        for (int i = 0; i < CROSSES; i++) {
            MEMBER parents[2];
            MEMBER child;

            parents[0] = population[rand() % POPULATION_SIZE];
            parents[1] = population[rand() % POPULATION_SIZE];

            BiasedCross(parents, &child);
            InsertMember(population, child);

            if (population[0].num_cliques < best) {
                best = population[0].num_cliques;
                std::cout << best << std::endl;
            }

            if (population[POPULATION_SIZE - 1].num_cliques == population[0].num_cliques) {
                for (int i = 5; i < POPULATION_SIZE; i++) {
                    free(population[i].chromosome);
                    InitializeRandomMember(&population[i]);
                }
            }
        }

        std::cout << "Best member: " << population[0].num_cliques << std::endl;

        std::ofstream outfile;

        outfile.open("results.txt", std::ios_base::app);

        outfile << std::endl;
        outfile << "Best member: " << population[0].num_cliques << std::endl;
        for (int j = 0; j < CHROMOSOME_LENGTH; j++) {
            outfile << (char) (population[0].chromosome[j] + 0x30);
        }

        outfile << std::endl;

        /* echo seed for posterity */
        outfile << "SEED: " << seed << std::endl;
        outfile.close();

        for (int i = 0; i < POPULATION_SIZE; i++) {
            free(population[i].chromosome);
        }
    }
}