wbtl_file::offset_type wbtl_file::get_next_write_block() { // mapping_lock has to be aquired by caller sortseq::iterator space = std::find_if(free_space.begin(), free_space.end(), bind2nd(FirstFit(), write_block_size) _STXXL_FORCE_SEQUENTIAL); if (space != free_space.end()) { offset_type region_pos = (*space).first; offset_type region_size = (*space).second; free_space.erase(space); if (region_size > write_block_size) free_space[region_pos + write_block_size] = region_size - write_block_size; free_bytes -= write_block_size; STXXL_VERBOSE_WBTL("wbtl:nextwb p" << FMT_A_S(region_pos, write_block_size) << " F f" << FMT_A_C(free_bytes, free_space.size())); return region_pos; } STXXL_THROW2(io_error, "OutOfSpace, probably fragmented"); return offset_type(-1); }
int ejecutaralgoritmo(int pIdProceso, int pTamanoProceso ){ switch (tipoAlgoritmo){ case 1 : return FirstFit(pIdProceso, pTamanoProceso, datos, *tamano); case 2 : return BestFit(pIdProceso, pTamanoProceso, datos, *tamano); case 3 : return WorstFit(pIdProceso, pTamanoProceso, datos, *tamano); } }
int procesoBloqueado(int pIdHilo){ int posicion = 0; obtenerSemaforoMemoria (semaforoIdBloqueado); posicion = FirstFit(pIdHilo, 1, bloqueado, MEMORIABLOQUEADO); liberarSemaforoMemoria(semaforoIdBloqueado); return posicion; }
void OnlineFirstFit(ListP listPtr, int* allItems, int itemsInRun){ int j, currentBin, currentItem; ItemP item; rewind(fpBins); // ensure every algorithm starts with the same Bin fscanf(fpBins, "%d", ¤tBin); addBinToList(listPtr, currentBin); for (j = 0; j < itemsInRun; j++){ currentItem = allItems[j]; item = createItem(currentItem); FirstFit(listPtr, item); } }
//Grafo, tipo de GRASP, se o grafo está "incolor" void GRASP::doGrasp(int type, int avoidColor){ switch (type) { case 1: LDO(avoidColor); break; case 2: SDO(avoidColor); break; case 3: IDO(avoidColor); break; default: FirstFit(avoidColor); } }
void OfflineFirstFit(ListP listPtr, int *allItems, int itemsInRun){ int j, currentItem, currentBin; ItemP item; // sort allItems mergeSort(allItems, itemsInRun); // create items and pack rewind(fpBins); // ensure every algorithm starts with the same Bin fscanf(fpBins, "%d", ¤tBin); addBinToList(listPtr, currentBin); for (j = 0; j < itemsInRun; j++){ currentItem = allItems[j]; item = createItem(currentItem); FirstFit(listPtr, item); } return; }
int main() { char c ='4'; if(c=='1') { memset(memorystatus,'t',1000); printf("Hello world!\n"); printf("Memoria Vacia\n"); puts(memorystatus); void* ptra = (FirstFit(5)); //MiFree(ptra); void* ptrb = (FirstFit(10)); void* ptrc = (FirstFit(15)); printf("Memoria con memoria asignada\n"); puts(memorystatus); printf("Punteros\n"); int a = (unsigned) ptra; int b = (unsigned) ptrb; int c = (unsigned) ptrc; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); } if(c=='2') { memset(memorystatus,'t',1000); printf("Hello world!\n"); printf("Memoria Vacia\n"); puts(memorystatus); void* ptra = (NextFit(5)); MiFree(ptra); void* ptrb = (NextFit(3)); void* ptrc = (NextFit(15)); printf("Memoria con memoria asignada\n"); puts(memorystatus); printf("Punteros\n"); int a = (unsigned) ptra; int b = (unsigned) ptrb; int c = (unsigned) ptrc; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); } if(c=='3') { memset(memorystatus,'t',1000); printf("Hello world!\n"); printf("Memoria Vacia\n"); puts(memorystatus); void* ptra = (BestFit(5)); MiFree(ptra); void* ptrb = (BestFit(10)); void* ptrc = (BestFit(15)); printf("Memoria con memoria asignada\n"); puts(memorystatus); printf("Punteros\n"); int a = (unsigned) ptra; int b = (unsigned) ptrb; int c = (unsigned) ptrc; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); } if(c=='4') { memset(memorystatus,'t',1000); printf("Hello world!\n"); printf("Memoria Vacia\n"); puts(memorystatus); void* ptra = (WorstFit(10)); //MiFree(ptra); void* ptrb = (WorstFit(5)); // MiFree(ptrb); void* ptrc = (WorstFit(15)); printf("Memoria con memoria asignada\n"); puts(memorystatus); printf("Punteros\n"); int a = (unsigned) ptra; int b = (unsigned) ptrb; int c = (unsigned) ptrc; printf("%u\n",a); printf("%u\n",b); printf("%u\n",c); } return 0; }