/* GPU OpenGL disassembler tool */ void gl_disasm(char *path, int opengl_shader_index) { void *file_buffer; int file_size; struct amd_opengl_bin_t *amd_opengl_bin; struct amd_opengl_shader_t *amd_opengl_shader; /* Initialize disassembler */ amd_disasm_init(); /* Load file into memory buffer */ file_buffer = read_buffer(path, &file_size); if(!file_buffer) fatal("%s:Invalid file!", path); /* Analyze the file and initialize structure */ amd_opengl_bin = amd_opengl_bin_create(file_buffer, file_size, path); free_buffer(file_buffer); /* Basic info of the shader binary */ printf("This shader binary contains %d shaders\n\n", list_count(amd_opengl_bin->shader_list)); if (opengl_shader_index > list_count(amd_opengl_bin->shader_list) || opengl_shader_index <= 0 ) { fatal("Shader index out of range! Please choose <index> from 1 ~ %d", list_count(amd_opengl_bin->shader_list)); } /* Disaseemble */ amd_opengl_shader = list_get(amd_opengl_bin->shader_list, opengl_shader_index -1 ); printf("**\n** Disassembly for shader %d\n**\n\n", opengl_shader_index); amd_disasm_buffer(&amd_opengl_shader->isa_buffer, stdout); printf("\n\n\n"); /* Free */ amd_opengl_bin_free(amd_opengl_bin); amd_disasm_done(); /* End */ mhandle_done(); exit(0); }
t_list* particiones(t_memoria segmento) { /* Esta funcion devuelve una lista en el formato t_list de las commonslibrary con la siguiente descripcion por cada particion */ t_particion* particionAux; t_list* list_segmento, *list_auxiliar; int i, totalLista; list_auxiliar = list_create(); list_segmento = list_create(); totalLista = list_particiones->elements_count; for (i = (totalLista-1); i >= 0; i--) { particionAux = list_get(list_particiones, i); list_add(list_auxiliar, particionAux); } list_segmento = list_take(list_auxiliar, totalLista); totalLista = list_segmento->elements_count; // for (i = 0; i < totalLista; i++) { // particionAux = list_get(list_segmento, i); // if (particionAux->libre == true) { // printf("VACIO[%d:%d:%d]\n", particionAux->inicio, // (particionAux->inicio + particionAux->tamanio - 1), // particionAux->tamanio); // } else { // printf("%c[%d:%d:%d]:", particionAux->id, particionAux->inicio, // (particionAux->inicio + particionAux->tamanio - 1), // particionAux->tamanio); // for (n = particionAux->inicio; n < (particionAux->tamanio + particionAux->inicio); n++) { // printf("%c", segmento[n]); // } // printf("\n"); // } // } list_destroy(list_auxiliar); return list_segmento; }
/* * Remove a waitable object by signaling the waitable thread to terminate. */ DWORD scheduler_remove_waitable( HANDLE waitable ) { DWORD index = 0; DWORD count = 0; THREAD * thread = NULL; WaitableEntry * entry = NULL; DWORD result = ERROR_SUCCESS; dprintf( "[SCHEDULER] entering scheduler_remove_waitable( 0x%08X )", waitable ); if( schedulerThreadList == NULL || waitable == NULL ) return ERROR_INVALID_HANDLE; lock_acquire( schedulerThreadList->lock ); count = list_count( schedulerThreadList ); for( index=0 ; index < count ; index++ ) { thread = (THREAD *)list_get( schedulerThreadList, index ); if( thread == NULL ) continue; entry = (WaitableEntry *)thread->parameter1; if( entry == NULL ) continue; if( entry->waitable == waitable ) { dprintf( "[SCHEDULER] scheduler_remove_waitable: signaling waitable = 0x%08X, thread = 0x%08X", waitable, thread ); thread_sigterm( thread ); result = ERROR_SUCCESS; break; } } lock_release( schedulerThreadList->lock ); dprintf( "[SCHEDULER] leaving scheduler_remove_waitable" ); return result; }
int agregar_en_frame_libre(int page_to_add, t_proceso * proceso, int read_or_write) { t_mem_frame * frame_libre = NULL; int nro_frame = 0; for (nro_frame = 0; nro_frame < umc_config->cant_frames; nro_frame++) { frame_libre = list_get(frames_memoria, nro_frame); if (frame_libre->libre) break; } if (nro_frame >= umc_config->cant_frames) return -1; //SWAPPING swapping(page_to_add, -1, proceso->pid, 0, nro_frame); //-------- t_tabla_pagina * page = buscar_pagina(page_to_add, proceso->tabla_paginas); page->accessedbit = 1; page->frame = nro_frame; page->presentbit = 1; page->dirtybit = read_or_write; frame_libre->libre = false; frame_libre->pagina = page_to_add; frame_libre->pid = proceso->pid; if (tlb_on) { t_tlb * reemplazo_tlb = malloc(sizeof(t_tlb)); reemplazo_tlb->referencebit = 0; reemplazo_tlb->frame = nro_frame; reemplazo_tlb->pagina = page_to_add; reemplazo_tlb->pid = proceso->pid; run_LRU(reemplazo_tlb); } return nro_frame; }
void tv_cast(CastResult* result, caValue* value, Type* type, bool checkOnly) { if (!is_list(value)) { result->success = false; return; } int sourceLength = list_length(value); // If the requested type doesn't have a specific size restriction, then // the input data is fine as-is. if (!list_type_has_specific_size(&type->parameter)) { if (!checkOnly) value->value_type = type; return; } List& destTypes = *List::checkCast(list_get_type_list_from_type(type)); // Check for correct number of elements. if (sourceLength != destTypes.length()) { result->success = false; return; } if (!checkOnly) { INCREMENT_STAT(Touch_ListCast); list_touch(value); value->value_type = type; } for (int i=0; i < sourceLength; i++) { caValue* sourceElement = list_get(value, i); Type* expectedType = as_type(destTypes[i]); INCREMENT_STAT(Cast_ListCastElement); cast(result, sourceElement, expectedType, checkOnly); if (!result->success) return; } }
void printSegmentos(t_list * segmentos, char porDondeImprimo) { ordenarTablaSegmentos(); printSegmentosHeaders(porDondeImprimo); void imprimirSeparador(char porDondeImprimo){ if(porDondeImprimo == PorCONSOLA) printf("------------------|-----------------------|-----------------------|-----------------|\n"); else fprintf( archivoDump, "------------------|-----------------------|-----------------------|-----------------|\n"); } int i = 0; uint32_t cont = 0; for (i = 0; i < list_size(segmentos); i++) { Segmento * segmento = (Segmento *) list_get(segmentos, i); if (segmento->inicioReal != cont) { printEspacioLibre(cont, segmento->inicioReal - 1, porDondeImprimo); cont = segmento->finReal + 1; imprimirSeparador(porDondeImprimo); } else{ printSegmento(segmento, porDondeImprimo); cont = segmento->finReal + 1; } imprimirSeparador(porDondeImprimo); } if (cont < (memoria_size - 1)){ printEspacioLibre(cont, (memoria_size - 1), porDondeImprimo); if (porDondeImprimo == PorCONSOLA) printf( "------------------------------------------------------------------------------------|\n"); else fprintf( archivoDump, "------------------------------------------------------------------------------------|\n"); } }
CUresult cuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev) { cuda_debug_print(stdout, "CUDA driver API '%s'\n", __FUNCTION__); cuda_debug_print(stdout, "\t(driver) in: attrib = %d\n", attrib); cuda_debug_print(stdout, "\t(driver) in: dev = %d\n", dev); if (dev >= list_count(device_list)) { cuda_debug_print(stdout, "\t(driver) out: return = %d\n", CUDA_ERROR_INVALID_VALUE); return CUDA_ERROR_INVALID_VALUE; } /* Get attribute */ *pi = (((struct cuda_device_t *)list_get(device_list, dev))->attributes)[attrib]; cuda_debug_print(stdout, "\t(driver) out: attribute_value = %d", *pi); cuda_debug_print(stdout, "\t(driver) out: return = %d\n", CUDA_SUCCESS); return CUDA_SUCCESS; }
ITEM_NIVEL * buscarRecursoEnLista(t_list * lista, char * simbolo){//BUSCA SI HAY UN RECURSO PEDIDO Y LO DEVUELVE ITEM_NIVEL * item; ITEM_NIVEL * unItem; bool encontrado = false; int i=0; while(i < list_size(lista) && !encontrado){ unItem=list_get(lista,i); if(unItem->item_type==RECURSO_ITEM_TYPE) if(unItem->id==simbolo[0]){ encontrado=true; item=unItem; } i++; } return item; }
void* buscarYEliminarPCBEnLista(t_list * lista, pcb* pcbLoco) { int i; pcb * pcbComparar; for (i = 0; i < list_size(lista); i++) { pcbComparar = ((pcb*) list_get(lista, i)); if ((pcbComparar->id) == (pcbLoco->id)) { return list_remove(lista, i); } } return NULL; }
void wap_map_destroy(void) { long i; struct url_map_struct *entry; if (url_map != NULL) { for (i = 0; i < list_len(url_map); i++) { entry = list_get(url_map, i); octstr_destroy(entry->name); octstr_destroy(entry->url); octstr_destroy(entry->map_url); octstr_destroy(entry->send_msisdn_query); octstr_destroy(entry->send_msisdn_header); octstr_destroy(entry->send_msisdn_format); gw_free(entry); } list_destroy(url_map, NULL); } url_map = NULL; }
CIRCA_EXPORT int circa_file_get_version(caWorld* world, const char* filename) { Value name; set_string(&name, filename); const char* builtinFile = find_builtin_file(filename); if (builtinFile != NULL) return 0; Value* fileSources = &world->fileSources; for (int i=list_length(fileSources) - 1; i >= 0; i--) { Value* file_source = list_get(fileSources, i); if (!file_source_does_file_exist(file_source, &name)) continue; return file_source_get_file_version(file_source, &name); } return 0; }
uint32_t algoritmo_lru(uint16_t * id_pagina_a_swappear){ // filtro segun paginas que tienen marco bool _paginas_con_marco(pagina_t* pagina){ return pagina->tiene_marco; } //lock_lista_indice_paginas(); t_list* paginas_con_marco = list_filter(get_indice_paginas(),(void*) _paginas_con_marco); //unlock_lista_indice_paginas(); // saco el ultimo elemento (el menos usado recientemente) pagina_t* pag = list_get(paginas_con_marco,list_size(paginas_con_marco)-1); uint32_t resultado = pag->marco; *id_pagina_a_swappear=pag->id; free(paginas_con_marco); return resultado; }
void task_kill(int pid) { if(!pid) return; /* Do not let the main task kill itself */ if(!irq_already_off) IRQ_OFF(); kprintf("\nKILLED PID: %d\n", pid); /* Remove the task from the list, then cleanup the rest (remove process from tree, deallocate task's stack and more) */ task_t * task_to_kill = (task_t*)list_get(tasklist, pid)->value; /* Store it first so we can clean up everything */ list_remove(tasklist, pid); tasklist_size--; /* Remove from tree: */ /* Cleanup everything else: */ task_free(task_to_kill); irq_already_off = 0; IRQ_RES(); /* Resume switching */ }
void destruir_archivos_swapp_proceso(uint32_t pid, segmento_t* segmento) { int i; char* nombre_archivo; for(i=0;i<list_size(segmento->paginas);i++) { pagina_t* pagina=list_get(segmento->paginas,i); if(pagina->en_disco) { nombre_archivo=generar_nombre_archivo_swap(pid, segmento->id, pagina->id); char* path; path=concat_string("en_disco/",nombre_archivo); path=concat_string(path,".txt"); free(nombre_archivo); remove(path); free(path); } } }
int system_del_prog(system_t * sys, prog_t * prog) { for (int i = 0; i < list_size(sys->inst_prog); i++) if (list_get(sys->inst_prog, i) == prog) { list_del(sys->inst_prog, i); if (i < sys->cur_prog) sys->cur_prog--; sys->memory += prog->memory; if (sys->cur_prog == i) { sys->op_mem += prog->memory; sys->cur_prog = -1; } return 1; } return 0; }
void si_opencl_kernel_free(struct si_opencl_kernel_t *kernel) { int i; /* Free arguments */ for (i = 0; i < list_count(kernel->arg_list); i++) si_opencl_kernel_arg_free((struct si_opencl_kernel_arg_t *) list_get(kernel->arg_list, i)); list_free(kernel->arg_list); /* AMD Binary (internal ELF) */ if (kernel->bin_file) si_bin_file_free(kernel->bin_file); /* Free lists */ list_free(kernel->constant_buffer_list); /* Free kernel */ si_opencl_repo_remove_object(si_emu->opencl_repo, kernel); free(kernel); }
tipoRespuesta* responderEscribir(tipoInstruccion* instruccionRecibida,t_list* listaPaginas){ paginaNegra* nuevaPag = malloc(sizeof(paginaNegra)); nuevaPag->nroPagina = instruccionRecibida->nroPagina; nuevaPag->pid = instruccionRecibida->pid; nuevaPag->contenido = string_duplicate(instruccionRecibida->texto); list_add(listaPaginas,nuevaPag); printf("La pagina guardad contiene: %s\n",nuevaPag->contenido); paginaNegra* pagTestear = list_get(listaPaginas,0); printf("Pagina %d de proceso %d con contenido: %s\n",pagTestear->nroPagina,pagTestear->pid,pagTestear->contenido); return crearTipoRespuesta(PERFECTO,"Pagina guardada en swap"); }
void shares_dump() { int i; Share* s; List* l; if (shareList == NULL) return; pthread_mutex_lock(&shareMutex); l = shareList->list; logInfo("Shares dump"); for (i = 0 ; i < l->size; i++) { s = (Share*)list_get(l, i); logInfo("\t %s: quota:%lli", s->name, s->quota); } pthread_mutex_unlock(&shareMutex); }
client_t *client_find_client_by_sock(list_t *clients,int sock) { client_t *c ; tmp_client.session_id = -1; tmp_client.sock_id = sock; if(g_debug) { int i = list_get_index(clients,&tmp_client); printf("get Client index %d\n",i); if(i == -1) return NULL; c = (client_t *)(clients->obj_arr[i]); }else { c = (client_t *)list_get(clients,&tmp_client); } return c; }
bool buscarPCB(t_list * lista, pcb* pcbLoco) { int i; pcb * pcbComparar; for (i = 0; i < list_size(lista); i++) { pcbComparar = ((pcb*) list_get(lista, i)); if ((pcbComparar->id) == (pcbLoco->id)) { return TRUE; } } return FALSE; }
int main(){ t_plan_nivel *plan_nivel; t_personaje *pj = cargar_personaje(PATH); int i=0; printf("Nombre: %s \n", pj->nombre); printf("Símbolo: %c \n", pj->simbolo); printf("Vidas: %d \n", pj->vidas); printf("IP orquestador: %s \n", pj->orquestador); while( i < (pj->lista_niveles->elements_count)){ plan_nivel = list_get(pj->lista_niveles, i); printf("Nombre Niv: %s - ", plan_nivel->nivel); printf("Objetivos: %s \n", plan_nivel->objetivos); i++; } return 0; }
t_nodo *seleccionarNodoMenosCargado(t_list *listaNodosConectados, int posicion) { t_nodo *nodoDevolver; reservarListaNodosConectados(); list_sort(listaNodosConectados,compararCantidadBloquesNodo); devolverListaNodosConectados(); t_list *listaAux = removerNodosDesahabilitadosYSinEspacio(listaNodosConectados); if(posicion > 0 && posicion <= list_size(listaAux)) { nodoDevolver = (t_nodo*)list_get(listaAux,(list_size(listaAux) - posicion)); list_destroy(listaAux); return nodoDevolver; } else { list_destroy(listaAux); return NULL; } }
void arm_file_desc_table_free(struct arm_file_desc_table_t *table) { int i; struct arm_file_desc_t *desc; /* Check no more links */ assert(!table->num_links); /* Free arm_file descriptors */ for (i = 0; i < list_count(table->arm_file_desc_list); i++) { desc = list_get(table->arm_file_desc_list, i); if (desc) arm_file_desc_free(desc); } /* Free list and table */ list_free(table->arm_file_desc_list); free(table); }
struct net_bus_t *net_bus_arbitration(struct net_node_t *bus_node, struct net_buffer_t *buffer) { int i; struct net_bus_t *check_bus; /* checks */ assert(buffer->bus); assert(!buffer->link); assert(bus_node->kind == net_node_bus); for (i = 0; i < list_count(bus_node->bus_lane_list); i++) { check_bus = list_get(bus_node->bus_lane_list, i); if (net_bus_arbiteration_per_lane(bus_node, check_bus) == buffer) return check_bus; } return NULL; }
static struct slab * kmem_get_slab(kmem_cache_t *cachep) { if(cachep == NULL) { return NULL; } struct slab *slabp = NULL; struct kmem_list *lists = NULL; struct list_head *head = NULL, *item = NULL, *pos = NULL; lists = &(cachep->kmem_lists); /* first find the partial slab*/ head = &(lists->partial); if(list_empty_careful(head)) { head = &(lists->free); if(list_empty_careful(head)) { return NULL; } else { if(list_get_del(head, &item) != 0) { return NULL; } list_add(item, &(cachep->kmem_lists.partial)); } } head = &(lists->partial); if(list_get(head, &pos) != 0) { return NULL; } slabp = list_entry(pos, struct slab, list); return slabp; }
CIRCA_EXPORT caWorld* circa_initialize() { memset(&FUNCS, 0, sizeof(FUNCS)); memset(&TYPES, 0, sizeof(TYPES)); bootstrap_kernel(); caWorld* world = global_world(); Block* kernel = global_root_block(); // Make sure there are no static errors in the kernel. This shouldn't happen. if (has_static_errors(kernel)) { std::cout << "Static errors found in kernel:" << std::endl; print_static_errors_formatted(kernel, std::cout); internal_error("circa fatal: static errors found in kernel"); } // Load library paths from CIRCA_LIB_PATH const char* libPathEnv = getenv("CIRCA_LIB_PATH"); if (libPathEnv != NULL) { Value libPathStr; set_string(&libPathStr, libPathEnv); Value libPaths; string_split(&libPathStr, ';', &libPaths); for (int i=0; i < list_length(&libPaths); i++) { caValue* path = list_get(&libPaths, i); if (string_eq(path, "")) continue; module_add_search_path(world, as_cstring(path)); } } log_msg(0, "finished circa_initialize"); world->bootstrapStatus = sym_Done; return world; }
void silverstack_asignar(t_puntero dir_var, t_valor_variable valor) { // 1) Mando a la UMV el valor de la variable junto con su direccion // 2) Actualizo diccionario de variables int buffer; t_mensaje msg_aux; msg_envio_bytes.base = pcb.stack_segment; msg_envio_bytes.offset = (pcb.stack_pointer - pcb.stack_segment) + dir_var - pcb.stack_pointer + 1; msg_envio_bytes.tamanio = 4; mensaje.tipo = ENVIOBYTES; msg_cambio_proceso_activo.id_programa = pcb.unique_id; send(sockUmv, &mensaje, sizeof(t_mensaje), 0); send(sockUmv, &msg_cambio_proceso_activo, sizeof(t_msg_cambio_proceso_activo), 0); send(sockUmv, &msg_envio_bytes, sizeof(t_msg_envio_bytes), 0); buffer = valor; send(sockUmv, &buffer, sizeof(buffer), 0); if (recv(sockUmv, &mensaje, sizeof(t_mensaje), 0) == 0) { log_error(logger, "UMV desconectada."); depuracion(SIGINT); } if (mensaje.tipo == ENVIOBYTES) { int i = 0; for (i = 0; i < list_size(variables); i++) { nueva_var = list_get(variables, i); if (nueva_var->dir == (int)dir_var) { break; } } nueva_var->valor = valor; } else { msg_aux.tipo = mensaje.tipo; send(sockKernel, &msg_aux, sizeof(t_mensaje), 0); proceso_finalizo = 1; } }
void jobConCombiner1Archivo1BloqueYConMapEjecutado_pedirSiguienteTarea_devuelveTareaReduce() { t_job *job = newJob(CON_COMBINER); jobAgregarArchivoMDFS(job,"/holy.txt",1); t_tarea *tarea1 = jobObtenerSiguienteTarea(job); tareaMarcarEnEjecucion(tarea1, newNodo("nodo1", "192.168.1.101", "5001"),"archivo1"); tareaMarcarFinalizada(tarea1); t_tarea *tarea2 = jobObtenerSiguienteTarea(job); CU_ASSERT_TRUE(tareaEsReduce(tarea2)); t_list *archivosRemotos = tareaReduceObtenerArchivosRemotos(tarea2); t_archivoRemoto *archivo = list_get(archivosRemotos,0); CU_ASSERT_EQUAL(list_size(archivosRemotos),1); CU_ASSERT_STRING_EQUAL(archivoRemotoObtenerNodo(archivo)->nombre,"nodo1"); CU_ASSERT_STRING_EQUAL(archivoRemotoObtenerNombreArchivo(archivo),"archivo1"); }
/* Given a buffer and buffer size, create list that contains offsets of external ELF magic bytes in the buffer */ static struct list_t *external_elf_file_list_create(void *ptr_buffer, size_t buf_size) { struct list_t *elf_file_list_external; int i; int elf_file_size; int *offset; elf_file_list_external = elf_file_list_create(ptr_buffer, buf_size); /* Remove internal ELF from list */ for (i = 0; i < list_count(elf_file_list_external); i++) { offset = list_get(elf_file_list_external, i); elf_file_size = buf_size - *offset; if (is_external_elf(ptr_buffer + *offset, elf_file_size) != 0) free(list_remove_at(elf_file_list_external, i)); } return elf_file_list_external; }
// Pack a state value. Each input will correspond with a slot in the branch's state type. void pack_state(caStack* stack) { Term* caller = (Term*) circa_caller_term(stack); Branch* branch = caller->owningBranch; if (branch->stateType == NULL) return; caValue* args = circa_input(stack, 0); caValue* output = circa_output(stack, 0); create(branch->stateType, output); for (int i=0; i < circa_count(args); i++) { caValue* input = circa_index(args, i); caValue* dest = list_get(output, i); if (input == NULL) set_null(dest); else copy(input, dest); } }