version 1.51, 2011/06/21 15:03:58
|
version 1.75, 2011/11/26 10:01:26
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.0.prerelease.1 |
RPL/2 (R) version 4.1.5 |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 111 initialisation_allocateur(struct_process
|
Line 111 initialisation_allocateur(struct_process
|
(*s_etat_processus).pointeur_vec = 0; |
(*s_etat_processus).pointeur_vec = 0; |
(*s_etat_processus).pointeur_maillons = 0; |
(*s_etat_processus).pointeur_maillons = 0; |
|
|
|
(*s_etat_processus).pointeur_variables_noeud = 0; |
|
(*s_etat_processus).pointeur_variables_feuille = 0; |
|
(*s_etat_processus).pointeur_variables_variable = 0; |
|
(*s_etat_processus).pointeur_variables_tableau_noeuds = 0; |
|
|
return; |
return; |
} |
} |
|
|
Line 143 liberation_allocateur(struct_processus *
|
Line 148 liberation_allocateur(struct_processus *
|
for(i = 0; i < (*s_etat_processus).pointeur_maillons; |
for(i = 0; i < (*s_etat_processus).pointeur_maillons; |
free((*s_etat_processus).maillons[i++])); |
free((*s_etat_processus).maillons[i++])); |
|
|
|
for(i = 0; i < (*s_etat_processus).pointeur_variables_noeud; |
|
free((*s_etat_processus).variables_noeud[i++])); |
|
for(i = 0; i < (*s_etat_processus).pointeur_variables_feuille; |
|
free((*s_etat_processus).variables_feuille[i++])); |
|
for(i = 0; i < (*s_etat_processus).pointeur_variables_variable; |
|
free((*s_etat_processus).variables_variable[i++])); |
|
for(i = 0; i < (*s_etat_processus).pointeur_variables_tableau_noeuds; |
|
free((*s_etat_processus).variables_tableau_noeuds[i++])); |
|
|
{ |
{ |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_suivant; |
struct_liste_chainee *l_element_suivant; |
Line 234 allocation_maillon(struct_processus *s_e
|
Line 248 allocation_maillon(struct_processus *s_e
|
|
|
/* |
/* |
================================================================================ |
================================================================================ |
Routine d'allocation d'un maillon d'un objet (liste, expression...) |
Routine de libération d'un maillon d'un objet (liste, expression...) |
================================================================================ |
================================================================================ |
Entrées : structure sur l'état du processus et objet à afficher |
Entrées : structure sur l'état du processus et objet à afficher |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 274 liberation_maillon(struct_processus *s_e
|
Line 288 liberation_maillon(struct_processus *s_e
|
================================================================================ |
================================================================================ |
*/ |
*/ |
|
|
void * |
struct_objet * |
allocation(struct_processus *s_etat_processus, enum t_type type) |
allocation(struct_processus *s_etat_processus, enum t_type type) |
{ |
{ |
struct_objet *s_objet; |
struct_objet *s_objet; |
Line 758 liberation(struct_processus *s_etat_proc
|
Line 772 liberation(struct_processus *s_etat_proc
|
{ |
{ |
logical1 drapeau; |
logical1 drapeau; |
|
|
sigset_t oldset; |
|
sigset_t set; |
|
|
|
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_suivant; |
struct_liste_chainee *l_element_suivant; |
|
|
Line 1130 liberation(struct_processus *s_etat_proc
|
Line 1141 liberation(struct_processus *s_etat_proc
|
|
|
case PRC : |
case PRC : |
{ |
{ |
sigfillset(&set); |
|
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
Line 1166 liberation(struct_processus *s_etat_proc
|
Line 1171 liberation(struct_processus *s_etat_proc
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
if (drapeau == d_vrai) |
if (drapeau == d_vrai) |
{ |
{ |
pthread_mutex_destroy(&((*(*((struct_processus_fils *) |
pthread_mutex_destroy(&((*(*((struct_processus_fils *) |
Line 1513 struct_objet *
|
Line 1512 struct_objet *
|
copie_objet(struct_processus *s_etat_processus, |
copie_objet(struct_processus *s_etat_processus, |
struct_objet *s_objet, unsigned char type) |
struct_objet *s_objet, unsigned char type) |
{ |
{ |
sigset_t oldset; |
|
sigset_t set; |
|
|
|
struct_liste_chainee *l_element_base; |
struct_liste_chainee *l_element_base; |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant_ecriture; |
struct_liste_chainee *l_element_courant_ecriture; |
Line 2220 copie_objet(struct_processus *s_etat_pro
|
Line 2216 copie_objet(struct_processus *s_etat_pro
|
|
|
case MTX : |
case MTX : |
{ |
{ |
if (type != 'O') |
// La duplication d'un mutex renvoie le même objet. |
{ |
incrementation_atomique(s_objet); |
incrementation_atomique(s_objet); |
|
return(s_objet); |
|
} |
|
|
|
if ((s_nouvel_objet = allocation(s_etat_processus, MTX)) == NULL) |
|
{ |
|
return(NULL); |
|
} |
|
|
|
(*((struct_mutex *) ((*s_nouvel_objet).objet))).mutex = |
|
(*((struct_mutex *) ((*s_objet).objet))).mutex; |
|
break; |
break; |
} |
} |
|
|
Line 2286 copie_objet(struct_processus *s_etat_pro
|
Line 2271 copie_objet(struct_processus *s_etat_pro
|
|
|
case PRC : |
case PRC : |
{ |
{ |
sigfillset(&set); |
|
pthread_sigmask(SIG_BLOCK, &set, &oldset); |
|
|
|
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
return(NULL); |
return(NULL); |
} |
} |
|
|
Line 2304 copie_objet(struct_processus *s_etat_pro
|
Line 2283 copie_objet(struct_processus *s_etat_pro
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
(*s_objet).objet)).thread).mutex_nombre_references)) != 0) |
{ |
{ |
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
return(NULL); |
return(NULL); |
} |
} |
|
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL); |
|
sigpending(&set); |
|
|
|
if (type != 'O') |
if (type != 'O') |
{ |
{ |
incrementation_atomique(s_objet); |
incrementation_atomique(s_objet); |
Line 2500 copie_objet(struct_processus *s_etat_pro
|
Line 2473 copie_objet(struct_processus *s_etat_pro
|
return(NULL); |
return(NULL); |
} |
} |
|
|
|
(*((struct_semaphore *) (*s_nouvel_objet).objet)).semaphore = |
|
(*((struct_semaphore *) (*s_objet).objet)).semaphore; |
strcpy((*((struct_semaphore *) (*s_nouvel_objet).objet)).nom, |
strcpy((*((struct_semaphore *) (*s_nouvel_objet).objet)).nom, |
(*((struct_semaphore *) (*s_objet).objet)).nom); |
(*((struct_semaphore *) (*s_objet).objet)).nom); |
break; |
break; |
Line 2817 copie_etat_processus(struct_processus *s
|
Line 2792 copie_etat_processus(struct_processus *s
|
* n'ont aucune raison de changer. |
* n'ont aucune raison de changer. |
*/ |
*/ |
|
|
# ifndef SEMAPHORES_NOMMES |
pthread_mutexattr_init(&attributs_mutex); |
sem_init(&((*s_nouvel_etat_processus).semaphore_fork), 0, 0); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
# else |
|
if (((*s_nouvel_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) |
// Les sémaphores sont initialisés dans le nouveau thread. Il |
== SEM_FAILED) |
// s'agit d'une limitation de l'implantation de l'émulation |
{ |
// de sem_init(). |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
initialisation_contexte_cas(s_etat_processus); |
} |
|
# endif |
|
|
|
(*s_nouvel_etat_processus).var_volatile_processus_pere = 0; |
(*s_nouvel_etat_processus).var_volatile_processus_pere = 0; |
(*s_nouvel_etat_processus).var_volatile_processus_racine = 0; |
(*s_nouvel_etat_processus).var_volatile_processus_racine = 0; |
Line 3284 copie_etat_processus(struct_processus *s
|
Line 3257 copie_etat_processus(struct_processus *s
|
* Copie des différents contextes |
* Copie des différents contextes |
*/ |
*/ |
|
|
|
(*s_nouvel_etat_processus).pointeur_signal_lecture = d_faux; |
|
(*s_nouvel_etat_processus).pointeur_signal_ecriture = d_faux; |
|
|
(*s_nouvel_etat_processus).l_base_pile_contextes = NULL; |
(*s_nouvel_etat_processus).l_base_pile_contextes = NULL; |
l_element_lecture = (*s_etat_processus).l_base_pile_contextes; |
l_element_lecture = (*s_etat_processus).l_base_pile_contextes; |
|
|
Line 3948 debug_fork()
|
Line 3924 debug_fork()
|
pthread_mutex_lock(&mutex_allocation); |
pthread_mutex_lock(&mutex_allocation); |
pid = fork(); |
pid = fork(); |
|
|
# ifdef OS2 |
|
if (pid == 0) |
|
{ |
|
sem_init(&semaphore_liste_threads, 0, 1); |
|
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
|
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
|
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
|
} |
|
# endif |
|
|
|
if (pid == 0) |
if (pid == 0) |
{ |
{ |
# ifdef _BROKEN_SIGINFO |
liberation_queue_signaux(s_etat_processus); |
liberation_fifos_signaux(s_etat_processus); |
creation_queue_signaux(s_etat_processus); |
creation_fifos_signaux(s_etat_processus); |
|
# endif |
|
|
|
pthread_mutex_destroy(&mutex_allocation); |
pthread_mutex_destroy(&mutex_allocation); |
debug_memoire_initialisation(); |
debug_memoire_initialisation(); |