9 #define ldnode(addr) ((word) (addr & 0xFF))
10 #define ldpix(addr) ((word) ((addr >> 8) & 0xFF))
11 #define staddr(node, pix) ((word) ((pix << 8) | node))
15 These are converters from global to process pointers in memory
16 to global process pointers in message.
17 M denotes memory in which pair (pointer,object) exists or has to exist.
18 We want to create object denoting remote process instead of
19 dummy pointer without object.
20 The object will be like an arrayof integer of size 2.
21 arr[1..3] : arr[1]=node, arr[2]=pix.
24 void obj2mess(M,obj,mess)
31 if( obj->mark != M[obj->addr+1] ){
42 mess->node=ldnode(obj->addr);
43 mess->pix =ldpix (obj->addr);
48 void mess2obj(p,mess,obj)
60 extern int compactify_allowed;
65 newarry(1,4,APROCESS,obj,&am);
76 obj->addr=staddr(mess->node,mess->pix);
85 bool isprocess(v) virtaddr *v; {
90 /*assert(v->mark<=M[v->addr+1]);*/
91 if( v->mark!=M[v->addr+1] ) { return 0;}
92 else { return ( M[am+1]==APROCESS );}
96 return ( v->mark < 0 );
106 /* hash entry is a word pointing to dictionary or 0 if empty */
108 #ifndef NO_PROTOTYPES
109 static int hash_check_item( word, procaddr * );
110 static void hash_new_item( virtaddr *, procaddr * );
111 static int hash_mess( procaddr * );
112 static int hash_2( int );
114 static int hash_check_item();
115 static void hash_new_item();
118 void hash_create(p,size) procdescr *p; int size;{
119 /* create hash table for p process */
121 if( p->hash!=NULL ) free( p->hash );
123 p->hash = mallocate(size);
124 if( p->hash==NULL ) errsignal(RTEMEMOV);
125 for( i=0; i<p->hash_size; i++ ) p->hash[i]=0;
129 /* find pointer in hash table, add if not exists */
131 void hash_find(mess,obj) procaddr *mess; virtaddr *obj; {
134 first=hash_mess( mess );
136 for( i=first; thisp->hash[i]!=0; ){
137 if( hash_check_item(thisp->hash[i],mess) ){
138 obj->addr=thisp->hash[i];
139 obj->mark=M[thisp->hash[i]+1];
142 i=(i+jump)%thisp->hash_size;
144 int *curhash=thisp->hash;
145 int cursize=thisp->hash_size;
146 errsignal(RTEMEMOV); /* the rest is not debugged yet */
147 thisp->hash_size = cursize*3-1;
148 thisp->hash = mallocate(thisp->hash_size);
149 if( thisp->hash==NULL ) errsignal(RTEMEMOV);
150 for( i=0; i<thisp->hash_size; i++ ) thisp->hash[i]=0;
151 for( i=0; i<cursize; i++ ){
156 obj.mark=M[curhash[i]+1];
157 obj2mess(M,&obj,&mess);
158 hash_set(&mess,curhash[i]);
161 hash_new_item( obj, mess );
162 hash_set( mess, obj->addr );
167 hash_new_item( obj, mess );
168 thisp->hash[i]=obj->addr;
171 void hash_set(mess,ah) procaddr *mess; word ah;{
174 first=hash_mess( mess );
176 for( i=first; thisp->hash[i]!=0; ){
177 assert( !hash_check_item(thisp->hash[i],mess) );
178 i=(i+jump)%thisp->hash_size;
179 if( i==first ) errsignal(RTEMEMOV);
182 assert( thisp->hash[i]==0 );
189 static int hash_check_item( ah, mess ) word ah; procaddr *mess; {
191 return ( mess->node==M[am+2] && mess->pix==M[am+3] && mess->mark==M[am+4] );
194 static void hash_new_item( obj, mess ) virtaddr *obj; procaddr *mess; {
196 newarry(1,4,APROCESS,obj,&am);
202 static int hash_mess( mess ) procaddr *mess;{
204 hash *= abs( mess->mark );
206 return hash % (thisp->hash_size);
209 static int hash_2( hash_1 ) int hash_1;{
210 return thisp->hash_size -2 - ( hash_1 % ( thisp->hash_size -2 ) );