eaangi77
03-10-2007, 20:00
Ciao scusate il disturbo ho un problema,
ho un processo addormentato con pause() che ha creato 4 thread , vorrei risvegliarlo ma utilizzando kill(0,0) non funziona.
Qualcuno può aiutarmi grazie.
Posto il codice.
void controllore(){
while ("true"){
msgrcv (ID_CODA, &messaggio_ricevuto, 5, 1 , MSG_NOERROR );
if (messaggio_ricevuto.mtext == 0){
printf("CONTROLORE SVEGLIA IL CUOCO \n");
raise(SIGUSR1);
}
}
}
static void gestioneSegnali(int segnale){
printf("SEGNALE CATTURATO");
segnalep = 1;
return ;
}
int main() {
ipc_key_coda = ftok(".", 'a');
ID_CODA = msgget(3, IPC_CREAT | 0600);
ipc_key = 1;
sem_id_camerieri = MutexCreate(ipc_key);
f_lettura_portate_ordinate = fopen ( "./portateOrdinate" , "r" );
signal(SIGUSR1,gestioneSegnali);
do{
if (f_lettura_portate_ordinate){
if (!feof(f_lettura_portate_ordinate)){
printf("Portata Lavorata: %s \n", &portata);
printf("\n");
fgets(&portata, 50, f_lettura_portate_ordinate);
sleep(2);
}else{
printf("ADDORMENTA CUOCO \n");
while (segnalep==0) ; //pause(); Pause non risvegliato dal segnale!!! Problema con i thread
printf("CUOCO SVEGLIATO\n");
segnalep=0;
fgets(&portata, 50, f_lettura_portate_ordinate);
}
} else {
printf("ERRORE NELL'APERTURA DEL FILE \n");
}
}while ("true");
printf("TERMINE CUOCO \n");
fclose(f_lettura_portate_ordinate);
return 0;
}
ho un processo addormentato con pause() che ha creato 4 thread , vorrei risvegliarlo ma utilizzando kill(0,0) non funziona.
Qualcuno può aiutarmi grazie.
Posto il codice.
void controllore(){
while ("true"){
msgrcv (ID_CODA, &messaggio_ricevuto, 5, 1 , MSG_NOERROR );
if (messaggio_ricevuto.mtext == 0){
printf("CONTROLORE SVEGLIA IL CUOCO \n");
raise(SIGUSR1);
}
}
}
static void gestioneSegnali(int segnale){
printf("SEGNALE CATTURATO");
segnalep = 1;
return ;
}
int main() {
ipc_key_coda = ftok(".", 'a');
ID_CODA = msgget(3, IPC_CREAT | 0600);
ipc_key = 1;
sem_id_camerieri = MutexCreate(ipc_key);
f_lettura_portate_ordinate = fopen ( "./portateOrdinate" , "r" );
signal(SIGUSR1,gestioneSegnali);
do{
if (f_lettura_portate_ordinate){
if (!feof(f_lettura_portate_ordinate)){
printf("Portata Lavorata: %s \n", &portata);
printf("\n");
fgets(&portata, 50, f_lettura_portate_ordinate);
sleep(2);
}else{
printf("ADDORMENTA CUOCO \n");
while (segnalep==0) ; //pause(); Pause non risvegliato dal segnale!!! Problema con i thread
printf("CUOCO SVEGLIATO\n");
segnalep=0;
fgets(&portata, 50, f_lettura_portate_ordinate);
}
} else {
printf("ERRORE NELL'APERTURA DEL FILE \n");
}
}while ("true");
printf("TERMINE CUOCO \n");
fclose(f_lettura_portate_ordinate);
return 0;
}