Publicado el 20 de Marzo del 2018
717 visualizaciones desde el 20 de Marzo del 2018
2,8 MB
672 paginas
Creado hace 11a (19/06/2012)
Programaci´on Distribuida y Mejora del Rendimiento
Casiano R. Le´on 1
19 de junio de 2012
1DEIOC Universidad de La Laguna
Programaci´on Distribuida y Mejora del Rendimiento by Casiano R. Le´on DEIOC Universidad de La
Laguna is licensed under a Creative Commons Reconocimiento 3.0 Unported License.
Permissions beyond the scope of this license may be available at:
http://campusvirtual.ull.es/ocw/course/view.php?id=44.
1
´Indice general
1. Ejecucion de Programas
13
13
15
17
18
19
22
28
29
1.1. La funci´on system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2. La funci´on exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3. Variables de entorno . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4. Uso de comillas de ejecuci´on (Backticks) . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5. Salvando Manejadores de Fichero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.6. Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.7. Entrada/Salida sin Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.8. Repaso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.9. Pr´actica: Introducci´on a los Sistemas de Control de Versiones. Ejecuci´on Controlada de Un Programa 31
1.10. Repaso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.11. Repaso: Control de Versiones
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.12. Pr´actica: Un Comando para la Gesti´on de Usuarios en Subversion . . . . . . . . . . .
1.13. El M´odulo IPC::Run3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.14. Pr´actica: Uso de IPC::Run3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.15. Pipes con nombre . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.15.1. Pr´actica: Pipes con Nombre. Apertura Bidireccional
. . . . . . . . . . . . . . .
1.15.2. Pr´actica: Calculo Usando Pipes con Nombre . . . . . . . . . . . . . . . . . . . .
67
77
84
85
85
85
90
91
2. SSH: Secure Shell
94
94
2.1. Conexiones con ssh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
94
2.1.1.
Introducci´on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
95
2.1.2. Conexi´on SSH a Una m´aquina por Primera Vez . . . . . . . . . . . . . . . . . .
2.1.3. Claves P´ublica y Privada: Estableciendo Autentificaci´on No Interactiva . . . .
97
2.1.4. Copia Segura de un Fichero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
2.1.5. Pr´actica: Copia Segura Paralela: Parallel Secure Copy . . . . . . . . . . . . . . 102
2.1.6. Copia Segura en Cascada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
2.1.7. Transferencia por sftp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
2.1.8. El fichero authorized keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
2.1.9. Acceso S´olo Via scp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
2.1.10. Pr´actica: Repositorio svn y ssh . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
2.1.11. SSH::RPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
2.1.12. Deshabilitar la Asignaci´on de una TTY . . . . . . . . . . . . . . . . . . . . . . 118
2.1.13. Agentes SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
2.1.14. Mejor un S´olo Agente . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
2.1.15. Redireccionado al Agente SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
2.1.16. Consideraciones sobre la Seguridad del Uso de Agentes . . . . . . . . . . . . . . 128
2.1.17. Depuraci´on/Debugging
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
2.1.18. Los Ficheros de Configuraci´on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
2.1.19. Copias de Seguridad con rsync . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
2.1.20. Multiplexado de Conexiones con SSH . . . . . . . . . . . . . . . . . . . . . . . 138
2.1.21. Conexiones X y Tunneling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
2.1.22. Tunneling Directo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
2
2.1.23. Creaci´on de un Tunel Inverso . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
2.1.24. SSH como Proxy SOCKS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
2.2. Montando un Disco Remoto via SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
2.3. Protegi´endose contra Ataques con Diccionarios
. . . . . . . . . . . . . . . . . . . . . . 148
2.4. Distributed Shell: dsh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
2.5. Conexi´on Autom´atica ssh con Net::SSH::Perl . . . . . . . . . . . . . . . . . . . . . . 151
2.5.1. Perl SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
2.5.2. Cifrados . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
2.5.3. Conmutando Entre Modo Batch e Interactivo . . . . . . . . . . . . . . . . . . . 155
2.6. El M´odulo Net::SSH::Expect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
2.7. El M´odulo IPC::PerlSSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
2.8. Pr´actica: Producto de Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
2.9. Visualizaci´on de un Cluster con cssh . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
2.10. Pr´actica: usando cssh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
2.11. Arrancando M´ultiples Sesiones SSH Usando DCOP . . . . . . . . . . . . . . . . . . . . 161
2.12. Virtual Network Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
2.13. screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
3. Fork y Se˜nales
169
3.1. La Funci´on fork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
3.2. La Funci´on wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
3.3. La Depuraci´on de Procesos
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
3.4. Se˜nales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
3.4.1. Lista de Se˜nales
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
3.4.2. Env´ıo de se˜nales
3.4.3. Captura de se˜nales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
3.4.4. Se˜nales a Grupos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
3.4.5. Controlando Errores en Tiempo de Ejecuci´on con eval . . . . . . . . . . . . . 177
3.4.6. Controlando warnings en tiempo de ejecuci´on . . . . . . . . . . . . . . . . . . . 179
3.4.7. A Donde se Retorna Despu´es de la Ejecuci´on del Manejador de una Se˜nal
. . . 179
3.4.8. Cronometrando el Tiempo de Entrada con alarm . . . . . . . . . . . . . . . . . 181
3.4.9. Limitando el Tiempo de Lectura . . . . . . . . . . . . . . . . . . . . . . . . . . 181
3.4.10. Limitando el Tiempo de un Proceso . . . . . . . . . . . . . . . . . . . . . . . . 182
3.4.11. El Manejo de Excepciones PIPE . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
3.4.12. El Manejador IGNORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
3.4.13. Consideraciones sobre el uso de las Se˜nales
. . . . . . . . . . . . . . . . . . . . 185
3.4.14. Cosechado con un Manejador para CHLD . . . . . . . . . . . . . . . . . . . . . . 186
3.4.15. Ejercicio: Barreras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
3.5. Cerrojos sobre Ficheros
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
3.6. Pr´actica: C´alculo Multiproceso usando cerrojos . . . . . . . . . . . . . . . . . . . . . . 189
3.7. Pr´actica: El PID de un Subproceso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.8. Pr´actica: Marshalling: Modifique Proc::Simple . . . . . . . . . . . . . . . . . . . . . . 190
3.9. El M´odulo Parallel::Simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
3.10. El M´odulo Parallel::ForkManager . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
3.11. Pr´actica: Callbacks en ForkManager . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
3.12. El An´alisis de URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
3.13. Pr´actica: Analisis de URLs en el Programa de Descarga . . . . . . . . . . . . . . . . . 202
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
3.14. Granjas Simples
3.14.1. Granja usando pipes y wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
3.14.2. Ejercicio: Uso de waitpid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.14.3. Ejercicio: Hashes de Manejadores . . . . . . . . . . . . . . . . . . . . . . . . . . 207
3.14.4. Granja con Extensiones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
3.14.5. Pr´actica: Granja con Pipes
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
3
3.14.6. Pr´actica: Extendiendo los Objetos Farm::Machine . . . . . . . . . . . . . . . . 218
4. Pipes
221
4.1. La Funci´on pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
4.1.1. M´ultiples escritores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
4.1.2. M´ultiples Lectores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
4.1.3. Comunicaci´on Bidireccional con Pipe . . . . . .
Comentarios de: Programación distribuida y mejora del rendimiento (0)
No hay comentarios