Exemplo n.º 1
0
void sensors_cleanup(void)
{
	int i;

	for (i = 0; i < sensors_proc_chips_count; i++) {
		free_chip_name(&sensors_proc_chips[i].chip);
		free_chip_features(&sensors_proc_chips[i]);
	}
	free(sensors_proc_chips);
	sensors_proc_chips = NULL;
	sensors_proc_chips_count = sensors_proc_chips_max = 0;

	for (i = 0; i < sensors_config_chips_count; i++)
		free_chip(&sensors_config_chips[i]);
	free(sensors_config_chips);
	sensors_config_chips = NULL;
	sensors_config_chips_count = sensors_config_chips_max = 0;
	sensors_config_chips_subst = 0;

	for (i = 0; i < sensors_proc_bus_count; i++)
		free_bus(&sensors_proc_bus[i]);
	free(sensors_proc_bus);
	sensors_proc_bus = NULL;
	sensors_proc_bus_count = sensors_proc_bus_max = 0;

	for (i = 0; i < sensors_config_files_count; i++)
		free(sensors_config_files[i]);
	free(sensors_config_files);
	sensors_config_files = NULL;
	sensors_config_files_count = sensors_config_files_max = 0;
}
Exemplo n.º 2
0
static void free_config_busses(void)
{
	int i;

	for (i = 0; i < sensors_config_busses_count; i++)
		free_bus(&sensors_config_busses[i]);
	free(sensors_config_busses);
	sensors_config_busses = NULL;
	sensors_config_busses_count = sensors_config_busses_max = 0;
}
Exemplo n.º 3
0
void scene_menu(){
	printf("\n\tTBS - Terminal Bojio Sentiasa\n");
	printf("\n\t1. Register arrived bus\n");
	printf("\t2. Bus leave\n");
	printf("\t3. View Queue\n");
	printf("\t4. Search Bus\n");
	printf("\t5. Exit\n");
	printf("\n\tChoice: ");
	if (!getint(&number)){
		msg("Invalid Action!");
		return;
	}
	switch (number){
	case 1:
		temp = new_bus();
		if(temp)scene = &scene_arrive;
		else msg("Sorry, error occurs when allocating memory,\n\tPlease try again later!")
		return;
	case 2:
		if (!busses.first){
			msg("Sorry, The Queue is Empty!");
			return;
		}
		printf("\n\tBus %s leaved the queue.\n\n\t", busses.first->num);
		busptr tempFirst = busses.first->next;
		if (busses.last == busses.first) busses.last = NULL;
		free_bus(busses.first);
		busses.first = tempFirst;
		pause();
		return;
	case 3:
		clear();
		scene_list();
		return;
	case 4:
		scene_search();
		return;
	case 5:
		scene = NULL;
		return;
	default:
		msg("Invalid Action!");
		return;
	}
}
Exemplo n.º 4
0
/*! Deallocates the processor struct and all of its internal components. */
void free_processor(Processor *proc) {
    // Destroy the components
    free_program_counter(proc->pc);
    free_instruction_store(proc->is);
    free_decode(proc->decode);
    free_register_file(proc->rf);
    free_alu(proc->alu);
    free_branch_unit(proc->bru);

    // Destroy each bus
    free_bus(proc->pc_bus);
    free_bus(proc->instr);
    free_bus(proc->aluop);
    free_bus(proc->writep);
    free_bus(proc->src1);
    free_bus(proc->src2);
    free_bus(proc->dst);
    free_bus(proc->rf1);
    free_bus(proc->rf2);
    free_bus(proc->aluout);
    free_bus(proc->branch_addr);
    free_bus(proc->branch);

    // Get rid of the actual Processor struct.
    free(proc);
}