version 1.70, 2011/09/20 15:45:52
|
version 1.78, 2012/01/17 14:44:05
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.3 |
RPL/2 (R) version 4.1.6 |
Copyright (C) 1989-2011 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 544 allocation(struct_processus *s_etat_proc
|
Line 544 allocation(struct_processus *s_etat_proc
|
return(NULL); |
return(NULL); |
} |
} |
|
|
|
(*((struct_mutex *) (*s_objet).objet)).tid = pthread_self(); |
break; |
break; |
} |
} |
|
|
Line 1103 liberation(struct_processus *s_etat_proc
|
Line 1104 liberation(struct_processus *s_etat_proc
|
return; |
return; |
} |
} |
|
|
|
if (pthread_mutex_trylock(&((*((struct_mutex *) |
|
(*s_objet).objet)).mutex)) == 0) |
|
{ |
|
// On a pu verrouiller le mutex. Il faut donc spécifier le tid. |
|
(*((struct_mutex *) (*s_objet).objet)).tid = pthread_self(); |
|
} |
|
|
|
if (pthread_equal(pthread_self(), |
|
(*((struct_mutex *) (*s_objet).objet)).tid) != 0) |
|
{ |
|
pthread_mutex_unlock(&((*((struct_mutex *) |
|
(*s_objet).objet)).mutex)); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_mutex_acquis_autre_thread; |
|
return; |
|
} |
|
|
|
pthread_mutex_destroy(&((*((struct_mutex *) |
|
(*s_objet).objet)).mutex)); |
free((struct_mutex *) (*s_objet).objet); |
free((struct_mutex *) (*s_objet).objet); |
break; |
break; |
} |
} |
Line 2216 copie_objet(struct_processus *s_etat_pro
|
Line 2239 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); |
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; |
|
} |
} |
|
|
case NOM : |
case NOM : |
Line 2484 copie_objet(struct_processus *s_etat_pro
|
Line 2496 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 2804 copie_etat_processus(struct_processus *s
|
Line 2818 copie_etat_processus(struct_processus *s
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
|
|
# ifndef SEMAPHORES_NOMMES |
// Les sémaphores sont initialisés dans le nouveau thread. Il |
sem_init(&((*s_nouvel_etat_processus).semaphore_fork), 0, 0); |
// s'agit d'une limitation de l'implantation de l'émulation |
# else |
// de sem_init(). |
if (((*s_etat_processus).semaphore_fork = sem_init3(0, getpid(), |
|
pthread_self(), SEM_FORK)) == SEM_FAILED) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
# endif |
|
|
|
initialisation_contexte_cas(s_etat_processus); |
initialisation_contexte_cas(s_etat_processus); |
|
|
Line 2830 copie_etat_processus(struct_processus *s
|
Line 2837 copie_etat_processus(struct_processus *s
|
(*s_nouvel_etat_processus).processus_detache = d_faux; |
(*s_nouvel_etat_processus).processus_detache = d_faux; |
(*s_nouvel_etat_processus).evaluation_forcee = 'N'; |
(*s_nouvel_etat_processus).evaluation_forcee = 'N'; |
|
|
(*s_nouvel_etat_processus).compteur_violation_d_acces = 0; |
|
|
|
(*s_nouvel_etat_processus).nombre_objets_envoyes_non_lus = 0; |
(*s_nouvel_etat_processus).nombre_objets_envoyes_non_lus = 0; |
(*s_nouvel_etat_processus).nombre_objets_injectes = 0; |
(*s_nouvel_etat_processus).nombre_objets_injectes = 0; |
(*s_nouvel_etat_processus).presence_fusible = d_faux; |
(*s_nouvel_etat_processus).presence_fusible = d_faux; |