Nov 8 2010 4:38PM GMT
Posted by: Richard Siddaway
Hardware
Cache memory
Posted by: Richard Siddaway
Processors have cache memory as we saw when we looked at Win32_Processor. We can find more details about the cache memory using the Win32_CacheMemory class
|
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 |
$assoc = DATA {ConvertFrom-StringData -StringData @’
1 = Other 2 = Unknown 3 = Direct Mapped 4 = 2-way Set-Associative 5 = 4-way Set-Associative 6 = Fully Associative 7 = 8-way Set-Associative 8 = 16-way Set-Associative ‘@} $ct = DATA {ConvertFrom-StringData -StringData @’1 = Other 2 = Unknown 3 = Instruction 4 = Data 5 = Unified ‘@} $wp = DATA {ConvertFrom-StringData -StringData @’1 = Other 2 = Unknown 3 = Write Back 4 = Write Through 5 = Varies with Address 6 = Determination Per I/O ‘@} $sram = DATA {ConvertFrom-StringData -StringData @’0 = Other 1 = Unknown 2 = Non-Burst 3 = Burst 4 = Pipeline Burst 5 = Synchronous 6 = Asynchronous ‘@} function ssram {param ($supsram) $ret = "" $supsram | foreach{ $ret += $sram["$($_)"] + ", " } $ret.TrimEnd(", ") } Get-WmiObject -Class Win32_CacheMemory | foreach { $_ | select DeviceID, Purpose, @{Name="Associativity"; Expression={$assoc["$($_.Associativity)"]}}, BlockSize, @{Name="Cache Type"; Expression={$ct["$($_.CacheType)"]}}, InstalledSize, NumberOfBlocks, MaxCacheSize, @{Name="Current SRAM"; Expression={$sram["$($_.CurrentSRAM)"]}}, @{Name="Supported SRAM"; Expression={ssram $_.SupportedSRAM}}, @{Name="Write Policy"; Expression={$wp["$($_.WritePolicy)"]}} } |
Most of this should be familiar by now. We create some hash tables as lookups. Then we use Win32_cachememory. The replacement of integer codes by their meaning looked up from the hash table is straight forward. The trick in this is decoding the SupportedSRAM property. its an array of integers so I had to write a function to work through the array members, decode them and add the results to a string that we can then display.




