flat assembler
Message board for the users of flat assembler.

Index > Main > tasks switching and local-apic timers

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 16 Apr 2011, 22:25

I am absolutely certain that Windows (XP Pro) doesn't use the local_apic timers (timer Register - 0FEE00320h) for switching tasks. How is this possible ?
How does Windows measures the time to switch tasks ?
maybe with the Performance-monitoring timer (0FEE00340h) ?
(sorry for my bad english)
An "interrupt" to do that is yet absolutely necessary !
From where it comes ?
....
Question

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 16 Apr 2011, 22:25
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 16 Apr 2011, 23:31
It may be using this: http://en.wikipedia.org/wiki/Programmable_interval_timer

Still, how did you determine it is not using the local APIC?
Post 16 Apr 2011, 23:31
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 17 Apr 2011, 07:26
Too bad MS doesn't use http://en.wikipedia.org/wiki/High_Precision_Event_Timer for task switching.
Post 17 Apr 2011, 07:26
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 17 Apr 2011, 14:00

@Loco

programmable interval timer (PIT)... this no longer exists in moderns pc
All functions are contained in the two main circuits, north-bridge and south-bridge

"xp" configures this timer with the interrupt 0xfd, but keeps it disable.
I reprogrammed this timer with my own interrupt, then redirected to the interrupt 0xfd... xp is never gone through my hook.
On the other hand, if I enable this timer with my own code,
I intercept it in my hook... but "xp" never.
windows (xp) never enables local-apic timers.

@bitRAKE

thank you for the link
but in this case, from where this essential interrupt comes from??? Confused

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 17 Apr 2011, 14:00
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 17 Apr 2011, 19:06
ouadji, architecturally speaking (which is the way I was referring to the PIT), it is still available, it is just the physical implementation that changed.
Post 17 Apr 2011, 19:06
View user's profile Send private message Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 18 Apr 2011, 03:25
bitRAKE wrote:
Too bad MS doesn't use http://en.wikipedia.org/wiki/High_Precision_Event_Timer for task switching.

Are you sure they don't? With Vista and HPET disabled i seem to get timer resolutions consistent with the RTC 32768Hz clock and divider A. ie RTC low nibble of reg A is set to 5 which is 488.281us and NtQueryTimerResolution shows a max resolution of 500.0us but actually gives 488.2us when selected. With HPET enabled reg A low nibble is set to 6 (976.562us) but NtQueryTimerResolution still shows a max of 500.0us and actually gives 500.0us when selected.

Doesn't XP also have a boot.ini option to use the ACPI timer instead. It all makes for confusing times. Laughing

BTW the HPET clocks I've seen have been 14.318180MHz.
Post 18 Apr 2011, 03:25
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 18 Apr 2011, 04:02
ouadji wrote:

@Loco

programmable interval timer (PIT)... this no longer exists in moderns pc
All functions are contained in the two main circuits, north-bridge and south-bridge
PIT emulation is one of the many uses of SMM.

Is there any reason it couldn't use the RTC? (Other than the fact it is much lower in priority than the PIT.)
Post 18 Apr 2011, 04:02
View user's profile Send private message Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville 18 Apr 2011, 04:04
ouadji wrote:
programmable interval timer (PIT)... this no longer exists in moderns pc
I agree with loco the 8253/8254 PIT definitely does functionally exist in modern PC's. The BIOS still sets up Counter0 to generate HW INT8 at approx 18.2 Hz (used by DOS for date/time calcs). In FAMOS I reprogram this counter to provide interrupts at 1kHz (via INT1Ch which is called by INT8) for isochronous USB audio streaming, and at 22kHz for my own digital audio hardware I made many years ago.
I suspect Counter2 is still used for dynamic RAM refresh too - would be very easy to prove by messing with it ..... Wink

_________________
FAMOS - the first memory operating system
Post 18 Apr 2011, 04:04
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 18 Apr 2011, 09:05
Okay, I ran a quick RDTSC check on a single thread with another active thread. By measuring a tight loop we can check the difference between two RDTSC's and when greater than say 1000 cycles then we can assume a context switch took place. The quantum (time slice) can be taken as the first RDTSC to the last before a big change was seen. By changing reg A of the RTC down or up one the quantum can be seen to double or half even though Windows still reports the same resolution. Although the RTC daytime clock carries on as normal the Windows time clock is affected.

Some snips from the ICH9 Southbridge.


Description:
Filesize: 9.27 KB
Viewed: 8538 Time(s)

rtc3.png


Description:
Filesize: 18.55 KB
Viewed: 8538 Time(s)

RTC2.png


Post 18 Apr 2011, 09:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 18 Apr 2011, 09:25
Alphonso wrote:
Okay, I ran a quick RDTSC check on a single thread with another active thread. By measuring a tight loop we can check the difference between two RDTSC's and when greater than say 1000 cycles then we can assume a context switch took place. The quantum (time slice) can be taken as the first RDTSC to the last before a big change was seen. By changing reg A of the RTC down or up one the quantum can be seen to double or half even though Windows still reports the same resolution. Although the RTC daytime clock carries on as normal the Windows time clock is affected.
Very good work. I like it when someone actually tests something to see what is really going on.
Post 18 Apr 2011, 09:25
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 18 Apr 2011, 13:46
Thanks Rev. Also when a resolution change is made (NtSetTimerResolution), reg A can be seen to be changed by Windows when RTC is selected, at least with Vista that is.
Post 18 Apr 2011, 13:46
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 19 Apr 2011, 03:29
http://msdn.microsoft.com/en-us/windows/hardware/gg463347.aspx

HPET is used by Vista and newer versions of Windows.
Post 19 Apr 2011, 03:29
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.