version 1.34, 2011/09/20 14:36:30
|
version 1.35, 2011/09/20 15:45:53
|
Line 29
|
Line 29
|
// est dans ce cas. |
// est dans ce cas. |
|
|
static unsigned char * |
static unsigned char * |
nom_segment_semaphore(pid_t pid) |
nom_segment_semaphore(pid_t pid, int ordre) |
{ |
{ |
unsigned char *fichier; |
unsigned char *fichier; |
|
|
Line 38 nom_segment_semaphore(pid_t pid)
|
Line 38 nom_segment_semaphore(pid_t pid)
|
return(NULL); |
return(NULL); |
} |
} |
|
|
sprintf(fichier, "/RPL-SS-%d", (int) pid); |
sprintf(fichier, "/RPL-%d-%d", (int) pid, ordre); |
return(fichier); |
return(fichier); |
} |
} |
|
|
|
|
static unsigned char * |
static unsigned char * |
nom_segment_semaphore_thread(pid_t pid, pthread_t tid) |
nom_segment_semaphore_thread(pid_t pid, pthread_t tid, int ordre) |
{ |
{ |
unsigned char *fichier; |
unsigned char *fichier; |
|
|
Line 53 nom_segment_semaphore_thread(pid_t pid,
|
Line 53 nom_segment_semaphore_thread(pid_t pid,
|
return(NULL); |
return(NULL); |
} |
} |
|
|
sprintf(fichier, "/RPL-SS-%d-%llx", (int) pid, |
sprintf(fichier, "/RPL-%d-%llX-%d", (int) pid, |
(unsigned long long) tid); |
(unsigned long long) tid, ordre); |
return(fichier); |
return(fichier); |
} |
} |
|
|
Line 72 nom_segment_semaphore_thread(pid_t pid,
|
Line 72 nom_segment_semaphore_thread(pid_t pid,
|
*/ |
*/ |
|
|
sem_t * |
sem_t * |
sem_init2(unsigned int valeur, pid_t pid) |
sem_init2(unsigned int valeur, pid_t pid, int ordre) |
{ |
{ |
sem_t *semaphore; |
sem_t *semaphore; |
|
|
unsigned char *chemin; |
unsigned char *chemin; |
unsigned int i; |
|
|
|
if ((chemin = nom_segment_semaphore(pid)) == NULL) |
if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) |
{ |
{ |
return(SEM_FAILED); |
return(SEM_FAILED); |
} |
} |
Line 93 sem_init2(unsigned int valeur, pid_t pid
|
Line 92 sem_init2(unsigned int valeur, pid_t pid
|
|
|
|
|
sem_t * |
sem_t * |
sem_init3(unsigned int valeur, pid_t pid, pthread_t tid) |
sem_init3(unsigned int valeur, pid_t pid, pthread_t tid, int ordre) |
{ |
{ |
sem_t *semaphore; |
sem_t *semaphore; |
|
|
unsigned char *chemin; |
unsigned char *chemin; |
unsigned int i; |
|
|
|
if ((chemin = nom_segment_semaphore_thread(pid, tid)) == NULL) |
if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) |
{ |
{ |
return(SEM_FAILED); |
return(SEM_FAILED); |
} |
} |
Line 114 sem_init3(unsigned int valeur, pid_t pid
|
Line 112 sem_init3(unsigned int valeur, pid_t pid
|
|
|
|
|
sem_t * |
sem_t * |
sem_open2(pid_t pid) |
sem_open2(pid_t pid, int ordre) |
{ |
{ |
unsigned char *chemin; |
unsigned char *chemin; |
|
|
sem_t *semaphore; |
sem_t *semaphore; |
|
|
if ((chemin = nom_segment_semaphore(pid)) == NULL) |
if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) |
{ |
{ |
return(SEM_FAILED); |
return(SEM_FAILED); |
} |
} |
Line 133 sem_open2(pid_t pid)
|
Line 131 sem_open2(pid_t pid)
|
|
|
|
|
int |
int |
sem_destroy2(sem_t *semaphore, pid_t pid) |
sem_destroy2(sem_t *semaphore, pid_t pid, int ordre) |
{ |
{ |
int erreur; |
int erreur; |
|
|
Line 141 sem_destroy2(sem_t *semaphore, pid_t pid
|
Line 139 sem_destroy2(sem_t *semaphore, pid_t pid
|
|
|
sem_close(semaphore); |
sem_close(semaphore); |
|
|
if ((chemin = nom_segment_semaphore(pid)) == NULL) |
if ((chemin = nom_segment_semaphore(pid, ordre)) == NULL) |
{ |
{ |
return(1); |
return(1); |
} |
} |
Line 154 sem_destroy2(sem_t *semaphore, pid_t pid
|
Line 152 sem_destroy2(sem_t *semaphore, pid_t pid
|
|
|
|
|
int |
int |
sem_destroy3(sem_t *semaphore, pid_t pid, pthread_t tid) |
sem_destroy3(sem_t *semaphore, pid_t pid, pthread_t tid, int ordre) |
{ |
{ |
int erreur; |
int erreur; |
|
|
Line 162 sem_destroy3(sem_t *semaphore, pid_t pid
|
Line 160 sem_destroy3(sem_t *semaphore, pid_t pid
|
|
|
sem_close(semaphore); |
sem_close(semaphore); |
|
|
if ((chemin = nom_segment_semaphore_thread(pid, tid)) == NULL) |
if ((chemin = nom_segment_semaphore_thread(pid, tid, ordre)) == NULL) |
{ |
{ |
return(1); |
return(1); |
} |
} |
Line 299 sem_init_SysV(sem_t *semaphore, int shar
|
Line 297 sem_init_SysV(sem_t *semaphore, int shar
|
return(-1); |
return(-1); |
} |
} |
|
|
sprintf((*semaphore).path, "%s/RPL-SIGSEMAPHORE-%d-%llu", |
sprintf((*semaphore).path, "%s/RPL-SIGSEMAPHORE-%d-%llX", |
racine_segment, pthread_self(), |
racine_segment, pthread_self(), |
(int) getpid()); |
(int) getpid(), pthread_self()); |
|
|
if ((desc = open((*semaphore).path, O_RDWR | O_CREAT | O_EXCL, |
if ((desc = open((*semaphore).path, O_RDWR | O_CREAT | O_EXCL, |
S_IRUSR | S_IWUSR)) == -1) |
S_IRUSR | S_IWUSR)) == -1) |