Modification to thread.h for making kaffe work on ARM

antonio at golia.iet.unipi.it antonio at golia.iet.unipi.it
Tue Mar 11 05:23:00 PST 1997


The thread.h and thread.s I sent only works modifying the order of some members in ctx and 
thread structures. I've done this to facilitate access to those members from asm routines.
Here follows the modified file:

/*
 * thread.h
 * Thread support.
 */

#ifndef __thread_h
#define __thread_h

#include "int64.h"

#define	THREADCLASS			"java/lang/Thread"
#define	THREADGROUPCLASS		"java/lang/ThreadGroup"
#define	THREADDEATHCLASS		"java/lang/ThreadDeath"

#define	MIN_THREAD_PRIO			1
#define	NORM_THREAD_PRIO		5
#define	MAX_THREAD_PRIO			10

#define	THREAD_SUSPENDED		0
#define	THREAD_RUNNING			1
#define	THREAD_DEAD			2

#define	THREAD_FLAGS_GENERAL		0
#define	THREAD_FLAGS_NOSTACKALLOC	1
#define	THREAD_FLAGS_KILLED		2
#define	THREAD_FLAGS_ALARM		4
#define	THREAD_FLAGS_USERSUSPEND	8
#define	THREAD_FLAGS_ERROR		16

#define	NOTIMEOUT			ll_zero_const() /* 
Originally 0 */

struct _thread;

/* Positions of members has been changed as to facilitate access from
   asm routines. In particular restorePoint has been set at offset 0,
   stackEnd at offset 4, stackBase at offset 8 and flags at offset 12 */
typedef struct _ctx {
	uint8*			restorePoint;
	uint8*			stackEnd;
	uint8*			stackBase;
	uint8			flags;		
	
	uint8			status;
	uint8			priority;
	jlong			time;
	struct _thread*		nextlive;
	struct _thread*		nextalarm;
	struct _thread**	blockqueue;
	void*			exceptPtr;
} ctx;

#define MAXTCTX 256

extern ctx** threadContext;
#define TCTX(t)         (threadContext[(t)->PrivateInfo])

struct _stringClass;
struct _object;

/* This structure mirrors java.lang.ThreadGroup.h */
typedef struct _threadGroup {
	struct _object		obj;
	struct _threadGroup*	parent;
	struct _object*		name;
	jint			maxPrio;
	jint			destroyed;
	jint			daemon;
	jint			nthreads;
	struct _object*		threads;
	jint			ngroups;
	struct _object*		groups;
} threadGroup;

/* This structure mirrors java.lang.Thread.h */
/* The member PrivateInfo has been moved at offset 0 to facilitate
   access from asm modules. */
typedef struct _thread {
	jint			PrivateInfo;
	struct _object		obj;
	struct _object*		name;
	jint			priority;
	struct _thread*		next;	
	jint			eetop;
	jint			single_step;
	jint			daemon;
	jint			stillborn;
	struct _object*		target;
	jint			interruptRequested;
	threadGroup*		group;
} thread;

void initThreads(void);
void startThread(thread*);
void resumeThread(thread*);
void iresumeThread(thread*);
void suspendThread(thread*);
void suspendOnQThread(thread*, thread**, jlong);
void yieldThread(void);
void killThread(void);
void setPriorityThread(thread*, int);
int blockOnFile(int, int);

void sleepThread(jlong);
bool aliveThread(thread*);
long framesThread(thread*);

void reschedule(void);
void freeThreadCtx(int);

extern int blockInts;
extern int threadStackSize;
extern bool needReschedule;

#define	intsDisable()	blockInts++
#define	intsRestore()	if ((blockInts == 1) && (needReschedule == true)) {	\
				reschedule();		
		\
			}			
			\
			blockInts--

/* Flags used for threading I/O calls */
#define	TH_READ		0
#define	TH_WRITE	1

#endif



More information about the kaffe mailing list