Hilos - Universidad Nacional de San Antonio Abad del Cusco
Hilos - Universidad Nacional de San Antonio Abad del Cusco
Hilos - Universidad Nacional de San Antonio Abad del Cusco
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
UNIVERSIDAD NACIONAL DE SAN ANTONIO ABAD DEL CUSCOSISTEMAS DE OPERACIONES IGUIA DE LABORATORIOecp 4 <strong>de</strong> 8b) Escriba un programa que cree dos hilos no in<strong>de</strong>pendientes.Solución/**/Nombre : hilosDependientes.cObjetivo : crea dos hilos <strong>de</strong>pendientesAutor : Edwin CarrascoFCreacion : 06/12/2007FModificacion :#inclu<strong>de</strong>#inclu<strong>de</strong>void func(void){printf( "Soy el hilo %d \n", pthread_self());pthread_exit(0);}main(){pthread_t h1, h2;int iret1, iret2;iret1 = pthread_create(&h1, NULL,(void*) func, NULL);iret2 = pthread_create(&h2, NULL, (void*)func, NULL);printf("El hilo principal %d continua ejecutando\n",getpid());pthread_join(h1, NULL);pthread_join(h2, NULL);}exit(0);c) Escriba un programa que cree dos hilos, a los cuales les <strong>de</strong>be pasar como parámetros elcarácter que cada uno <strong>de</strong>be imprimir, así como el numero <strong>de</strong> veces que imprimirán elmismoSolución/**/Nombre : pasoParametros.cObjetivo : muestra el mecanismo <strong>de</strong> paso <strong>de</strong> parámetros ahilosAutor : Edwin CarrascoFCreacion : 06/12/2007FModificacion :#inclu<strong>de</strong> #inclu<strong>de</strong>