what does that mean? Where can we find the speed. I am hearing it for first time.Candy wrote: And just for a hint, try searching the processor ID string, it usually contains the speed too (note, the speed, not the frequency)
:-\
what does that mean? Where can we find the speed. I am hearing it for first time.Candy wrote: And just for a hint, try searching the processor ID string, it usually contains the speed too (note, the speed, not the frequency)
I like that more than the "nice" speedalgorithm: multiply the value you get by 6, add 50, chop off the last 2 decimals, divide by 6, and use that value. This rounds off to 1333 / 1350 / 1366 / 1387 / 1400 etc. so you get a "nice" speed instead of 1402.123 mhz
Without the internal counter you'll have to do it the old fashioned way and measure the time it takes to execute a piece of code with a well known cycle count. It's tricky to produce a piece of code like that with all the caching mechanisms, but not that hard.DennisCGc wrote: And how to detect the cpu speed for 486's ?
Any suggestions ? ???Without the internal counter you'll have to do it the old fashioned way and measure the time it takes to execute a piece of code with a well known cycle count. It's tricky to produce a piece of code like that with all the caching mechanisms, but not that hard
Code: Select all
INC ECX
sth likeDennisCGc wrote: Any suggestions ? ???
Could:be helpful ?Code: Select all
INC ECX
Code: Select all
xor ecx, ecx
jmpl:
inc ecx
jmp jmpl
Code: Select all
void count() {
register_handler(&count_handler);
wait_for_pulse();
start_thread();
}
count_handler () {
read_ecx_count_off_the_stack();
stop_thread();
return ecx_count * cycle count;
}
OkayPype.Clicker wrote: well, post it and we'll see
Code: Select all
;divider = 3334
;assumes that IRQ0_COUNT will change after the timer interrupt is called.
;PIT must be set to 100 hz.
mov ebx,[irq0_count]
irq0loop:
cmp ebx,[irq0_count]
jz irq0loop
;timer interrupt just occured, start!
mov ebx, [irq0_count]
add ebx,2
xor ecx,ecx
cpu_loop:
inc ecx
cmp ebx,[irq0_count]
jnz cpu_loop
;end loop
xor edx,edx
mov eax,ecx
mov ecx,3334
idiv ecx
;eax contains the MHZ :)
Code: Select all
add ebx,2
Code: Select all
inc ebx
So indeed, using '20Hz' PIT could be the best if one can perform exact CPU speed detection *before* task switching is in place (imho, it wouldn't be nice to have a system which can only schedule 20 tasks a second as our screens goes up to 60 frames a second :-/)200 5965.9 Hz
5966 5.00008ms 199.996647670131 Hz
11932 10000.16... us (99,998 Hz)
13125 11.000016 ms
26250 22.000033 ms
59659 50 ms 50000 us 20 Hz
Code: Select all
cli
mov al,34h
out 43h,al
xor al,al
out 40h,al
out 40h,al
rdtsc
mov [stsc],edx
mov [stsc+4],eax
mov ecx,1000h
.loop_tsc
rdtsc
mov [etsc],edx
mov [etsc+4],eax
dec ecx
jnz .loop_tsc
mov al,4
out 43h,al
in al,40h
mov [blow],al
in al,40h
mov [bhigh],al
movzx eax,byte[bhigh]
shl eax,8
movzx ebx,byte[blow]
add ebx,eax
mov eax,10000h
sub eax,ebx
mov [ticks],eax
mov edx,[etsc]
mov eax,[etsc+4]
mov ebx,[stsc]
sub eax,[stsc+4]
sbb edx,ebx
mov ebx,1193180
mul ebx
mov ebx,[ticks]
div ebx
call dec2ascii_str, eax
sti
Code: Select all
loop_length=0x1000;
do {
Mhz=compute_mhz(loop_length,&elapsed_ticks);
loop_length*=2;
} while(elapsed_ticks < 0x4000);