lost SIGALRM in RedHat Linux 5.0, kernel 2.0.32

Mihai Surdeanu mihai at seas.smu.edu
Mon Jan 4 11:48:48 PST 1999


I noticed the following unwanted effect while working on a project with
kaffe under Linux 2.0.32:

If SIGIO arrives while KVM is handling SIGALRM, the SIGALRM handler is
preempted and NEVER restored. The overall effect is that the "alarmList"
is not empty but there is no timer set, thus the threads in the alarm list
may potentially sleep for ever.

I'm not a linux guru so I don't know if this is normal (as far as I know
Linux provides reliable signals) or if it happens for other signals as
well. Nevertheless, the attached patch solved the problem for my
application. diff was applied to the "unix-jthreads" and "kaffevm" folder
of yesterday's (1/3/99) snap.
The patch checks for a set timer if alarmList is not empty before any
SIGIO. I used "getitimer" to do this, so probably it's not portable on all
Unix flavour's.

Regards,
Mihai Surdeanu

-------------- next part --------------
diff -c kaffevm/systems/unix-jthreads/jthread.c kaffevm-orig/systems/unix-jthreads/jthread.c
*** kaffevm/systems/unix-jthreads/jthread.c	Mon Jan  4 13:10:31 1999
--- kaffevm-orig/systems/unix-jthreads/jthread.c	Sun Jan  3 21:19:02 1999
***************
*** 654,672 ****
  }
  #endif DEBUG
  
- /*
-  * Recover a lost SIGALRM
-  */
- static void recover_lost_alarm(void)
- {
-   jlong time;
- 	
-   if(alarmList != 0 && alarm_is_set() == 0){
-     time = alarmList->time - currentTime();
-     if(time <= 0) time = 10;
-     MALARM(time);
-   }
- }
  
  /*
   * handle an interrupt.
--- 654,659 ----
***************
*** 697,703 ****
  		break;
  
  	case SIGIO:
- 		recover_lost_alarm();
  		handleIO(false);
  		break;
  
--- 684,689 ----
-------------- next part --------------
diff -c kaffevm/exception.c kaffevm-orig/exception.c
*** kaffevm/exception.c	Mon Jan  4 11:35:05 1999
--- kaffevm-orig/exception.c	Sun Jan  3 21:19:01 1999
***************
*** 64,87 ****
  static bool findExceptionBlockInMethod(uintp, Hjava_lang_Class*, Method*, exceptionInfo*);
  
  /*
-  * Returns 0 if there is no alarm set, 
-  * or the time in ms until the next alarm
-  */
- long alarm_is_set(void)
- {
-   long to;
-   struct itimerval tv;
- 
-   if(getitimer(ITIMER_REAL, & tv) < 0){
-     perror("getitimer");
-     exit(1);
-   }
- 
-   to = (tv.it_value.tv_sec * 1000) + (tv.it_value.tv_usec / 1000);
-   return to;
- }
- 
- /*
   * Throw an internal exception.
   */
  void
--- 64,69 ----
diff -c kaffevm/exception.h kaffevm-orig/exception.h
*** kaffevm/exception.h	Mon Jan  4 11:34:20 1999
--- kaffevm-orig/exception.h	Sun Jan  3 21:19:01 1999
***************
*** 53,60 ****
  extern void initExceptions(void);
  extern void catchSignal(int, void*);
  
- extern long alarm_is_set(void);
- 
  #if defined(__WIN32__)
  #define SIG_T   void(*)()
  #else
--- 53,58 ----
Common subdirectories: kaffevm/intrp and kaffevm-orig/intrp
Common subdirectories: kaffevm/jit and kaffevm-orig/jit
Common subdirectories: kaffevm/mem and kaffevm-orig/mem
Common subdirectories: kaffevm/systems and kaffevm-orig/systems


More information about the kaffe mailing list