--- rpl/src/Attic/siginfo.c 2010/09/02 07:51:48 1.4 +++ rpl/src/Attic/siginfo.c 2010/09/06 16:50:17 1.5 @@ -30,13 +30,20 @@ static int *fifos; static int markov; -static int segment; static sem_t *semaphores[nombre_queues]; static sem_t *semaphore_global; #ifdef IPCS_SYSV +#ifndef OS2 static unsigned char *chemin = NULL; #endif +#endif + +#ifdef OS2 +PVOID ptr_os2; +#else +static int segment; +#endif static unsigned char * nom_segment(unsigned char *chemin, pid_t pid) @@ -44,6 +51,9 @@ nom_segment(unsigned char *chemin, pid_t unsigned char *fichier; # ifdef IPCS_SYSV + +# ifndef OS2 + if ((fichier = malloc((strlen(chemin) + 1 + 256 + 1) * sizeof(unsigned char))) == NULL) { @@ -51,7 +61,19 @@ nom_segment(unsigned char *chemin, pid_t } sprintf(fichier, "%s/RPL-SIGQUEUES-%d", chemin, (int) pid); + +# else + + if ((fichier = malloc((10 + 256 + 1) * sizeof(unsigned char))) == NULL) + { + return(NULL); + } + + sprintf(fichier, "\\SHAREMEM\\RPL-SIGQUEUES-%d", (int) pid); + +# endif # else + if ((fichier = malloc((1 + 256 + 1) * sizeof(unsigned char))) == NULL) { @@ -59,6 +81,7 @@ nom_segment(unsigned char *chemin, pid_t } sprintf(fichier, "/RPL-SIGQUEUES-%d", (int) pid); + # endif return(fichier); @@ -74,7 +97,7 @@ nom_semaphore(pid_t pid, int queue) return(NULL); } - sprintf(fichier, "/RPL-SIGESMAPHORES-%d-%d", (int) pid, queue); + sprintf(fichier, "/RPL-SIGSEMAPHORES-%d-%d", (int) pid, queue); return(fichier); } @@ -174,6 +197,7 @@ creation_fifos_signaux(struct_processus free(nom); # else // SystemV +# ifndef OS2 file *desc; @@ -228,6 +252,27 @@ creation_fifos_signaux(struct_processus return; } +# else + + if ((nom = nom_segment(NULL, getpid())) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + if (DosAllocSharedMem(&ptr_os2, nom, nombre_queues * + ((2 * longueur_queue) + 4) * sizeof(int), + PAG_WRITE | PAG_READ | PAG_COMMIT) != 0) + { + free(nom); + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + free(nom); + fifos = ptr_os2; + +# endif # endif /* @@ -301,6 +346,7 @@ liberation_fifos_signaux(struct_processu int i; # ifdef IPCS_SYSV // SystemV +# ifndef OS2 if (shmdt(fifos) == -1) { @@ -308,6 +354,15 @@ liberation_fifos_signaux(struct_processu return; } +# else + + if (DosFreeMem(fifos) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + +# endif # else // POSIX if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)) @@ -345,6 +400,7 @@ destruction_fifos_signaux(struct_process unsigned char *nom; # ifdef IPCS_SYSV // SystemV +# ifndef OS2 if (shmdt(fifos) == -1) { @@ -368,6 +424,15 @@ destruction_fifos_signaux(struct_process unlink(nom); free(nom); +# else + + if (DosFreeMem(fifos) != 0) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + +# endif # else // POSIX if (munmap(fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)) @@ -448,7 +513,9 @@ queue_in(pid_t pid, int signal) int *base; int *buffer; int horodatage_initial; +# ifndef OS2 int identifiant; +# endif int *projection_fifos; sem_t *semaphore; @@ -502,9 +569,18 @@ queue_in(pid_t pid, int signal) # else // Traitement à l'aide d'IPCS SystemV +# ifndef OS2 key_t clef; struct stat s_stat; +# endif + + // Dans le cas de SIGSTART, premier signal envoyé à un processus fils, + // il convient d'attendre que le fichier support soit effectivement + // accessible. Dans tous les autres cas, ce fichier doit exister. S'il + // n'existe plus, le processus associé n'existe plus. + +# ifndef OS2 // Ouverture des projections @@ -513,11 +589,6 @@ queue_in(pid_t pid, int signal) return(-1); } - // Dans le cas de SIGSTART, premier signal envoyé à un processus fils, - // il convient d'attendre que le fichier support soit effectivement - // accessible. Dans tous les autres cas, ce fichier doit exister. S'il - // n'existe plus, le processus associé n'existe plus. - if (signal == SIGSTART) { // On attend que le fichier sois présent @@ -563,13 +634,51 @@ queue_in(pid_t pid, int signal) return(-1); } +# else + + // Ouverture des projections + + if ((nom = nom_segment(NULL, pid)) == NULL) + { + return(-1); + } + + if (signal == SIGSTART) + { + horodatage_initial = horodatage(); + + while(DosGetNamedSharedMem(&ptr_os2, nom, + PAG_READ | PAG_WRITE | PAG_COMMIT) != 0) + { + if (abs(horodatage_initial - horodatage()) > 500) + { + return(-1); + } + } + } + else + { + if (DosGetNamedSharedMem(&ptr_os2, nom, + PAG_READ | PAG_WRITE) != 0) + { + return(-1); + } + } + + projection_fifos = ptr_os2; + +# endif # endif if ((nom = nom_semaphore(pid, queue)) == NULL) { # ifdef IPCS_SYSV +# ifndef OS2 shmdt(projection_fifos); # else + DosFreeMem(projection_fifos); +# endif +# else munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)); # endif @@ -584,8 +693,12 @@ queue_in(pid_t pid, int signal) if (errno != EINTR) { # ifdef IPCS_SYSV +# ifndef OS2 shmdt(projection_fifos); # else + DosFreeMem(projection_fifos); +# endif +# else munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)); # endif @@ -603,8 +716,12 @@ queue_in(pid_t pid, int signal) sem_post(semaphore); sem_close(semaphore); # ifdef IPCS_SYSV +# ifndef OS2 shmdt(projection_fifos); # else + DosFreeMem(projection_fifos); +# endif +# else munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)); # endif @@ -622,8 +739,12 @@ queue_in(pid_t pid, int signal) if (sem_post(semaphore) != 0) { # ifdef IPCS_SYSV +# ifndef OS2 shmdt(projection_fifos); # else + DosFreeMem(projection_fifos); +# endif +# else munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)); # endif @@ -635,8 +756,12 @@ queue_in(pid_t pid, int signal) // Fermeture des projections # ifdef IPCS_SYSV +# ifndef OS2 shmdt(projection_fifos); # else + DosFreeMem(projection_fifos); +# endif +# else munmap(projection_fifos, nombre_queues * ((2 * longueur_queue) + 4) * sizeof(int)); # endif