Alarm signals during findClass

Bernie Solomon bernard at UG.EDS.COM
Wed Mar 12 04:55:09 PST 1997


I was having sporadic problems with crashes on my HP interpreter which
after some investigation I decided was due to alarm signals going off
during the system calls from findClass where classes are being loaded. I
think this was more likely to happen because I currently have the BISS
AWT classes in a directory structure rather than a ZIP file but it seems
possible on any machine not using mmap including for ZIP files. My quick
patch (below) is to disable interrupts for the whole of findClass which
currently seems to solve my problem.

What I am wondering is whether this a HP specific problem with my
threading or is a general problem? There is no check for EINTR in this
code so I would have thought this can happen elsewhere. But I am a bit
dubious of how well things stand up to having the thread switches in the
return from system call code (this is where alarm signals get handled as
I understand most kernels). I never actually saw a EINTR value when
things were failing but I wonder if thats because we have one errno for
all threads or that my thread switching doesn't work inside the alarm
signal handler inside the return from system call code (either is
possible). 

So is this a general problem or do other systems cope OK? I would have
thought with internal threads that alarm signals should actually be
blocked for all system calls and the system calls would be restarted for
EINTR. If the alarm goes off a flag could be set and the scheduling
could happen after the system call has been successfully processed. This
avoids doing a kaffe thread switch inside a system call.

Or am I completely misunderstanding things?

Also how is the interlocking supposed to work if two threads try and do
a findClass on the same class at the same time? Or is this all handled
up at a higher level inside Java code itself (I am in the learning stage
which is why I am looking at kaffe at all and don't understand much
yet).
-- 
Bernie Solomon (bernard at edsug.com or Bernard.Solomon at acm.org)
Unigraphics Architecture, EDS-Unigraphics, Cambridge, UK
-------------- next part --------------
*** findClass.c	Wed Mar 12 12:24:42 1997
--- /users/bernard/orig-kaffe-0.8.2/kaffe/kaffevm/findClass.c	Tue Mar  4 09:57:06 1997
***************
*** 27,33 ****
  #include "paths.h"
  #include "flags.h"
  #include "errors.h"
- #include "thread.h"
  
  #define	CLASSPATH1	"KAFFE_CLASSPATH"
  #define	CLASSPATH2	"CLASSPATH"
--- 27,32 ----
***************
*** 63,71 ****
  	int j;
  	/* Look for the class */
  CDBG(	printf("Scanning for class %s\n", cname);		)
- 
- 	intsDisable();
- 
  	for (i = 0; classpath[i].path != 0; i++) {
  		switch (classpath[i].type) {
  		case CP_FILE:
--- 62,67 ----
***************
*** 144,152 ****
  		default:
  			continue;
  		}
- 
- 		intsRestore();
- 
  		return (class);
  	}
  	/*
--- 140,145 ----
***************
*** 158,166 ****
  		fprintf(stderr, "Cannot find essential class '%s' in class library ... aborting.\n", cname);
  		abort();
  	}
- 
- 	intsRestore();
- 
  	return (0);
  }
  
--- 151,156 ----


More information about the kaffe mailing list