version 1.26, 2010/06/17 11:00:23
|
version 1.35, 2010/08/12 14:13:57
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.16 |
RPL/2 (R) version 4.0.18 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 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 266 liberation_maillon(struct_processus *s_e
|
Line 266 liberation_maillon(struct_processus *s_e
|
================================================================================ |
================================================================================ |
Routine d'allocation d'une structure *s_objet |
Routine d'allocation d'une structure *s_objet |
================================================================================ |
================================================================================ |
Entrées : structure sur l'état du processus et objet à afficher |
Entrées : structure sur l'état du processus et objet à allouer |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Sorties : chaine de caractères |
Sorties : chaine de caractères |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 279 allocation(struct_processus *s_etat_proc
|
Line 279 allocation(struct_processus *s_etat_proc
|
{ |
{ |
struct_objet *s_objet; |
struct_objet *s_objet; |
|
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_allocation)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
if ((*s_etat_processus).pile_objets == NULL) |
if ((*s_etat_processus).pile_objets == NULL) |
{ |
{ |
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_allocation)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
|
|
// Il n'existe aucune structure struct_objet disponible dans le cache. |
// Il n'existe aucune structure struct_objet disponible dans le cache. |
|
|
if ((s_objet = malloc(sizeof(struct_objet))) == NULL) |
if ((s_objet = malloc(sizeof(struct_objet))) == NULL) |
Line 299 allocation(struct_processus *s_etat_proc
|
Line 311 allocation(struct_processus *s_etat_proc
|
(*s_etat_processus).taille_pile_objets--; |
(*s_etat_processus).taille_pile_objets--; |
|
|
(*s_objet).nombre_occurrences = 1; |
(*s_objet).nombre_occurrences = 1; |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_allocation)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return(NULL); |
|
} |
} |
} |
|
|
(*s_objet).type = type; |
(*s_objet).type = type; |
Line 1104 liberation(struct_processus *s_etat_proc
|
Line 1122 liberation(struct_processus *s_etat_proc
|
return; |
return; |
} |
} |
|
|
free(s_objet); |
|
break; |
break; |
} |
} |
|
|
Line 1149 liberation(struct_processus *s_etat_proc
|
Line 1166 liberation(struct_processus *s_etat_proc
|
pthread_mutex_destroy(&((*(*((struct_processus_fils *) |
pthread_mutex_destroy(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex)); |
(*s_objet).objet)).thread).mutex)); |
free((*((struct_processus_fils *) (*s_objet).objet)).thread); |
free((*((struct_processus_fils *) (*s_objet).objet)).thread); |
|
|
} |
} |
|
|
if (decrementation_atomique(s_objet) > 0) |
if (decrementation_atomique(s_objet) > 0) |
{ |
{ |
|
BUG(drapeau == d_vrai, uprintf("(*(*((struct_processus_fils" |
|
" *) (*s_objet).objet)).thread).nombre_references " |
|
"= 0 with nombre_occurrences > 0\n")); |
return; |
return; |
} |
} |
|
|
Line 1417 liberation(struct_processus *s_etat_proc
|
Line 1438 liberation(struct_processus *s_etat_proc
|
return; |
return; |
} |
} |
|
|
if (s_etat_processus != NULL) |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_allocation)) != 0) |
{ |
{ |
if ((*s_etat_processus).taille_pile_objets < TAILLE_CACHE) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
{ |
return; |
(*s_objet).objet = (*s_etat_processus).pile_objets; |
} |
(*s_etat_processus).pile_objets = s_objet; |
|
(*s_etat_processus).taille_pile_objets++; |
|
} |
|
else |
|
{ |
|
if (pthread_mutex_destroy(&((*s_objet).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
free(s_objet); |
if ((*s_etat_processus).taille_pile_objets < TAILLE_CACHE) |
} |
{ |
|
(*s_objet).objet = (*s_etat_processus).pile_objets; |
|
(*s_etat_processus).pile_objets = s_objet; |
|
(*s_etat_processus).taille_pile_objets++; |
} |
} |
else |
else |
{ |
{ |
|
if (pthread_mutex_destroy(&((*s_objet).mutex)) != 0) |
|
{ |
|
pthread_mutex_unlock(&((*s_etat_processus).mutex_allocation)); |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
free(s_objet); |
free(s_objet); |
} |
} |
|
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_allocation)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
return; |
return; |
} |
} |
|
|
Line 2802 copie_etat_processus(struct_processus *s
|
Line 2829 copie_etat_processus(struct_processus *s
|
(*s_nouvel_etat_processus).nombre_interruptions_non_affectees = 0; |
(*s_nouvel_etat_processus).nombre_interruptions_non_affectees = 0; |
|
|
(*s_nouvel_etat_processus).at_exit = NULL; |
(*s_nouvel_etat_processus).at_exit = NULL; |
|
(*s_nouvel_etat_processus).at_poke = NULL; |
|
(*s_nouvel_etat_processus).traitement_at_poke = 'N'; |
|
|
for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++) |
for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++) |
{ |
{ |
Line 2813 copie_etat_processus(struct_processus *s
|
Line 2842 copie_etat_processus(struct_processus *s
|
|
|
if ((*s_nouvel_etat_processus).generateur_aleatoire != NULL) |
if ((*s_nouvel_etat_processus).generateur_aleatoire != NULL) |
{ |
{ |
(*s_nouvel_etat_processus).generateur_aleatoire = NULL; |
if (((*s_nouvel_etat_processus).generateur_aleatoire = |
} |
gsl_rng_clone((*s_etat_processus).generateur_aleatoire)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
(*s_nouvel_etat_processus).type_generateur_aleatoire = NULL; |
gsl_rng_set((*s_nouvel_etat_processus).generateur_aleatoire, |
|
gsl_rng_get((*s_etat_processus).generateur_aleatoire)); |
|
} |
|
|
// Copie de la localisation |
// Copie de la localisation |
|
|
Line 3538 copie_etat_processus(struct_processus *s
|
Line 3574 copie_etat_processus(struct_processus *s
|
pthread_mutex_init(&((*s_nouvel_etat_processus).mutex), &attributs_mutex); |
pthread_mutex_init(&((*s_nouvel_etat_processus).mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
|
pthread_mutex_init(&((*s_nouvel_etat_processus).mutex_allocation), |
|
&attributs_mutex); |
|
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |