Advertisement
xangelux

Maquina virtual: 1 lib/util.h

Apr 3rd, 2011
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.87 KB | None | 0 0
  1. #ifndef _UTIL_H_
  2. #define _UTIL_H_
  3.  
  4. /*
  5.  * Detecta Teclazos
  6.  */
  7.  
  8. int kbhit( void );
  9.  
  10. /*
  11.  * Compara el comando verificando los implementados
  12.  */
  13.  
  14. int compc( char [] );
  15. int compaux( char [] );
  16.  
  17. /*
  18.  * Va armando el comando
  19.  */
  20.  
  21. int com(char *, char, int, char *, int *);
  22.  
  23. /*
  24.  * Definiciones
  25.  */
  26.  
  27. typedef struct proceso PROCESO;
  28. typedef struct lista LISTA;
  29.  
  30. /*
  31.  * Constructor de lista
  32.  */
  33.  
  34. int inicial( LISTA * );
  35.  
  36. /*
  37.  * Inserta un nodo al final de la lista
  38.  */
  39.  
  40. void ins_list(PROCESO *,LISTA *);
  41.  
  42. /*
  43.  * Eliminar un nodo de la lista
  44.  */
  45.  
  46. int elim_list(int, LISTA *, LISTA *, LISTA *, LISTA *, LISTA *);
  47.  
  48. /*
  49.  * Identifica y mata el proceso
  50.  */
  51.  
  52. int mata(int, LISTA *, LISTA *, LISTA *, LISTA *, LISTA *, int, int **, char **, int *, int *);
  53.  
  54. /*
  55.  * Levanta los procesos
  56.  */
  57.  
  58. PROCESO *levanta_proceso(char *, int *, int, int *);
  59.  
  60. /*
  61.  * Levanta procesos hijo
  62.  */
  63.  
  64. PROCESO *levanta_hijo(char *,int *, int, LISTA *, LISTA *, int *, LISTA *, LISTA * );
  65.  
  66. /*
  67.  * Divide argumentos del comando fork
  68.  */
  69.  
  70. void div_fork(char *,int *,int *);
  71.  
  72. /*
  73.  * Busca el proceso padre para levanta hijo
  74.  */
  75.  
  76. PROCESO *busca_padre(int ,LISTA *);
  77.  
  78. /*
  79.  * Planificadores
  80.  */
  81.  
  82. int planifica( LISTA *, LISTA *, LISTA *,unsigned long long *, unsigned long long *, unsigned long long *, unsigned long long *, int, float);
  83.  
  84. /*
  85.  * Ejecuta el siguiente ciclo de timer
  86.  */
  87.  
  88. int ejecuta( unsigned long long *AX, unsigned long long *BX, unsigned long long *CX, unsigned long long *DX, LISTA *, int, LISTA *, float, int, char **, int **, LISTA *, LISTA *, int, int *, int *);
  89.  
  90. /*
  91.  * Actualiza la variable grupo de los procesos hermanos e hijos
  92.  */
  93.  
  94. void grupo( PROCESO * );
  95.  
  96. /*
  97.  * Función para imprimir el monitor de procesos
  98.  */
  99.  
  100. int imprime(LISTA *, LISTA *, LISTA*, LISTA *, LISTA *, LISTA*);
  101.  
  102. /*
  103.  * Función para imprimir la RAM
  104.  */
  105.  
  106. void ram_print( char** );
  107. /*
  108.  * Función para imprimir la RAM
  109.  */
  110.  
  111. void tmm_print( int ** );
  112.  
  113. void tmp_print( LISTA * );
  114.  
  115. /*
  116.  * Función que verifica si existen marcos libres en la RAM basado en la tmm
  117.  */
  118.  
  119. int free_frame( int ** );
  120.  
  121. /*
  122.  * Función para leer la instrucción indicada
  123.  */
  124.  
  125. char *lee_ins( FILE *, int );
  126.  
  127. /*
  128.  * Función que saca un proceso del frente de la lista origen y lo pone al final de la lista destino
  129.  */
  130. int swap( LISTA *, LISTA * );
  131.  
  132. /*
  133.  * Función para traducir direcciones virtuales a físicas
  134.  */
  135.  
  136. int traduce( int, int);
  137.  
  138. /*
  139.  *  Libera la memoria RAM usada de un proceso
  140.  */
  141.  
  142. void libera( PROCESO *, int **, char **);
  143.  
  144. /*
  145.  * Checar si el proceso mandado tiene sus 3 frames ocupados o no
  146.  */
  147.  
  148. int lleno( PROCESO *, int * );
  149.  
  150. /*
  151.  * Intercambia marcos, uno nuevo por el más viejo del mismo proceso
  152.  */
  153.  
  154. int switch_frame( PROCESO *, int**, char**, int*, int );
  155.  
  156. /*
  157.  * Saca una página vieja de un proceso y mete una nueva de otro
  158.  */
  159.  
  160. int switch_other( PROCESO *, int **, char ** );
  161.  
  162. /*
  163.  * Esta es una operación con registros pero usa definiciones de util.h
  164.  */
  165. int get( int *, int *, char *, char *, char *, char *, LISTA *, LISTA *);
  166.  
  167. /*
  168.  * Función para verificar marcados en banquero
  169.  */
  170.  
  171. int suma_marc_pend( int *, int *, int);
  172.  
  173. /*
  174.  * Buscar marcados
  175.  */
  176.  
  177. int marcado( int, int *, int);
  178.  
  179. /*
  180.  * Finje un uso de recursos
  181.  */
  182.  
  183. int use( PROCESO *, char *, char *, char *, char *);
  184.  
  185. /*
  186.  * Decrementar random de bloqueados y sacar si es necesario
  187.  */
  188.  
  189. void bloqueadoschk( LISTA *, LISTA *);
  190.  
  191. /*
  192.  * Función para liberar recursos utilizados
  193.  */
  194.  
  195. int fre( PROCESO *, char *, char *, char *, char *, int *);
  196.  
  197. /*
  198.  * Estructuras
  199.  */
  200. struct proceso{
  201.     int fp, lineas, pid, PC, ppid, proceso, grupo, **tmp, fork, *recs, *recAs, bloqueo;
  202.     float prioridad;   
  203.     unsigned long long AX,BX,CX,DX;
  204.     char *nombre;
  205.     FILE *instrucciones;
  206.     PROCESO *siguiente, *hermano;
  207.     LISTA   *hijos;
  208. };
  209.  
  210. struct lista{
  211.     int num;
  212.     PROCESO *inicio,*fin;
  213. };
  214.  
  215. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement