//testeada
void entrada_salida(char * identificador, int cantidad, pcb *pcbPrograma) {

	int i;
	int j;
	int abortar = 0;
	int retardoPeriferico;
	int totalRetardo;
	for (i = 0; i< (*cantidadDispositivosIO); i++) {

		if ((strcmp(idIO[i], identificador)) == 0) {
			j = i;

			//retardoPeriferico = (int) retardoIO[i];

			retardoPeriferico = atoi(retardoIO[i]);
			abortar++;
		}

	}

	if (abortar == 0) {
		//ACA PARA MATAR todo

	}
	totalRetardo = retardoPeriferico * cantidad * 1000;
	//usleep(totalRetardo*1000);

	moverAListaBlock(pcbPrograma);
	if (pthread_mutex_lock(mutexIO[j]) == 0) {
		ejecutarIO(j, pcbPrograma, totalRetardo);

	}

}
예제 #2
0
int resultadoExpresion(char* expresion,imagen_proceso_t proceso)
{
	if(esUnaEntradaSalida(expresion))
		return ejecutarIO(expresion);
	int i = 0;
	while(expresion[i] != '#' && expresion[i] != '\n' && expresion[i] != ';' && expresion[i] != '+' && expresion[i] != '-')
		i++;
	if(expresion[i] == '+' || expresion[i] == '-')
	{
		int j=i;
		while(expresion[j] != '#' && expresion[j] != '\n' && expresion[j] != ';')
			j++;
		return obtenerResultado(expresion,i,j+1,proceso);
	}
	return obtenerOperando(expresion,0,i,proceso);
}
예제 #3
0
int parsear(char* linea, imagen_proceso_t* proceso)
{
	if(especificaTiempo(linea))
		printf("Especifica tiempo;");
		//sleep(tiempo);
	int tipoDeLinea = determinarTipoDeLinea(linea);
	switch (tipoDeLinea)
	{
		case LINEA_VACIA:
			return NOSALTO;
			break;
		case INTERPRETE:
			return NOSALTO;
			break;
		case COMENTARIO:
			return NOSALTO;
			break;
		case DECLARACION_DE_VARIABLES:
			return NOSALTO;
			break;
		case COMIENZO_PROGRAMA:
			return NOSALTO;
			break;
		case FIN_PROGRAMA:
			proceso->PCB_proceso.ProgramCounter = FIN;
			return FIN;
			break;
		case COMIENZO_FUNCION:
			puts("Una funcion empieza");
			break;
		case FIN_FUNCION:
			//nodoStack_t* retorno = sacarLlamada(proceso);
			//proceso->PCB_proceso->ProgramCounter = retorno->numeroDeLinea;
			puts("Una funcion finaliza");
			return SALTO;
			break;
		case IMPRIMIR:
			imprimir(linea,*proceso);
			return NOSALTO;
			break;
		case SALTAR_NO_CERO:
			return saltar(linea,proceso,DISTINTO);
			break;
		case SALTAR_SI_CERO:
			return saltar(linea,proceso,IGUAL);
			break;
		case ETIQUETA:
			return NOSALTO;
			break;
		case ASIGNACION:
			puts("Asignacion");
			asignarVariable(linea,*proceso);
			return NOSALTO;
			break;
		case IO_FUNCION:
			puts("I/O");
			ejecutarIO(linea);
			return NOSALTO;//TODO por ahora despues vemos
			break;
		case FUNCION:
			irAFuncion(linea,proceso);
			return SALTO;
		case OTRO:
			puts("Error");
			return ERROR;
			break;
	}
	return 0;
}