Del curso Sistema Operativos Avanzados, de la MaestrΓa de Ciencias de la ComputaciΓ³n del TecnolΓ³gico de Costa Rica.
- Carvajal Barboza Nicole
- GonzΓ‘lez Villanueva Ruben
- LΓ³pez DΓaz Edisson
- Mena Kikut Otto
- Soto Rojas Cristina
Se utiliza el compilador de GNU, el GCC, usando la siguiente lΓnea:
gcc main.c -o main -lpthread -lm -w
- main.c: Nombre del archivo principal.
- -o: Indica el nombre del archivo de salida.
- main: Nombre del archivo de salida.
- -lpthread: Indica que se usarΓ‘n pthreads.
- -lm: Indica que se usarΓ‘ math.
- -w: Indica que no imprima warnings.
Se usa el archivo de salida resultante de la compilaciΓ³n "main". Para ejecutarlo es suficiente con la siguiente lΓnea:
./main
Sin embargo Γ©sto ejecutarΓ‘ el programa con variables estΓ‘ndares que hemos definido, para indicar cuΓ‘ntos carros vienen del Γ©ste y del oeste se usan los parΓ‘metros, con la siguiente lΓnea:
./main 4 5
Donde el primero, el 4, indica la cantidad de carros que quieren ingresar desde el este/derecha, y el segundo, el 5, la cantidad de carros que quieren ingresar desde el oeste/izquierda.
Se incluyeron dos parΓ‘metros extra que son opcionales para indicar el lambda que se usarΓ‘ para la funciΓ³n exponencial para cada direcciΓ³n, este/derecha y oeste/izquierda. Se hace uso de la siguiente manera:
./main 4 5 6 7
Donde el tercero, el 6, indica el lambda el este/derecha, y el cuarto, el 7, el lambda para el oeste/izquierda.
Actualmente todo funciona en el programa y se programΓ³ tal como se solicitΓ³ en el enunciado.
A continuaciΓ³n dos ejecuciones del programa, mostrando el comando de ejecuciΓ³n y las lΓneas impresas en consola del resultado.
EjecuciΓ³n:
./main 3 3 15 15
Resultado:
Parameters set at: East cars: 3, West cars: 3, East lambda: 15, West lambda: 15
Before Thread
===================Left Times ==============
Time = 2.612782
Time = 4.853285
Time = 8.171958
===================Right Times ==============
Time = 17.620624
Time = 35.221855
Time = 62.820526
===================Total Times and Direction ==============
Time = 2.612782 Direction = -1
Time = 4.853285 Direction = -1
Time = 8.171958 Direction = -1
Time = 17.620624 Direction = 1
Time = 35.221855 Direction = 1
Time = 62.820526 Direction = 1
** BEGIN PROCESS TO PASS THE BRIDGE **
-655395072 (Left β¬
οΈ) Arrived a new car! ππ¨
-655395072 (Left β¬
οΈ) I'm the fist, I allow the Left β¬
οΈ direction π’ π’
-655395072 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-663787776 (Left β¬
οΈ) Arrived a new car! ππ¨
-663787776 (Left β¬
οΈ) It's my same direction π’
-663787776 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-655395072 (Left β¬
οΈ) I passed the bridge π’
-672180480 (Left β¬
οΈ) Arrived a new car! ππ¨
-672180480 (Left β¬
οΈ) It's my same direction π’
-672180480 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-663787776 (Left β¬
οΈ) I passed the bridge π’
-672180480 (Left β¬
οΈ) I passed the bridge π’
-672180480 (Left β¬
οΈ) I was the last, the bridge is empty π‘
-680573184 (Right β‘οΈ) Arrived a new car! ππ¨
-680573184 (Right β‘οΈ) I'm the fist, I allow the Right β‘οΈ direction π’ π’
-680573184 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-680573184 (Right β‘οΈ) I passed the bridge π’
-680573184 (Right β‘οΈ) I was the last, the bridge is empty π‘
-688965888 (Right β‘οΈ) Arrived a new car! ππ¨
-688965888 (Right β‘οΈ) I'm the fist, I allow the Right β‘οΈ direction π’ π’
-688965888 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-688965888 (Right β‘οΈ) I passed the bridge π’
-688965888 (Right β‘οΈ) I was the last, the bridge is empty π‘
-697358592 (Right β‘οΈ) Arrived a new car! ππ¨
-697358592 (Right β‘οΈ) I'm the fist, I allow the Right β‘οΈ direction π’ π’
-697358592 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-697358592 (Right β‘οΈ) I passed the bridge π’
-697358592 (Right β‘οΈ) I was the last, the bridge is empty π‘
EjecuciΓ³n:
./main 7 6 2 3
Resultado:
Parameters set at: East cars: 7, West cars: 6, East lambda: 2, West lambda: 3
Before Thread
===================Left Times ==============
Time = 3.156758
Time = 6.247203
Time = 9.495758
Time = 9.543585
Time = 17.531501
Time = 25.652481
===================Right Times ==============
Time = 3.773602
Time = 7.449789
Time = 10.267353
Time = 13.422997
Time = 15.114030
Time = 19.688628
Time = 19.851628
===================Total Times and Direction ==============
Time = 3.156758 Direction = -1
Time = 3.773602 Direction = 1
Time = 6.247203 Direction = -1
Time = 7.449789 Direction = 1
Time = 9.495758 Direction = -1
Time = 9.543585 Direction = -1
Time = 10.267353 Direction = 1
Time = 13.422997 Direction = 1
Time = 15.114030 Direction = 1
Time = 17.531501 Direction = -1
Time = 19.688628 Direction = 1
Time = 19.851628 Direction = 1
Time = 25.652481 Direction = -1
** BEGIN PROCESS TO PASS THE BRIDGE **
-993585408 (Left β¬
οΈ) Arrived a new car! ππ¨
-993585408 (Left β¬
οΈ) I'm the fist, I allow the Left β¬
οΈ direction π’ π’
-993585408 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1001978112 (Right β‘οΈ) Arrived a new car! ππ¨
-1001978112 (Right β‘οΈ) I'll wait because bridge is in use π΄
-1010370816 (Left β¬
οΈ) Arrived a new car! ππ¨
-1010370816 (Left β¬
οΈ) It's my same direction π’
-1010370816 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1018763520 (Right β‘οΈ) Arrived a new car! ππ¨
-1018763520 (Right β‘οΈ) I'll wait because bridge is in use π΄
-993585408 (Left β¬
οΈ) I passed the bridge π’
-1027156224 (Left β¬
οΈ) Arrived a new car! ππ¨
-1027156224 (Left β¬
οΈ) It's my same direction π’
-1027156224 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1035548928 (Left β¬
οΈ) Arrived a new car! ππ¨
-1035548928 (Left β¬
οΈ) It's my same direction π’
-1035548928 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1043941632 (Right β‘οΈ) Arrived a new car! ππ¨
-1043941632 (Right β‘οΈ) I'll wait because bridge is in use π΄
-1010370816 (Left β¬
οΈ) I passed the bridge π’
-1052334336 (Right β‘οΈ) Arrived a new car! ππ¨
-1052334336 (Right β‘οΈ) I'll wait because bridge is in use π΄
-1060727040 (Right β‘οΈ) Arrived a new car! ππ¨
-1060727040 (Right β‘οΈ) I'll wait because bridge is in use π΄
-1027156224 (Left β¬
οΈ) I passed the bridge π’
-1035548928 (Left β¬
οΈ) I passed the bridge π’
-1035548928 (Left β¬
οΈ) I was the last, the bridge is empty π‘
-1001978112 (Right β‘οΈ) Now is my turn, I'll prepare to pass π‘
-1001978112 (Right β‘οΈ) I'm the fist, I allow the Right β‘οΈ direction π’ π’
-1001978112 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1018763520 (Right β‘οΈ) Now is my turn, I'll prepare to pass π‘
-1018763520 (Right β‘οΈ) It's my same direction π’
-1043941632 (Right β‘οΈ) Now is my turn, I'll prepare to pass π‘
-1060727040 (Right β‘οΈ) Now is my turn, I'll prepare to pass π‘
-1060727040 (Right β‘οΈ) It's my same direction π’
-1018763520 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1052334336 (Right β‘οΈ) Now is my turn, I'll prepare to pass π‘
-1052334336 (Right β‘οΈ) It's my same direction π’
-1052334336 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1060727040 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1043941632 (Right β‘οΈ) It's my same direction π’
-1043941632 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1069119744 (Left β¬
οΈ) Arrived a new car! ππ¨
-1069119744 (Left β¬
οΈ) I'll wait because bridge is in use π΄
-1077512448 (Right β‘οΈ) Arrived a new car! ππ¨
-1077512448 (Right β‘οΈ) It's my same direction π’
-1077512448 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1085905152 (Right β‘οΈ) Arrived a new car! ππ¨
-1085905152 (Right β‘οΈ) It's my same direction π’
-1085905152 (Right β‘οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1001978112 (Right β‘οΈ) I passed the bridge π’
-1018763520 (Right β‘οΈ) I passed the bridge π’
-1052334336 (Right β‘οΈ) I passed the bridge π’
-1060727040 (Right β‘οΈ) I passed the bridge π’
-1043941632 (Right β‘οΈ) I passed the bridge π’
-1077512448 (Right β‘οΈ) I passed the bridge π’
-1085905152 (Right β‘οΈ) I passed the bridge π’
-1085905152 (Right β‘οΈ) I was the last, the bridge is empty π‘
-1094297856 (Left β¬
οΈ) Arrived a new car! ππ¨
-1069119744 (Left β¬
οΈ) Now is my turn, I'll prepare to pass π‘
-1069119744 (Left β¬
οΈ) I'm the fist, I allow the Left β¬
οΈ direction π’ π’
-1069119744 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1094297856 (Left β¬
οΈ) I'm the fist, I allow the Left β¬
οΈ direction π’ π’
-1069119744 (Left β¬
οΈ) I passed the bridge π’
-1069119744 (Left β¬
οΈ) I was the last, the bridge is empty π‘
-1094297856 (Left β¬
οΈ) I'll pass the bridge in a row, and now I'm the last π’
-1094297856 (Left β¬
οΈ) I passed the bridge π’
-1094297856 (Left β¬
οΈ) I was the last, the bridge is empty π‘
_ end line _