version 1.25, 2010/06/09 12:18:17
|
version 1.28, 2010/06/19 15:54:51
|
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 3538 copie_etat_processus(struct_processus *s
|
Line 3565 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; |
Line 3716 debug_memoire_modification(void *pointeu
|
Line 3749 debug_memoire_modification(void *pointeu
|
{ |
{ |
pthread_mutex_unlock(&mutex_allocation); |
pthread_mutex_unlock(&mutex_allocation); |
|
|
uprintf("[%d-%llu] ILLEGAL POINTER\n", |
uprintf("[%d-%llu] ILLEGAL POINTER (realloc)\n", |
getpid(), (unsigned long long) pthread_self()); |
getpid(), (unsigned long long) pthread_self()); |
# ifdef __BACKTRACE |
# ifdef __BACKTRACE |
BACKTRACE(PROFONDEUR_PILE); |
BACKTRACE(PROFONDEUR_PILE); |
Line 3813 debug_memoire_retrait(void *pointeur)
|
Line 3846 debug_memoire_retrait(void *pointeur)
|
|
|
if (element_courant == NULL) |
if (element_courant == NULL) |
{ |
{ |
uprintf("[%d-%llu] ILLEGAL POINTER\n", |
uprintf("[%d-%llu] ILLEGAL POINTER (free)\n", |
getpid(), (unsigned long long) pthread_self()); |
getpid(), (unsigned long long) pthread_self()); |
# ifdef __BACKTRACE |
# ifdef __BACKTRACE |
BACKTRACE(PROFONDEUR_PILE); |
BACKTRACE(PROFONDEUR_PILE); |