《深入理解Windows操作系统》笔记3

X86/X64的页面错误异常号是0xe,页面错误:一个线程企图访问虚拟内存中没有定义的或者已经存在的页面时产生的异常。Windows支持的硬件体系结构允许最多可达256IDT项。一台PC所能支持的中断IRQ数量是由该机器的中断控制器的具体设计决定的。

由于大多数X86都依赖一个硬件i8259A可编程中断控制器(PIC)在单处理器系统上有15条中断线。

0:kd>!idt

DumpingIDT:

37:806e6864hal!PicSpuriousService37

3d:806e7e2chal!HalpApcInterrupt

41:806e7c88hal!HalpDispatchInterrupt

50:806e693chal!HalpApicRebootService

62:8a3019548a38ecb8(KINTERRUPT8a301918)

63:89d3d044NDIS!ndisMIsr(KINTERRUPT89d3d008)

8a225cb8(KINTERRUPT89cc7bb0)

73:8a056becVIDEOPRT!pVideoPortInterrupt(KINTERRUPT8a056bb0)

8a225cb8(KINTERRUPT89cd8938)

8a225cb8(KINTERRUPT89ccf938)

83:8a2b6afc8a38ecb8(KINTERRUPT8a2b6ac0)

8a38ecb8(KINTERRUPT8a2b5bb0)

NDIS!ndisMIsr(KINTERRUPT89ce2930)

92:899e1becserial!SerialCIsrSw(KINTERRUPT899e1bb0)

93:899e8044i8042prt!I8042KeyboardInterruptService(KINTERRUPT899e8008)

a4:89cdfbec8a225cb8(KINTERRUPT89cdfbb0)

8a225cb8(KINTERRUPT89cd0bb0)

b1:8a36f044ACPI!ACPIInterruptServiceRoutine(KINTERRUPT8a36f008)

8a1d0cb8(KINTERRUPT8a075508)

b4:89d38bec8a225cb8(KINTERRUPT89d38bb0)

HDAudBus!AzController::Isr(KINTERRUPT89d32410)

c1:806e6ac0hal!HalpBroadcastCallService

d1:806e5e54hal!HalpClockInterrupt

e1:806e7048hal!HalpIpiHandler

e3:806e6dachal!HalpLocalApicErrorService

fd:806e75a8hal!HalpProfileInterrupt

fe:806e7748hal!HalpPerfInterrupt

查看PICAPIC

0:kd>!pic

-----IRQNumber-----000102030405060708090A0B0C0D0E0F

Physicallyinservice:YY.Y....YY.Y....

Physicallymasked:YYY.Y.Y.YYY.Y.Y.

Physicallyrequested:.Y.Y.....Y.Y....

0:kd>

对于本机单CPU双核来看:是否使用了MPSHAL

lkd>!apic

Apic@fffe0000ID:1(80050010)LogDesc:02000000DestFmt:ffffffffTPR41

TimeCnt:0be420e0clkSpurVec:1fFaultVec:e3error:0

IpiCmd:01000000`00040041Vec:41FixedDelDest=Selfedghigh

Timer..:00000000`000300fdVec:FDFixedDelDest=Selfedghighm

Linti0.:00000000`0001001fVec:1FFixedDelDest=Selfedghighm

Linti1.:00000000`000184ffVec:FFNMIDest=Selflvlhighm

TMR:63,73,A4,B1,B4

IRR:

ISR:

0:kd>!ioapic

IoApic@FEC00000ID:0(0)Arb:0

Inti00.:00000000`00000000Vec:00FixedDelPh:00000000edghigh

仅在windows2003上菜支持!Irql查看一个处理器的IRQL

lkd>!pcr

KPCRforProcessor0atffdff000:

Major1Minor1

NtTib.ExceptionList:ffffffff

NtTib.StackBase:805524f0

NtTib.StackLimit:8054f700

NtTib.SubSystemTib:00000000

NtTib.Version:00000000

NtTib.UserPointer:00000000

NtTib.SelfTib:00000000

SelfPcr:ffdff000

Prcb:ffdff120

Irql:00000000

IRR:00000000

IDR:ffffffff

InterruptMode:00000000

IDT:8003f400

GDT:8003f000

TSS:80042000

CurrentThread:8055ce60

NextThread:00000000

IdleThread:8055ce60

DpcQueue:

可以使用DDK上头文件中的ntddk.H定义的PCRPRCB的信息。不幸的是在不适用延迟IRQL的系统上,比如本机器AMDAthlon64X26000+windowsXPSP3上就不支持,因此为0,需要至少WINDOWS2003

http://msdn.microsoft.com/zh-cn/windows/hardware/gg463382
下载安装kernrates软件,进行内核性能剖析程序来分析性能。

C:\ProgramFiles\SupportTools>cd"c:\ProgramFiles\KrView\Kernrates"

C:\ProgramFiles\KrView\Kernrates>dir

驱动器C中的卷没有标签。

卷的序列号是18F6-A188

C:\ProgramFiles\KrView\Kernrates的目录

2012-02-0716:57<DIR>.

2012-02-0716:57<DIR>..

2003-11-0716:58269,312Kernrate_i386_Win2000.exe

2003-11-0716:58129,024Kernrate_i386_XP.exe

2003-11-0716:59326,656Kernrate_ia64_XP.exe

3个文件724,992字节

2个目录146,187,862,016可用字节

C:\ProgramFiles\KrView\Kernrates>Kernrate_i386_XP.exe

/==============================\

<KERNRATELOG>

\==============================/

Date:2012/02/07Time:16:58:17

MachineName:AMD6000

NumberofProcessors:2

PROCESSOR_ARCHITECTURE:x86

PROCESSOR_LEVEL:15

PROCESSOR_REVISION:4303

PhysicalMemory:2816MB

PagefileTotal:2656MB

VirtualTotal:2047MB

PageFile1:(null),0MB

OSVersion:5.1Build2600Service-Pack:3.0

WinDir:C:\WINDOWS

KernrateUser-SpecifiedCommandLine:

Kernrate_i386_XP.exe

KernelProfile(PID=0):Source=Time,

UsingKernrateDefaultRateof25000events/hit

Startingtocollectprofiledata

***>Pressctrl-ctofinishcollectingprofiledata

------------OverallSummary:--------------

P0K0:00:08.562(8.8%)U0:00:11.109(11.4%)I0:01:17.703(79.8%)DPC

0:00:01.656(1.7%)Interrupt0:00:00.062(0.1%)

Interrupts=142334,InterruptRate=1462/sec.

P1K0:00:10.562(10.8%)U0:00:06.406(6.6%)I0:01:20.406(82.6%)DPC

0:00:05.828(6.0%)Interrupt0:00:00.265(0.3%)

Interrupts=73111,InterruptRate=751/sec.

TOTALK0:00:19.125(9.8%)U0:00:17.515(9.0%)I0:02:38.109(81.2%)DPC

0:00:07.484(3.8%)Interrupt0:00:00.328(0.2%)

TotalInterrupts=215445,TotalInterruptRate=2213/sec.

TotalProfileTime=97375msec

BytesStartBytesStopByt

esDiff.

AvailablePhysicalMemory,1864134656,2005221376,141086

720

AvailablePagefile(s),1864282112,2005024768,140742

656

AvailableVirtual,2131689472,2130640896,-1048

576

AvailableExtendedVirtual,0,0,

0

TotalAvg.Rate

ContextSwitches,571193,5866/sec.

SystemCalls,2132527,21900/sec.

PageFaults,325110,3339/sec.

I/OReadOperations,11188,115/sec.

I/OWriteOperations,8299,85/sec.

I/OOtherOperations,29196,300/sec.

I/OReadBytes,39124405,3497/I/O

I/OWriteBytes,16790740,2023/I/O

I/OOtherBytes,4785210,164/I/O

-----------------------------

ResultsforKernelMode:

-----------------------------

OutputResults:KernelModuleCount=142

PercentageinthefollowingtableisbasedontheTotalHitsfortheKernel

Time69611hits,25000eventsperhit--------

ModuleHitsmsec%TotalEvents/Sec

processr608559735987%15626444

ntkrnlpa4118973755%1057252

ati2cqag947973591%243172

hal907973751%232862

ati2dvag838973591%215182

PECKP701973591%180003

win32k654973590%167935

USBPORT130973590%33381

athuw81973590%20799

RtkHDAud38973590%9757

usbehci38973590%9757

ati2mtag37973590%9500

kmixer34973590%8730

tcpip30973590%7703

NDIS24973590%6162

Ntfs23973590%5905

afd21973590%5392

Npfs18973590%4622

portcls15973590%3851

l151x8613973590%3338

sptd13973590%3338

usbhub12973590%3081

wdf010009973590%2311

watchdog6973590%1540

fltMgr6973590%1540

ipnat5973590%1283

LiveKdD4973590%1027

avipbb4973590%1027

ati3duag3973590%770

ks3973590%770

avgntflt2973590%513

el90xbc52973590%513

usbohci2973590%513

wdmaud1973590%256

sniffer1973590%256

LMouFilt1973590%256

mouhid1973590%256

LHidFilt1973590%256

HIDPARSE1973590%256

avkmgr1973590%256

rdbss1973590%256

ipsec1973590%256

psched1973590%256

TDI1973590%256

av261r6u1973590%256

HDAudBus1973590%256

Mup1973590%256

CLASSPNP1973590%256

PartMgr1973590%256

PCIIDEX1973590%256

WMILIB1973590%256

=================================ENDOFRUN==================================

==============================NORMALENDOFRUN==============================

C:\ProgramFiles\KrView\Kernrates>

由此可见系统在内核模式下花了TOTALK0:00:19.125(9.8%)的时间。碰撞率最高的模块是process,这个是CPU处理器驱动程序。

X86的多处理器系统上,IRQ本质上是随机的,但在X64或者IA64上,IRQ16除中断向量号。

因为windows并没有以任何一种可控的方式对设备IRQ进行优先级处理,而且用户的应用程序只能在处理器的IRQL为被动级别的时候才能执行,所以windows不适合作实时系统。

声明:真相:windowsXPEmbedded并没有实时特性,而是借助venturcom公司将实时内核内嵌到自定义好的HAL中。



你可能感兴趣的:(windows)