TempleOSCD_150720.ISO
This commit is contained in:
1 parent
401601816c
commit
f8c05f98f4
554 files changed
+26046
-24853
No files matched your search
@@ -6,34 +6,34 @@ U0 TimeIns()
|
||||
{
|
||||
I64 start1,end1,start2,end2,overhead_time,test_time;
|
||||
I64 reg i,reg temp;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
CPURep;
|
||||
|
||||
//Measure Loop Overhead
|
||||
//Measure Loop Overhead
|
||||
start1=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++) {
|
||||
}
|
||||
end1=GetTSC;
|
||||
overhead_time=end1-start1;
|
||||
|
||||
//Measure remainder...
|
||||
//Measure remainder...
|
||||
start2=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
temp=i%0x400;
|
||||
temp=i%0x400;
|
||||
end2=GetTSC;
|
||||
test_time=end2-start2;
|
||||
"Remainder Version #1 Cycles\t: %10.5f\n",
|
||||
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
||||
|
||||
//Measure remainder...
|
||||
//Measure remainder...
|
||||
start2=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
temp=i&0x3FF;
|
||||
temp=i&0x3FF;
|
||||
end2=GetTSC;
|
||||
test_time=end2-start2;
|
||||
"Remainder Version #2 Cycles\t: %10.5f\n",
|
||||
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time-overhead_time)/SAMPLE_SIZE;
|
||||
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ U0 DoIt2()
|
||||
"i&0xFFFFFFFF=%X\n",i&0xFFFFFFFF;
|
||||
"i>>32 =%X\n",i>>32;
|
||||
|
||||
/* Standard integer types are declared
|
||||
with a special compiler feature which
|
||||
allows a structure to be accessed as a
|
||||
whole. That's why the i variable can
|
||||
be accessed normally in addition to
|
||||
structure member access $LK,"I64",A="MN:I64"$. The actual
|
||||
intrinsic compiler type is U64i.
|
||||
/* Standard integer types are declared
|
||||
with a special compiler feature which
|
||||
allows a structure to be accessed as a
|
||||
whole. That's why the i variable can
|
||||
be accessed normally in addition to
|
||||
structure member access $LK,"I64",A="MN:I64"$. The actual
|
||||
intrinsic compiler type is U64i.
|
||||
|
||||
public U64i union I64
|
||||
{
|
||||
@@ -65,10 +65,10 @@ public U64i union I64
|
||||
U32 u32[2];
|
||||
};
|
||||
|
||||
It's not quite as great as it seems
|
||||
because the compiler decides it cannot
|
||||
place i into a reg, so there is a
|
||||
penalty.
|
||||
It's not quite as great as it seems
|
||||
because the compiler decides it cannot
|
||||
place i into a reg, so there is a
|
||||
penalty.
|
||||
|
||||
For a complete lst of nonstandard compiler
|
||||
features, see $LK,"::/Doc/HolyC.TXT"$.
|
||||
|
||||
@@ -78,7 +78,7 @@ U0 Main()
|
||||
I64 start,end,overhead_time,test_time;
|
||||
F64 d1,fsum;
|
||||
I64 reg i,temp,reg d2,reg sum;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
CPURep;
|
||||
|
||||
@@ -86,18 +86,18 @@ U0 Main()
|
||||
for (i=0;i<65536;i++)
|
||||
coordinates[i]=RandU32;
|
||||
|
||||
//Measure Loop Overhead
|
||||
//Measure Loop Overhead
|
||||
start=GetTSC;
|
||||
for (i=SAMPLE_SIZE-1;i>=0;i--) {
|
||||
}
|
||||
end=GetTSC;
|
||||
overhead_time=end-start;
|
||||
"$$RED$$Overhead Cycles :%10.5f$$FG$$\n",
|
||||
ToF64(overhead_time)/SAMPLE_SIZE;
|
||||
ToF64(overhead_time)/SAMPLE_SIZE;
|
||||
|
||||
//Measure F64 arithmetic
|
||||
// (Some of this is due to crappy
|
||||
// compiler code.)
|
||||
//Measure F64 arithmetic
|
||||
// (Some of this is due to crappy
|
||||
// compiler code.)
|
||||
d1=Sin(1.0);
|
||||
fsum=0;
|
||||
start=GetTSC;
|
||||
@@ -107,39 +107,39 @@ U0 Main()
|
||||
test_time=end-start;
|
||||
"Float Sum :%X\n",ToI64(fsum);
|
||||
"$$RED$$Float Cycles :%10.5f$$FG$$\n",
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
|
||||
//Measure fixed point arithmetic
|
||||
//Measure fixed point arithmetic
|
||||
d2=Sin(1.0)*0x100000000;
|
||||
sum=0;
|
||||
start=GetTSC;
|
||||
for (i=SAMPLE_SIZE-1;i>=0;i--) {
|
||||
temp=d2*coordinates[i&65535];
|
||||
temp=d2*coordinates[i&65535];
|
||||
sum+=temp.i32[1];
|
||||
}
|
||||
end=GetTSC;
|
||||
test_time=end-start;
|
||||
"Fixed-Point Sum :%X\n",sum;
|
||||
"$$RED$$Fixed-Point Cycles :%10.5f$$FG$$\n",
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
|
||||
//Measure fixed point arithmetic
|
||||
//Measure fixed point arithmetic
|
||||
start=GetTSC;
|
||||
sum=AsmFixedPt;
|
||||
end=GetTSC;
|
||||
test_time=end-start;
|
||||
"Asm Fixed-Point Sum :%X\n",sum;
|
||||
"$$RED$$Asm Fixed-Point Cycles:%10.5f$$FG$$\n",
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
|
||||
//Measure float arithmetic
|
||||
//Measure float arithmetic
|
||||
start=GetTSC;
|
||||
sum=AsmFloat;
|
||||
end=GetTSC;
|
||||
test_time=end-start;
|
||||
"Asm Float Sum :%X\n",sum;
|
||||
"$$RED$$Asm Float Cycles :%10.5f$$FG$$\n",
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
ToF64(test_time)/SAMPLE_SIZE;
|
||||
|
||||
Preempt(old_preempt);
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ U0 GrDemo()
|
||||
{
|
||||
I64 i;
|
||||
F64 t;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
CPURep;
|
||||
for (i=0;i<16;i++) {
|
||||
t=VGAPattern(0x5555555555555555);
|
||||
"$$GREEN$$Rate:$$RED$$%5.1f FPS$$FG$$"
|
||||
" $$GREEN$$Load@30Hz:$$RED$$%5.1f%%$$FG$$\n",1/t,100*t*30.0;
|
||||
" $$GREEN$$Load@30Hz:$$RED$$%5.1f%%$$FG$$\n",1/t,100*t*30.0;
|
||||
t=VGAPattern(0x3333333333333333);
|
||||
"$$GREEN$$Rate:$$RED$$%5.1f FPS$$FG$$"
|
||||
" $$GREEN$$Load@30Hz:$$RED$$%5.1f%%$$FG$$\n",1/t,100*t*30.0;
|
||||
" $$GREEN$$Load@30Hz:$$RED$$%5.1f%%$$FG$$\n",1/t,100*t*30.0;
|
||||
}
|
||||
Preempt(old_preempt);
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
|
||||
@@ -55,22 +55,22 @@ U0 TimeIns()
|
||||
{
|
||||
I64 start,end;
|
||||
I64 i,old_irq;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
CPURep;
|
||||
old_irq=IntEntrySet(I_F_UNARY_MINUS,F_UNARY_MINUS_INT,IDTET_TRAP);
|
||||
|
||||
//Measure interrupt time
|
||||
//Measure interrupt time
|
||||
start=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
UnaryMinusInt(ã);
|
||||
UnaryMinusInt(ã);
|
||||
end=GetTSC;
|
||||
"Interrupt Cycles: %10.5f\n",ToF64(end-start)/SAMPLE_SIZE;
|
||||
|
||||
//Measure call time
|
||||
//Measure call time
|
||||
start=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
UnaryMinusCall(ã);
|
||||
UnaryMinusCall(ã);
|
||||
end=GetTSC;
|
||||
"Call Cycles: %10.5f\n",ToF64(end-start)/SAMPLE_SIZE;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ The main compiler generates $LK,"Intermediate Code",A="FF:::/Compiler/CompilerA.
|
||||
|
||||
The main compiler optimizes See $LK,"Intermediate Code Attributes",A="MN:intermediate_code_table"$, $LK,"Combining Consts",A="FF:::/Compiler/OptPass012.CPP,case IC_MUL"$, $LK,"Choosing Reg Vars",A="FF:::/Compiler/OptPass3.CPP,cmp.num_reg_vars"$. Set $LK,"OTrace",A="MN:OTrace"$(ON) to see the optimization stages.
|
||||
|
||||
The main compiler makes machine code in the back end. See $LK,"IC Struct",A="MN:CIntermediateCode"$, $LK,"LCCCompile",A="MN:LCCCompile"$ and $LK,"OptPass789A",A="FF:::/Compiler/OptPass789A.CPP,IC_MUL"$(), $LK,"BackEnd",A="FF:::/Compiler/BackA.CPP,ICMul"$. Set $LK,"CTrace",A="MN:CTrace"$(ON) to see the output of the backend.
|
||||
The main compiler makes machine code in the back end. See $LK,"IC Struct",A="MN:CIntermediateCode"$, $LK,"COCCompile",A="MN:COCCompile"$ and $LK,"OptPass789A",A="FF:::/Compiler/OptPass789A.CPP,IC_MUL"$(), $LK,"BackEnd",A="FF:::/Compiler/BackA.CPP,ICMul"$. Set $LK,"CTrace",A="MN:CTrace"$(ON) to see the output of the backend.
|
||||
$ID,-2$
|
||||
$TR,"Mini Compiler"$
|
||||
$ID,2$For this mini compiler, some things you should know about 64-bit asm:
|
||||
@@ -198,14 +198,14 @@ U0 Main()
|
||||
{
|
||||
U8 *src,*src2,*code,*dst;
|
||||
|
||||
//Fixed size, no buffer overrun check.
|
||||
//You can make it fancier if you like.
|
||||
//Fixed size, no buffer overrun check.
|
||||
//You can make it fancier if you like.
|
||||
code=MAlloc(512,Fs->code_heap);
|
||||
|
||||
while (TRUE) {
|
||||
"This will compile an expression\n"
|
||||
"consisting of integers, parentheses\n"
|
||||
"and the operators +,-,* and /.\n";
|
||||
"consisting of integers, parentheses\n"
|
||||
"and the operators +,-,* and /.\n";
|
||||
src=GetStr;
|
||||
if (*src) {
|
||||
src2=src;
|
||||
@@ -217,7 +217,7 @@ U0 Main()
|
||||
"$$RED$$This code is not efficient, but the compiler is simple.$$FG$$\n";
|
||||
Un(code,dst-code); //Unassemble the code we created.
|
||||
//$LK,"Call",A="MN:Call"$() is a function. See $LK,"_CALL",A="FF:::/Kernel/KUtils.CPP,_CALL"$::
|
||||
//See also $LK,"CallInd",A="MN:CallInd"$(). See $LK,"_CALLIND",A="FF:::/Kernel/KUtils.CPP,_CALLIND"$::
|
||||
//See also $LK,"CallInd",A="MN:CallInd"$(). See $LK,"_CALLIND",A="FF:::/Kernel/KUtils.CPP,_CALLIND"$::
|
||||
"$$LTBLUE$$Answer:%d$$FG$$\n",Call(code);
|
||||
} catch {
|
||||
"$$RED$$Error$$FG$$\n";
|
||||
|
||||
@@ -17,7 +17,7 @@ U0 MGInit()
|
||||
|
||||
U0 MGUpdate()
|
||||
{//Copy image to VGA memory
|
||||
//For better performance we could only write what's changed.
|
||||
//For better performance we could only write what's changed.
|
||||
//0xA0000 is slower than normal RAM.
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,0xF);//All color planes at once -- Black and White
|
||||
@@ -32,7 +32,7 @@ U0 MGPlot(I64 x,I64 y)
|
||||
|
||||
U0 MGHLine(I64 x1,I64 x2,I64 y)
|
||||
{//Warning! No clipping
|
||||
//For performance, we do as many whole-bytes as possible.
|
||||
//For performance, we do as many whole-bytes as possible.
|
||||
U8 *ptr;
|
||||
I64 i,w,leading,trailing,whole_bytes;
|
||||
if (x2<x1) SwapI64(&x1,&x2);
|
||||
@@ -88,11 +88,11 @@ U0 MGCircle(I64 x,I64 y,F64 r)
|
||||
MGPlot(x+x1,y+y1);
|
||||
while (len-->=0) {
|
||||
|
||||
//m1@a1 * m2@a2 = m1*m2@(a1+a2)
|
||||
//m1@a1 * m2@a2 = m1*m2@(a1+a2)
|
||||
|
||||
//(x1+y1i)*(x2+y2i) = x1*x2+(x1*y1+x2*y2)i-y1*y2
|
||||
//(x1+y1i)*(x2+y2i) = x1*x2+(x1*y1+x2*y2)i-y1*y2
|
||||
|
||||
// me$SY,-3$ti$SY,0$=mCos(t)+imSin(t)
|
||||
// me$SY,-3$ti$SY,0$=mCos(t)+imSin(t)
|
||||
|
||||
x2=x1; y2=y1;
|
||||
x1=c*x2-s*y2;
|
||||
@@ -108,7 +108,7 @@ U0 MiniGrLibDemo()
|
||||
Bool old_preempt;
|
||||
MGInit;
|
||||
|
||||
old_preempt=Preempt(OFF);
|
||||
old_preempt=Preempt;
|
||||
for (i=0;i<100;i++)
|
||||
MGHLine(200+i,400+i,300+i);
|
||||
for (i=0;i<500;i+=10)
|
||||
@@ -124,7 +124,7 @@ It is not normal to by-pass the TempleOS graphcis routines.
|
||||
The TempleOS graphics don't know VGA has changed.
|
||||
This bit tells TempleOS to update whole screen.
|
||||
*/
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ This example uses 8-bit negative displacements.
|
||||
|
||||
class Person
|
||||
{ $$=-128;
|
||||
U8 first [32];
|
||||
U8 last [32];
|
||||
U8 address1 [64];
|
||||
U8 address2 [64];
|
||||
U8 city [32];
|
||||
U8 state_zip[32];
|
||||
U8 first [32];
|
||||
U8 last [32];
|
||||
U8 address1 [64];
|
||||
U8 address2 [64];
|
||||
U8 city [32];
|
||||
U8 state_zip[32];
|
||||
};
|
||||
|
||||
U0 OffsetDemo2()
|
||||
|
||||
@@ -61,7 +61,7 @@ _WELL_OPTIMIZED3::
|
||||
XOR RAX,RAX
|
||||
MOV RCX,SAMPLES-1
|
||||
@@05: ADD RAX,RCX
|
||||
LOOP @@05 //This instruction sucks, speedwise, but it saves code size
|
||||
LOOP @@05 //Instruction sucks in speed, but saves code size.
|
||||
RET
|
||||
}
|
||||
|
||||
|
||||
@@ -11,25 +11,25 @@
|
||||
interrupt U0 MyVect40()
|
||||
{
|
||||
lock {progress1++;}
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
}
|
||||
|
||||
interrupt U0 MyVect41()
|
||||
{
|
||||
lock {progress2++;}
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
}
|
||||
|
||||
interrupt U0 MyVect42()
|
||||
{
|
||||
lock {progress3++;}
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
}
|
||||
|
||||
interrupt U0 MyVect43()
|
||||
{
|
||||
lock {progress4++;}
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
*LAPIC_EOI(U32 *)=0;
|
||||
}
|
||||
|
||||
I64 vect[4]={&MyVect40,&MyVect41,&MyVect42,&MyVect43};
|
||||
@@ -44,8 +44,8 @@ U0 Main()
|
||||
for (i=I_USER;i<I_USER+4;i++)
|
||||
IntEntrySet(i,vect[i&3],IDTET_IRQ);
|
||||
|
||||
//There are like 4*6 vects. Bus zero
|
||||
//has the first four vects.
|
||||
//There are like 4*6 vects. Bus zero
|
||||
//has the first four vects.
|
||||
for (i=IOREDTAB;i<IOREDTAB+4*2;i+=2) {
|
||||
*da=i+1;
|
||||
*_d=dev.mp_apic_ids[DEST_CPU]<<24;
|
||||
@@ -55,10 +55,10 @@ U0 Main()
|
||||
|
||||
Sleep(1000);
|
||||
"The keyboard and timer seem to be active.\n"
|
||||
"IntA:%d IntB:%d IntC:%d IntD:%d\n\n"
|
||||
"IntB is my keybaord and regs a single KEY-UP.\n"
|
||||
"Rerun and press a few keys.\n",
|
||||
progress1,progress2,progress3,progress4;
|
||||
"IntA:%d IntB:%d IntC:%d IntD:%d\n\n"
|
||||
"IntB is my keybaord and regs a single KEY-UP.\n"
|
||||
"Rerun and press a few keys.\n",
|
||||
progress1,progress2,progress3,progress4;
|
||||
|
||||
//Disable vects
|
||||
for (i=IOREDTAB;i<IOREDTAB+4*2;i+=2) {
|
||||
|
||||
@@ -22,13 +22,13 @@ U0 PageTableDemo1()
|
||||
InvlPg(VGAM_GRAPHICS); //Invalidate translation look aside buffer (TLB).
|
||||
InvlPg(VGAM_GRAPHICS+0x1000);
|
||||
|
||||
//Use this if you wish to change
|
||||
//the page table reg.
|
||||
//Use this if you wish to change
|
||||
//the page table reg.
|
||||
|
||||
// SetRAX(0x100000+0x1000*(MEM_NUM_PML1+MEM_NUM_PML2+MEM_NUM_PML3));
|
||||
// MOV_CR3_EAX
|
||||
// SetRAX(0x100000+0x1000*(MEM_NUM_PML1+MEM_NUM_PML2+MEM_NUM_PML3));
|
||||
// MOV_CR3_EAX
|
||||
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
PressAKey;
|
||||
|
||||
@@ -37,7 +37,7 @@ U0 PageTableDemo1()
|
||||
InvlPg(VGAM_GRAPHICS);
|
||||
InvlPg(VGAM_GRAPHICS+0x1000);
|
||||
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ interrupt haserrcode U0 PageFault()
|
||||
*pte_addr|=1;
|
||||
InvlPg(addr);
|
||||
err_code=rbp[1];
|
||||
MOV_RAX_CR2
|
||||
MOV_RAX_CR2
|
||||
reported_fault_addr=GetRAX;
|
||||
}
|
||||
|
||||
|
||||
+24
-24
@@ -33,39 +33,39 @@ U0 Ring3Demo()
|
||||
|
||||
TSSBusy(Gs->tss->tr_ring3,OFF);
|
||||
SetRAX(Gs->tss->tr_ring3+3);
|
||||
LTR AX
|
||||
LTR AX
|
||||
|
||||
asm {
|
||||
MOV U64 [&old_stk],RSP
|
||||
asm {
|
||||
MOV U64 [&old_stk],RSP
|
||||
|
||||
LEA RAX,[R3_CALLBACK]
|
||||
MOV U64 [&new_rip],RAX
|
||||
|
||||
MOV AX,CGDT.ds_ring3+3
|
||||
MOV DS,AX
|
||||
MOV ES,AX
|
||||
LEA RAX,[R3_CALLBACK]
|
||||
MOV U64 [&new_rip],RAX
|
||||
|
||||
PUSH U32 CGDT.ds_ring3+3 //STKSEG
|
||||
PUSH U64 [&old_stk]
|
||||
PUSH U32 0 //FLAGS--interrupts off
|
||||
PUSH U32 CGDT.cs64_ring3+3
|
||||
LEA RAX,[R3_START]
|
||||
PUSH RAX
|
||||
IRET
|
||||
MOV AX,CGDT.ds_ring3+3
|
||||
MOV DS,AX
|
||||
MOV ES,AX
|
||||
|
||||
R3_START:
|
||||
INC U64 [SYS_PROGRESS1]
|
||||
CLI //This causes general protection fault #13
|
||||
PUSH U32 CGDT.ds_ring3+3 //STKSEG
|
||||
PUSH U64 [&old_stk]
|
||||
PUSH U32 0 //FLAGS--interrupts off
|
||||
PUSH U32 CGDT.cs64_ring3+3
|
||||
LEA RAX,[R3_START]
|
||||
PUSH RAX
|
||||
IRET
|
||||
|
||||
R3_CALLBACK:
|
||||
MOV AX,CGDT.ds
|
||||
MOV DS,AX
|
||||
MOV ES,AX
|
||||
R3_START:
|
||||
INC U64 [SYS_PROGRESS1]
|
||||
CLI //This causes general protection fault #13
|
||||
|
||||
R3_CALLBACK:
|
||||
MOV AX,CGDT.ds
|
||||
MOV DS,AX
|
||||
MOV ES,AX
|
||||
}
|
||||
|
||||
TSSBusy(Gs->tss->tr,OFF);
|
||||
SetRAX(Gs->tss->tr);
|
||||
LTR AX
|
||||
LTR AX
|
||||
|
||||
IntEntrySet(0x0D,old_vect,IDTET_IRQ,0);
|
||||
STI
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
U0 PlotXY(I64 x,I64 y)
|
||||
{
|
||||
//Screen bits are reversed
|
||||
//Screen bits are reversed
|
||||
LBts(VGAM_GRAPHICS,y*GR_WIDTH+x^7);
|
||||
}
|
||||
|
||||
U0 Main()
|
||||
{
|
||||
I64 i;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
|
||||
//This makes all 4 color planes active.
|
||||
//This makes all 4 color planes active.
|
||||
OutU8(VGAP_INDEX,VGAR_MAP_MASK);
|
||||
OutU8(VGAP_DATA,WHITE);
|
||||
MemSet(VGAM_GRAPHICS,0,GR_WIDTH*GR_HEIGHT/8);
|
||||
@@ -41,12 +41,13 @@ That means no read-modify-writes, too.
|
||||
|
||||
Preempt(old_preempt);
|
||||
|
||||
//TempleOS has a 4 plane memory duplicate of the screen, $LK,"gr.screen_image",A="MN:CGrGlbls"$,
|
||||
//and only writes actual changes. See $LK,"GrUpdateVGAGraphics",A="MN:GrUpdateVGAGraphics"$().
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
//TempleOS has a 4 plane memory duplicate of the screen, $LK,"gr.screen_image",A="MN:CGrGlbls"$,
|
||||
//and only writes actual changes. See $LK,"GrUpdateVGAGraphics",A="MN:GrUpdateVGAGraphics"$().
|
||||
//<CTRL-ALT-f> will flush screen VGA cache.
|
||||
VGAFlush;
|
||||
}
|
||||
|
||||
Main;
|
||||
|
||||
//See $LK,"::/Demo/Lectures/GraphicsCPULoad.CPP"$.
|
||||
|
||||
@@ -3,8 +3,8 @@ U0 LoadTask(I64)
|
||||
{
|
||||
I64 i,j=100;
|
||||
//Preemption is ctrlled on a per task basis.
|
||||
//Preemption is OFF by default on new tasks.
|
||||
//It is turned on for user terminal tasks.
|
||||
//Preemption is OFF by default on new tasks.
|
||||
//It is turned on for user terminal tasks.
|
||||
Preempt(ON);
|
||||
while (TRUE) {
|
||||
for (i=0;i<10000;i++)
|
||||
@@ -29,13 +29,13 @@ U0 SpinningNoPreempt()
|
||||
Bool old_preempt;
|
||||
"Spinning with no preemption...\n";
|
||||
|
||||
//Put on screen before it starts. Text lags by one refresh
|
||||
//and we might catch it in the middle of an update.
|
||||
//Put on screen before it starts. Text lags by one refresh
|
||||
//and we might catch it in the middle of an update.
|
||||
WinMgrSync;
|
||||
WinMgrSync;
|
||||
WinMgrSync;
|
||||
|
||||
old_preempt=Preempt(OFF);
|
||||
old_preempt=Preempt;
|
||||
for (i=0;i<3000000;i++)
|
||||
InU8(0x21);
|
||||
Preempt(old_preempt);
|
||||
@@ -69,7 +69,7 @@ U0 CooperativeMultitaskingPreempt()
|
||||
U0 CooperativeMultitaskingNoPreempt()
|
||||
{
|
||||
F64 timeout=tS+3.0;
|
||||
Bool old_preempt=Preempt(OFF);
|
||||
Bool old_preempt=Preempt;
|
||||
"Cooperative multitasking with no preemption...\n";
|
||||
while (tS<timeout) {
|
||||
InU8(0x21);
|
||||
|
||||
@@ -4,13 +4,13 @@ U0 TimeIns()
|
||||
{
|
||||
I64 i,start,end;
|
||||
I64 *cached_I64=MAlloc(sizeof(I64)),
|
||||
shared_blks,*uncached_I64;
|
||||
shared_blks,*uncached_I64;
|
||||
CBlkPool *bp;
|
||||
CHeapCtrl *hc;
|
||||
Bool old_preempt;
|
||||
|
||||
"$$RED$$Now, this demo seems broken, perhaps,\n"
|
||||
"because I run in a virtual machine.$$FG$$\n\n";
|
||||
"because I run in a virtual machine.$$FG$$\n\n";
|
||||
CPURep;
|
||||
|
||||
shared_blks=1;
|
||||
@@ -18,9 +18,9 @@ U0 TimeIns()
|
||||
hc=HeapCtrlBPInit(bp,shared_blks<<12);
|
||||
uncached_I64=MAlloc(sizeof(I64),hc);
|
||||
|
||||
old_preempt=Preempt(OFF);
|
||||
old_preempt=Preempt;
|
||||
|
||||
//Measure cached time
|
||||
//Measure cached time
|
||||
start=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
*cached_I64=i;
|
||||
@@ -28,7 +28,7 @@ U0 TimeIns()
|
||||
end=GetTSC;
|
||||
" Cached Cycles: %10,d\n",end-start;
|
||||
|
||||
//Measure uncached time
|
||||
//Measure uncached time
|
||||
start=GetTSC;
|
||||
for (i=0;i<SAMPLE_SIZE;i++)
|
||||
*uncached_I64=i;
|
||||
@@ -36,7 +36,7 @@ U0 TimeIns()
|
||||
"Uncached Cycles: %10,d\n",end-start;
|
||||
|
||||
"$$GREEN$$The difference is even greater\n"
|
||||
"because the loop overhead was not subtracted.$$FG$$\n\n";
|
||||
"because the loop overhead was not subtracted.$$FG$$\n\n";
|
||||
Free(cached_I64);
|
||||
Free(uncached_I64);
|
||||
Mem2MegFree(bp,shared_blks);
|
||||
|
||||
Reference in new issue
Block a user