PowerShell for Windows Admins

Nov 8 2010   4:38PM GMT

Cache memory



Posted by: Richard Siddaway
Tags:
Hardware

 

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.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: