version 1.75, 2013/03/24 22:06:10
|
version 1.88, 2014/04/25 07:37:29
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.13 |
RPL/2 (R) version 4.1.18 |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
Copyright (C) 1989-2014 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 42 lancement_thread(void *argument)
|
Line 42 lancement_thread(void *argument)
|
|
|
pid_t ppid; |
pid_t ppid; |
|
|
pthread_t tid_final; |
|
|
|
sig_atomic_t registre_stop; |
sig_atomic_t registre_stop; |
|
|
ssize_t longueur_ecriture; |
ssize_t longueur_ecriture; |
Line 65 lancement_thread(void *argument)
|
Line 63 lancement_thread(void *argument)
|
|
|
struct timespec attente; |
struct timespec attente; |
|
|
|
unsigned char caractere; |
unsigned char *message; |
unsigned char *message; |
|
|
unsigned int erreur; |
unsigned int erreur; |
Line 90 lancement_thread(void *argument)
|
Line 89 lancement_thread(void *argument)
|
|
|
(*s_argument_thread).tid = pthread_self(); |
(*s_argument_thread).tid = pthread_self(); |
insertion_thread(s_etat_processus, d_faux); |
insertion_thread(s_etat_processus, d_faux); |
|
|
|
if (pthread_mutex_lock(&((*s_argument_thread).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
(*s_argument_thread).thread_actif = d_vrai; |
(*s_argument_thread).thread_actif = d_vrai; |
|
|
|
if (pthread_mutex_unlock(&((*s_argument_thread).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
// Envoi d'une donnée pour signaler le démarrage du thread au thread |
// Envoi d'une donnée pour signaler le démarrage du thread au thread |
// de surveillance. |
// de surveillance. |
|
|
|
caractere = 0; |
|
|
if (write_atomic(s_etat_processus, |
if (write_atomic(s_etat_processus, |
(*s_argument_thread).pipe_nombre_objets_attente[1], |
(*s_argument_thread).pipe_nombre_elements_attente[1], |
"-", sizeof(unsigned char)) != sizeof(unsigned char)) |
&caractere, sizeof(caractere)) != sizeof(caractere)) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
Line 106 lancement_thread(void *argument)
|
Line 120 lancement_thread(void *argument)
|
|
|
(*s_argument_thread).thread_actif = d_faux; |
(*s_argument_thread).thread_actif = d_faux; |
|
|
tid_final = (pthread_t) -2; |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_argument_thread).pipe_nombre_interruptions_attente[1], |
(*s_argument_thread).pipe_nombre_elements_attente[1], |
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
|
if (longueur_ecriture == -1) |
|
{ |
|
break; |
|
} |
|
} |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_argument_thread).pipe_nombre_objets_attente[1], |
|
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
|
{ |
{ |
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
{ |
{ |
Line 188 lancement_thread(void *argument)
|
Line 190 lancement_thread(void *argument)
|
} |
} |
else |
else |
{ |
{ |
if (((*s_etat_processus).var_volatile_alarme == 0) |
if (((*s_etat_processus).arret_depuis_abort == 0) |
&& ((*s_etat_processus).arret_depuis_abort == 0) |
|
&& ((*s_etat_processus).at_exit != NULL)) |
&& ((*s_etat_processus).at_exit != NULL)) |
{ |
{ |
(*s_etat_processus).var_volatile_requete_arret = 0; |
(*s_etat_processus).var_volatile_requete_arret = 0; |
(*s_etat_processus).var_volatile_traitement_retarde_stop = |
(*s_etat_processus).var_volatile_alarme = 0; |
-1; |
(*s_etat_processus).var_volatile_traitement_sigint = 0; |
|
|
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, "ATEXIT"); |
|
} |
|
|
if (evaluation(s_etat_processus, |
if (evaluation(s_etat_processus, |
(*s_etat_processus).at_exit, 'E') == d_erreur) |
(*s_etat_processus).at_exit, 'E') == d_erreur) |
Line 206 lancement_thread(void *argument)
|
Line 212 lancement_thread(void *argument)
|
d_ex_erreur_evaluation; |
d_ex_erreur_evaluation; |
} |
} |
} |
} |
|
|
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
} |
} |
} |
} |
} |
} |
Line 221 lancement_thread(void *argument)
|
Line 232 lancement_thread(void *argument)
|
pthread_cancel((*s_etat_processus).thread_fusible); |
pthread_cancel((*s_etat_processus).thread_fusible); |
} |
} |
|
|
tid_final = (pthread_t) -2; |
caractere = 0; |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_argument_thread).pipe_nombre_interruptions_attente[1], |
(*s_argument_thread).pipe_nombre_elements_attente[1], |
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
|
if (longueur_ecriture == -1) |
|
{ |
|
break; |
|
} |
|
} |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_argument_thread).pipe_nombre_objets_attente[1], |
|
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
|
{ |
{ |
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
{ |
{ |
Line 264 lancement_thread(void *argument)
|
Line 265 lancement_thread(void *argument)
|
{ |
{ |
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_argument_thread).pipe_erreurs[1], |
(*s_argument_thread).pipe_erreurs[1], |
&((*s_etat_processus).erreur_execution), |
(int *) &((*s_etat_processus).erreur_execution), |
sizeof((*s_etat_processus).erreur_execution))) != |
sizeof((*s_etat_processus).erreur_execution))) != |
sizeof((*s_etat_processus).erreur_execution)) |
sizeof((*s_etat_processus).erreur_execution)) |
{ |
{ |
Line 296 lancement_thread(void *argument)
|
Line 297 lancement_thread(void *argument)
|
{ |
{ |
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_argument_thread).pipe_erreurs[1], |
(*s_argument_thread).pipe_erreurs[1], |
&((*s_etat_processus).erreur_systeme), |
(int *) &((*s_etat_processus).erreur_systeme), |
sizeof((*s_etat_processus).erreur_systeme))) != |
sizeof((*s_etat_processus).erreur_systeme))) != |
sizeof((*s_etat_processus).erreur_systeme)) |
sizeof((*s_etat_processus).erreur_systeme)) |
{ |
{ |
Line 338 lancement_thread(void *argument)
|
Line 339 lancement_thread(void *argument)
|
|
|
close((*s_argument_thread).pipe_erreurs[1]); |
close((*s_argument_thread).pipe_erreurs[1]); |
close((*s_argument_thread).pipe_interruptions[1]); |
close((*s_argument_thread).pipe_interruptions[1]); |
close((*s_argument_thread).pipe_nombre_interruptions_attente[1]); |
close((*s_argument_thread).pipe_nombre_elements_attente[1]); |
close((*s_argument_thread).pipe_objets[1]); |
close((*s_argument_thread).pipe_objets[1]); |
close((*s_argument_thread).pipe_nombre_objets_attente[1]); |
|
close((*s_argument_thread).pipe_injections[0]); |
close((*s_argument_thread).pipe_injections[0]); |
close((*s_argument_thread).pipe_nombre_injections[0]); |
close((*s_argument_thread).pipe_nombre_injections[0]); |
close((*s_argument_thread).pipe_acquittement[0]); |
close((*s_argument_thread).pipe_acquittement[0]); |
Line 380 lancement_thread(void *argument)
|
Line 380 lancement_thread(void *argument)
|
l_element_courant = l_element_suivant; |
l_element_courant = l_element_suivant; |
} |
} |
|
|
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)); |
|
|
l_element_courant = (struct_liste_chainee *) |
l_element_courant = (struct_liste_chainee *) |
(*s_etat_processus).l_base_pile_processus; |
(*s_etat_processus).l_base_pile_processus; |
Line 466 lancement_thread(void *argument)
|
Line 466 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
!= 0) |
!= 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
Line 490 lancement_thread(void *argument)
|
Line 491 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread) |
(*(*l_element_courant).donnee).objet)).thread) |
.mutex)) != 0) |
.mutex)) != 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
Line 507 lancement_thread(void *argument)
|
Line 509 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
!= 0) |
!= 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
Line 540 lancement_thread(void *argument)
|
Line 543 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
(*(*l_element_courant).donnee).objet)).thread).mutex)) |
!= 0) |
!= 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
Line 595 lancement_thread(void *argument)
|
Line 599 lancement_thread(void *argument)
|
|
|
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
|
|
if (registre_stop == 0) |
if (registre_stop == 0) |
{ |
{ |
Line 646 lancement_thread(void *argument)
|
Line 651 lancement_thread(void *argument)
|
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)); |
|
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
(*s_etat_processus).erreur_systeme = d_es_signal; |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
Line 664 lancement_thread(void *argument)
|
Line 670 lancement_thread(void *argument)
|
} |
} |
} |
} |
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_interruptions)) != 0) |
|
{ |
|
pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
exit(EXIT_FAILURE); |
|
} |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
{ |
{ |
affectation_interruptions_logicielles(s_etat_processus); |
affectation_interruptions_logicielles(s_etat_processus); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_interruptions)) |
|
!= 0) |
|
{ |
|
pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
exit(EXIT_FAILURE); |
|
} |
|
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)); |
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)); |
} |
} |
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus).mutex_pile_processus)); |
|
|
l_element_courant = (*s_etat_processus).s_sockets; |
l_element_courant = (*s_etat_processus).s_sockets; |
|
|
Line 996 lancement_thread(void *argument)
|
Line 1018 lancement_thread(void *argument)
|
liberation_allocateur(s_etat_processus); |
liberation_allocateur(s_etat_processus); |
|
|
retrait_thread(s_etat_processus); |
retrait_thread(s_etat_processus); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex_pile_processus)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_interruptions)); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_signaux)); |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
Line 1011 lancement_thread(void *argument)
|
Line 1035 lancement_thread(void *argument)
|
free(s_etat_processus); |
free(s_etat_processus); |
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
|
(*s_argument_thread).thread_actif = d_faux; |
pthread_mutex_unlock(&((*s_argument_thread).mutex)); |
pthread_mutex_unlock(&((*s_argument_thread).mutex)); |
|
|
(*s_argument_thread).thread_actif = d_faux; |
|
pthread_exit(NULL); |
pthread_exit(NULL); |
return(NULL); |
return(NULL); |
} |
} |