--- rpl/src/interruptions.c 2011/10/05 13:14:19 1.83 +++ rpl/src/interruptions.c 2012/05/16 14:45:25 1.95 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.4 - Copyright (C) 1989-2011 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.8 + Copyright (C) 1989-2012 Dr. BERTRAND Joël This file is part of RPL/2. @@ -64,6 +64,28 @@ unsigned char *racine_segment; static pthread_mutex_t mutex_interruptions = PTHREAD_MUTEX_INITIALIZER; +void * +thread_surveillance_signaux(void *argument) +{ + // Chaque kill() ou pthread_kill() incrémente le sémaphore. Lorsque le + // sémaphore est déverrouillé, on part dans un timeout. + // while(sem_wait()) + // { + // nanosleep(); + // if (errno == EINTR) + // { + // continue; + // } + // + // if (sem_trywait() != 0) + // { + // sem_post() + // kill() + // } + // } + pthread_exit(NULL); +} + void modification_pid_thread_pere(struct_processus *s_etat_processus) { @@ -1772,7 +1794,6 @@ interruption3(int signal) kill(pid_processus_pere, SIGUSR1); } - if (signal != SIGUSR2) { write(STDERR_FILENO, message_1, strlen(message_1)); @@ -1828,7 +1849,7 @@ interruption_violation_access(void *adre unsigned char message[] = "+++System : Trying to catch access " "violation\n"; - static int compteur_erreur = 0; + static int compteur_erreur = 0; if ((gravite == 0) && (routine_recursive != 0)) { @@ -1935,13 +1956,6 @@ signal_stop(struct_processus *s_etat_pro if (pid == getpid()) { - if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) - == NULL) - { - deverrouillage_gestionnaire_signaux(s_etat_processus); - return; - } - if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) { printf("[%d] RPL/SIGSTOP (thread %llu)\n", (int) getpid(), @@ -2033,13 +2047,6 @@ signal_urg(struct_processus *s_etat_proc if (pid == getpid()) { - if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) - == NULL) - { - deverrouillage_gestionnaire_signaux(s_etat_processus); - return; - } - if (((*s_etat_processus).type_debug & d_debug_signaux) != 0) { printf("[%d] RPL/SIGURG (thread %llu)\n", (int) getpid(), @@ -2089,13 +2096,6 @@ signal_abort(struct_processus *s_etat_pr if (pid == getpid()) { - if ((s_etat_processus = recherche_thread(getpid(), pthread_self())) - == NULL) - { - deverrouillage_gestionnaire_signaux(s_etat_processus); - return; - } - (*s_etat_processus).arret_depuis_abort = -1; /* @@ -2296,7 +2296,7 @@ scrutation_interruptions(struct_processu if (sem_trywait(semaphore_queue_signaux) == 0) # endif { - if ((*s_queue_signaux).pointeur_lecture != + while((*s_queue_signaux).pointeur_lecture != (*s_queue_signaux).pointeur_ecriture) { // Il y a un signal en attente dans le segment partagé. On le @@ -2322,7 +2322,7 @@ scrutation_interruptions(struct_processu if (pthread_mutex_trylock(&mutex_interruptions) == 0) { - if ((*s_etat_processus).pointeur_signal_lecture != + while((*s_etat_processus).pointeur_signal_lecture != (*s_etat_processus).pointeur_signal_ecriture) { // Il y a un signal dans la queue du thread courant. On le traite. @@ -2362,6 +2362,7 @@ nom_segment(unsigned char *chemin, pid_t # ifdef IPCS_SYSV // !POSIX # ifndef OS2 // !OS2 + if ((fichier = malloc((strlen(chemin) + 1 + 256 + 1) * sizeof(unsigned char))) == NULL) { @@ -2620,6 +2621,8 @@ envoi_signal_processus(pid_t pid, enum s # endif } + kill(pid, SIGALRM); + return(0); } @@ -2683,6 +2686,8 @@ envoi_signal_thread(pthread_t tid, enum return(1); } + pthread_kill(tid, SIGALRM); + return(0); } @@ -2699,6 +2704,8 @@ envoi_signal_contexte(struct_processus * % LONGUEUR_QUEUE_SIGNAUX; pthread_mutex_unlock(&mutex_interruptions); + pthread_kill((*s_etat_processus_a_signaler).tid, SIGALRM); + return(0); }