version 1.12, 2010/04/28 07:05:38
|
version 1.58, 2012/01/05 10:18:59
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.15 |
RPL/2 (R) version 4.1.5 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 46 lancement_thread(void *argument)
|
Line 46 lancement_thread(void *argument)
|
|
|
sig_atomic_t registre_stop; |
sig_atomic_t registre_stop; |
|
|
sigset_t set; |
|
|
|
ssize_t longueur_ecriture; |
ssize_t longueur_ecriture; |
|
|
struct_descripteur_thread *s_argument_thread; |
struct_descripteur_thread *s_argument_thread; |
Line 74 lancement_thread(void *argument)
|
Line 72 lancement_thread(void *argument)
|
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
s_argument_thread = (struct_descripteur_thread *) argument; |
s_argument_thread = (struct_descripteur_thread *) argument; |
(*s_argument_thread).tid = pthread_self(); |
|
(*s_argument_thread).thread_actif = d_vrai; |
|
s_etat_processus = (*s_argument_thread).s_nouvel_etat_processus; |
s_etat_processus = (*s_argument_thread).s_nouvel_etat_processus; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (pthread_setspecific(semaphore_fork_processus_courant, |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
# else |
if (pthread_setspecific(semaphore_fork_processus_courant, |
if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), |
(*s_etat_processus).semaphore_fork) != 0) |
pthread_self(), SEM_FORK)) == SEM_FAILED) |
# endif |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
|
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
|
pthread_mutex_unlock(&((*s_argument_thread).mutex)); |
|
|
|
(*s_argument_thread).thread_actif = d_faux; |
|
|
|
tid_final = -2; |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_argument_thread).pipe_nombre_interruptions_attente[1], |
|
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
|
{ |
|
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) |
|
{ |
|
break; |
|
} |
|
} |
|
|
|
pthread_exit(NULL); |
|
} |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
|
|
pthread_mutex_lock(&((*s_argument_thread).mutex)); |
|
pthread_mutex_unlock(&((*s_argument_thread).mutex)); |
|
|
|
(*s_argument_thread).thread_actif = d_faux; |
|
|
|
tid_final = -2; |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_argument_thread).pipe_nombre_interruptions_attente[1], |
|
&tid_final, sizeof(tid_final))) != sizeof(tid_final)) |
|
{ |
|
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) |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
{ |
return(NULL); |
break; |
|
} |
|
} |
} |
|
# endif |
|
|
pthread_exit(NULL); |
(*s_argument_thread).tid = pthread_self(); |
} |
(*s_argument_thread).thread_actif = d_vrai; |
|
|
insertion_thread(s_etat_processus, d_faux); |
insertion_thread(s_etat_processus, d_faux); |
|
|
Line 163 lancement_thread(void *argument)
|
Line 97 lancement_thread(void *argument)
|
(*s_argument_thread).pipe_nombre_objets_attente[1], |
(*s_argument_thread).pipe_nombre_objets_attente[1], |
"-", sizeof(unsigned char)) != sizeof(unsigned char)) |
"-", sizeof(unsigned char)) != sizeof(unsigned char)) |
{ |
{ |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
|
(*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 202 lancement_thread(void *argument)
|
Line 135 lancement_thread(void *argument)
|
(*s_etat_processus).instruction_courante = NULL; |
(*s_etat_processus).instruction_courante = NULL; |
} |
} |
|
|
set = (*s_argument_thread).set; |
// Attente de la réception du signal rpl_sigstart. |
|
|
if (sigpending(&set) != 0) |
for((*s_etat_processus).demarrage_fils = d_faux;;) |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
} |
|
else if (sigismember(&set, SIGSTART) == 0) |
|
{ |
{ |
while(sigismember(&set, SIGSTART) == 0) |
scrutation_interruptions(s_etat_processus); |
{ |
|
if (sigpending(&set) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
if ((*s_etat_processus).demarrage_fils == d_vrai) |
|
{ |
|
break; |
} |
} |
|
|
|
nanosleep(&attente, NULL); |
} |
} |
|
|
if ((*s_etat_processus).debug == d_vrai) |
if ((*s_etat_processus).debug == d_vrai) |
Line 238 lancement_thread(void *argument)
|
Line 166 lancement_thread(void *argument)
|
fflush(stdout); |
fflush(stdout); |
} |
} |
|
|
if (pthread_sigmask(SIG_SETMASK, &((*s_argument_thread).oldset), NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
} |
|
|
|
sigpending(&set); |
|
|
|
(*s_etat_processus).pid_erreur_processus_fils = getpid(); |
(*s_etat_processus).pid_erreur_processus_fils = getpid(); |
|
|
// Évaluation de l'objet |
// Évaluation de l'objet |
|
|
if ((*s_etat_processus).erreur_systeme == d_es) |
if ((*s_etat_processus).erreur_systeme == d_es) |
{ |
{ |
if (evaluation(s_etat_processus, (*s_argument_thread).argument, 'E') |
if (setjmp(contexte_thread) == 0) |
== d_erreur) |
|
{ |
{ |
if (((*s_etat_processus).erreur_execution == d_ex) && |
if (evaluation(s_etat_processus, (*s_argument_thread).argument, 'E') |
((*s_etat_processus).erreur_systeme == d_es)) |
== d_erreur) |
{ |
{ |
(*s_etat_processus).erreur_execution = |
if (((*s_etat_processus).erreur_execution == d_ex) && |
d_ex_erreur_evaluation; |
((*s_etat_processus).erreur_systeme == d_es)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_evaluation; |
|
} |
} |
} |
} |
else |
else |
|
{ |
|
if ((*s_etat_processus).at_exit != NULL) |
|
{ |
{ |
if (evaluation(s_etat_processus, (*s_etat_processus).at_exit, |
if (((*s_etat_processus).var_volatile_alarme == 0) |
'E') == d_erreur) |
&& ((*s_etat_processus).arret_depuis_abort == 0) |
{ |
&& ((*s_etat_processus).at_exit != NULL)) |
if (((*s_etat_processus).erreur_execution == d_ex) && |
{ |
((*s_etat_processus).erreur_systeme == d_es)) |
(*s_etat_processus).var_volatile_requete_arret = 0; |
|
(*s_etat_processus).var_volatile_traitement_retarde_stop = |
|
-1; |
|
|
|
if (evaluation(s_etat_processus, |
|
(*s_etat_processus).at_exit, 'E') == d_erreur) |
{ |
{ |
(*s_etat_processus).erreur_execution = |
if (((*s_etat_processus).erreur_execution == d_ex) && |
d_ex_erreur_evaluation; |
((*s_etat_processus).erreur_systeme == d_es)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_evaluation; |
|
} |
} |
} |
} |
} |
} |
} |
Line 483 lancement_thread(void *argument)
|
Line 413 lancement_thread(void *argument)
|
|
|
if ((*s_etat_processus).var_volatile_alarme != 0) |
if ((*s_etat_processus).var_volatile_alarme != 0) |
{ |
{ |
kill((*(*((struct_processus_fils *) (*(*l_element_courant) |
envoi_signal_processus((*(*((struct_processus_fils *) |
.donnee).objet)).thread).pid, SIGURG); |
(*(*l_element_courant) |
|
.donnee).objet)).thread).pid, rpl_sigurg); |
} |
} |
else |
else |
{ |
{ |
kill((*(*((struct_processus_fils *) (*(*l_element_courant) |
if ((*s_etat_processus).arret_depuis_abort == -1) |
.donnee).objet)).thread).pid, SIGFSTOP); |
{ |
|
envoi_signal_processus((*(*((struct_processus_fils *) |
|
(*(*l_element_courant) |
|
.donnee).objet)).thread).pid, rpl_sigabort); |
|
} |
|
else |
|
{ |
|
envoi_signal_processus((*(*((struct_processus_fils *) |
|
(*(*l_element_courant) |
|
.donnee).objet)).thread).pid, rpl_sigstop); |
|
} |
} |
} |
} |
} |
else |
else |
Line 538 lancement_thread(void *argument)
|
Line 479 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread) |
(*(*l_element_courant).donnee).objet)).thread) |
.thread_actif == d_vrai) |
.thread_actif == d_vrai) |
{ |
{ |
pthread_kill((*(*((struct_processus_fils *) |
envoi_signal_thread((*(*((struct_processus_fils *) |
(*(*l_element_courant).donnee).objet)).thread).tid, |
(*(*l_element_courant).donnee).objet)).thread).tid, |
SIGURG); |
rpl_sigurg); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
Line 579 lancement_thread(void *argument)
|
Line 520 lancement_thread(void *argument)
|
(*(*l_element_courant).donnee).objet)).thread) |
(*(*l_element_courant).donnee).objet)).thread) |
.thread_actif == d_vrai) |
.thread_actif == d_vrai) |
{ |
{ |
pthread_kill((*(*((struct_processus_fils *) |
if ((*s_etat_processus).arret_depuis_abort == -1) |
(*(*l_element_courant).donnee).objet)).thread).tid, |
{ |
SIGFSTOP); |
envoi_signal_thread((*(*((struct_processus_fils *) |
|
(*(*l_element_courant).donnee).objet)).thread) |
|
.tid, rpl_sigabort); |
|
} |
|
else |
|
{ |
|
envoi_signal_thread((*(*((struct_processus_fils *) |
|
(*(*l_element_courant).donnee).objet)).thread) |
|
.tid, rpl_sigstop); |
|
} |
} |
} |
|
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
Line 621 lancement_thread(void *argument)
|
Line 571 lancement_thread(void *argument)
|
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; |
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
|
{ |
|
affectation_interruptions_logicielles(s_etat_processus); |
|
} |
|
|
|
registre_stop = (*s_etat_processus) |
registre_stop = (*s_etat_processus) |
.var_volatile_traitement_retarde_stop; |
.var_volatile_traitement_retarde_stop; |
(*s_etat_processus).var_volatile_traitement_retarde_stop = 1; |
(*s_etat_processus).var_volatile_traitement_retarde_stop = 1; |
Line 718 lancement_thread(void *argument)
|
Line 663 lancement_thread(void *argument)
|
} |
} |
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
|
|
|
if ((*s_etat_processus).nombre_interruptions_non_affectees != 0) |
|
{ |
|
affectation_interruptions_logicielles(s_etat_processus); |
|
} |
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
} |
} |
Line 859 lancement_thread(void *argument)
|
Line 810 lancement_thread(void *argument)
|
(*s_etat_processus).instruction_derniere_erreur = NULL; |
(*s_etat_processus).instruction_derniere_erreur = NULL; |
} |
} |
|
|
for(i = 0; i < (*s_etat_processus).nombre_variables; i++) |
liberation_arbre_variables(s_etat_processus, |
{ |
(*s_etat_processus).s_arbre_variables, d_faux); |
// Les définitions ne sont pas libérées parce qu'elles sont partagées |
|
// avec le thread père. |
|
|
|
if ((*s_etat_processus).s_liste_variables[i].niveau != 0) |
|
{ |
|
liberation(s_etat_processus, |
|
(*s_etat_processus).s_liste_variables[i].objet); |
|
} |
|
|
|
free((*s_etat_processus).s_liste_variables[i].nom); |
|
} |
|
|
|
free((*s_etat_processus).s_liste_variables); |
|
|
|
for(i = 0; i < (*s_etat_processus).nombre_variables_statiques; i++) |
for(i = 0; i < (*s_etat_processus).nombre_variables_statiques; i++) |
{ |
{ |
Line 1008 lancement_thread(void *argument)
|
Line 946 lancement_thread(void *argument)
|
|
|
liberation(s_etat_processus, (*s_argument_thread).argument); |
liberation(s_etat_processus, (*s_argument_thread).argument); |
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
|
liberation(s_etat_processus, (*s_etat_processus).at_poke); |
|
|
for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++) |
for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++) |
{ |
{ |
Line 1055 lancement_thread(void *argument)
|
Line 994 lancement_thread(void *argument)
|
|
|
retrait_thread(s_etat_processus); |
retrait_thread(s_etat_processus); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
|
# else |
|
sem_destroy3((*s_etat_processus).semaphore_fork, getpid(), |
|
pthread_self(), SEM_FORK); |
|
# endif |
|
|
|
liberation_contexte_cas(s_etat_processus); |
free((*s_etat_processus).localisation); |
free((*s_etat_processus).localisation); |
free(s_etat_processus); |
free(s_etat_processus); |
|
|
Line 1064 lancement_thread(void *argument)
|
Line 1012 lancement_thread(void *argument)
|
|
|
(*s_argument_thread).thread_actif = d_faux; |
(*s_argument_thread).thread_actif = d_faux; |
pthread_exit(NULL); |
pthread_exit(NULL); |
|
return(NULL); |
} |
} |
|
|
// vim: ts=4 |
// vim: ts=4 |