Download SUN User`s Guide
Transcript
29
USING TIlE SUN PROCESSOR
possible for the kernel to simply switch contexts before changing the segment map; this operation must be
done by code running entirely in ROM and processor registers. The memory management EMTs provide this
service. Notc that it is essential that the context register not be changed except via the EMT described below.
short emt~ getsegmap(cxt,segno)
int ext;
int segoo;
Returns the contents of segment map entry number s e 9 n0 in context nUlnber ex t.
setsegmap(cxt,segno,entry)
int cxt;
int segoo;
short entry;
emt~
Sets segment map entry number s ego 0 in context number cx t to en try.
int
geteontext()
Returns the current value of the context register.
emt~
emt~ setcontext(ext)
int ext;
Sets the context register to ex t.
Here is an example of the use of the emt .... ticks global to derive an accurate
timer~
counting seconds.
(Warning: a previous version of this example contained a program logic error that rendered it inaccurate!)
maine)
{
long NextTick;
long ThisTick;
long seconds = 0;
1* value of RefrCnt at next second *1
1* temporary; used to avoid a race *1
ThisTick = emtlicks{); 1* initialize loop invariant *1
for (;:) {
printf("Time is %d\n".seconds++);
NextTick = ThisTick + 1000:
1* predict next second *1
while ( ThisTick < NextTick)
1* busy-wait *1
ThisTick = emt_ticks();
}
}
11 DECEMBER 1981