📄 instance_x86logical.cpp
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
#include <string.h>
#include "inc/framework/win2linux.h"
#include "./Instance_X86Logical.h"
//#include "HelperUtils.h"
//extern TNtQuerySystemInformation g_fNTQuerySystemInformation;
DefaultX86LogicalInstanceObject::~DefaultX86LogicalInstanceObject(void)
{
}
void DefaultX86LogicalInstanceObject::OnInstanceRemoved()
{
}
bool DefaultX86LogicalInstanceObject::Initialize( const IntelMobileString& szKey )
{
try {
// convert the string key to dwAffinityMask
DWORD dwAffinityMask = atoi( szKey.c_str() );
if ( szKey == "0" || dwAffinityMask != 0L ) // convert successfully
{
__dwAffinityMask = dwAffinityMask;
m_nIndex = 0;
DWORD dwTemp = (dwAffinityMask>>1);
while ( dwTemp != 0 )
{
dwTemp >>= 1;
m_nIndex++;
}
}
else
{
return false;
}
}
catch(...) {
THROWIMEXCEPTION("80043411");
}
bool bRet = true;
Lock();
m_sKey = ( szKey );
CpuUsage.SetValue( 0.0f );
Unlock();
return bRet;
}
CacheInfoList DefaultX86LogicalInstanceObject::GetCacheInfo()
{
CacheInfoList cacheList = m_pParent->GetCacheInfo();
for ( size_t i=0;i<cacheList.size();i++ )
cacheList[i].Shared = true;
return cacheList;
}
IntelMobileString DefaultX86LogicalInstanceObject::GetParent()
{
if ( m_pParent )
return m_pParent->GetKey();
else
THROWIMEXCEPTION("80043412");;
}
void ProcessorLogicalCpuUsageClass::GetValueImpl()
{
}
void ProcessorLogicalIdleTimeClass::GetValueImpl()
{
//try {
//
// DefaultX86LogicalInstanceObject* pThis = (DefaultX86LogicalInstanceObject*) this->_pThis;
// SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pi[MAX_PROCESSOR];
//
// ULONG num;
// if ( g_fNTQuerySystemInformation( SystemProcessorPerformanceInformation, pi, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)*MAX_PROCESSOR, &num ) == 0 )
// {
// num /= sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
// if ( pThis->m_nIndex < num )
// {
// this->SetValue( pi[pThis->m_nIndex].IdleTime.QuadPart );
// }
// else
// this->SetNull( true );
// }
// else
// this->SetNull( true );
//}
//catch(...) {
// this->SetNull( true );
// THROWIMEXCEPTION("80043423");
//}
this->SetNull( true );
}
void ProcessorLogicalKernelTimeClass::GetValueImpl()
{
//try {
//
// DefaultX86LogicalInstanceObject* pThis = (DefaultX86LogicalInstanceObject*) this->_pThis;
// SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pi[MAX_PROCESSOR];
//
// ULONG num;
// if ( g_fNTQuerySystemInformation( SystemProcessorPerformanceInformation, pi, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)*MAX_PROCESSOR, &num ) == 0 )
// {
// num /= sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
// if ( pThis->m_nIndex < num )
// {
// this->SetValue( pi[pThis->m_nIndex].KernelTime.QuadPart );
// }
// else
// this->SetNull( true );
// }
// else
// this->SetNull( true );
//}
//catch(...) {
// this->SetNull( true );
// THROWIMEXCEPTION("80043424");
//}
this->SetNull( true );
}
void ProcessorLogicalUserTimeClass::GetValueImpl()
{
//try {
//
// DefaultX86LogicalInstanceObject* pThis = (DefaultX86LogicalInstanceObject*) this->_pThis;
// SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION pi[MAX_PROCESSOR];
//
// ULONG num;
// if ( g_fNTQuerySystemInformation( SystemProcessorPerformanceInformation, pi, sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION)*MAX_PROCESSOR, &num ) == 0 )
// {
// num /= sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION);
// if ( pThis->m_nIndex < num )
// {
// this->SetValue( pi[pThis->m_nIndex].UserTime.QuadPart );
// }
// else
// this->SetNull( true );
// }
// else
// this->SetNull( true );
//}
//catch(...) {
// this->SetNull( true );
// THROWIMEXCEPTION("80043425");
//}
this->SetNull( true );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -