diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/sdktools/cpustres | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/sdktools/cpustres')
-rw-r--r-- | private/sdktools/cpustres/cpustres.cpp | 72 | ||||
-rw-r--r-- | private/sdktools/cpustres/cpustres.h | 37 | ||||
-rw-r--r-- | private/sdktools/cpustres/cpustres.ico | bin | 0 -> 1078 bytes | |||
-rw-r--r-- | private/sdktools/cpustres/cpustres.rc | 349 | ||||
-rw-r--r-- | private/sdktools/cpustres/cpustres.rc2 | 13 | ||||
-rw-r--r-- | private/sdktools/cpustres/makefile | 6 | ||||
-rw-r--r-- | private/sdktools/cpustres/resource.h | 35 | ||||
-rw-r--r-- | private/sdktools/cpustres/sources | 52 | ||||
-rw-r--r-- | private/sdktools/cpustres/stdafx.cpp | 6 | ||||
-rw-r--r-- | private/sdktools/cpustres/stdafx.h | 16 | ||||
-rw-r--r-- | private/sdktools/cpustres/stresdlg.cpp | 716 | ||||
-rw-r--r-- | private/sdktools/cpustres/stresdlg.h | 84 |
12 files changed, 1386 insertions, 0 deletions
diff --git a/private/sdktools/cpustres/cpustres.cpp b/private/sdktools/cpustres/cpustres.cpp new file mode 100644 index 000000000..c469b5bf5 --- /dev/null +++ b/private/sdktools/cpustres/cpustres.cpp @@ -0,0 +1,72 @@ +// CpuStres.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "CpuStres.h" +#include "StresDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CCpuStresApp + +BEGIN_MESSAGE_MAP(CCpuStresApp, CWinApp) + //{{AFX_MSG_MAP(CCpuStresApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CCpuStresApp construction + +CCpuStresApp::CCpuStresApp() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CCpuStresApp object + +CCpuStresApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CCpuStresApp initialization + +BOOL CCpuStresApp::InitInstance() +{ + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + CStressDlg dlg; + m_pMainWnd = &dlg; + int nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: Place code here to handle when the dialog is + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // TODO: Place code here to handle when the dialog is + // dismissed with Cancel + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} diff --git a/private/sdktools/cpustres/cpustres.h b/private/sdktools/cpustres/cpustres.h new file mode 100644 index 000000000..d0ce6f42c --- /dev/null +++ b/private/sdktools/cpustres/cpustres.h @@ -0,0 +1,37 @@ +// CpuStres.h : main header file for the CpuStres application +// + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CCpuStresApp: +// See CpuStres.cpp for the implementation of this class +// + +class CCpuStresApp : public CWinApp +{ +public: + CCpuStresApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CCpuStresApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CCpuStresApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// diff --git a/private/sdktools/cpustres/cpustres.ico b/private/sdktools/cpustres/cpustres.ico Binary files differnew file mode 100644 index 000000000..7eef0bcbe --- /dev/null +++ b/private/sdktools/cpustres/cpustres.ico diff --git a/private/sdktools/cpustres/cpustres.rc b/private/sdktools/cpustres/cpustres.rc new file mode 100644 index 000000000..b0e56aa7a --- /dev/null +++ b/private/sdktools/cpustres/cpustres.rc @@ -0,0 +1,349 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif\r\n" + "#include ""CpuStres.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON DISCARDABLE "CpuStres.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About CpuStres" +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "CpuStres Version 1.0",IDC_STATIC,40,10,119,8,SS_NOPREFIX + LTEXT "Copyright © 1996",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP +END + +IDD_CPU_STRESS_DIALOG DIALOGEX 0, 0, 203, 247 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "CPU Stress" +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Thread 1",IDC_STATIC,7,45,189,45 + CONTROL "Active",IDC_1_ACTIVE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,55,40,10 + LTEXT "Thread Priority:",IDC_STATIC,60,56,50,8 + COMBOBOX IDC_1_PRIORITY,109,54,72,72,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Activity:",IDC_STATIC,60,75,38,8 + COMBOBOX IDC_1_ACTIVITY,109,73,72,45,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Thread 2",IDC_STATIC,7,95,189,45 + CONTROL "Active",IDC_2_ACTIVE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,105,40,10 + COMBOBOX IDC_2_PRIORITY,109,104,72,72,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_2_ACTIVITY,109,123,72,45,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Thread 3",IDC_STATIC,7,145,189,45 + CONTROL "Active",IDC_3_ACTIVE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,155,40,10 + COMBOBOX IDC_3_PRIORITY,109,154,72,72,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_3_ACTIVITY,109,174,72,45,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + GROUPBOX "Thread 4",IDC_STATIC,7,195,189,45 + CONTROL "Active",IDC_4_ACTIVE,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,14,205,40,10 + COMBOBOX IDC_4_PRIORITY,109,204,72,72,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_4_ACTIVITY,109,223,72,45,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Process Priority Class:",IDC_STATIC,14,9,69,8 + COMBOBOX IDC_PROCESS_PRIORITY,109,7,72,38,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + LTEXT "Thread Priority:",IDC_STATIC,60,105,50,8 + LTEXT "Activity:",IDC_STATIC,60,124,38,8 + LTEXT "Thread Priority:",IDC_STATIC,60,156,50,8 + LTEXT "Activity:",IDC_STATIC,60,178,38,8 + LTEXT "Thread Priority:",IDC_STATIC,60,206,50,8 + LTEXT "Activity:",IDC_STATIC,60,225,38,8 + CONTROL "Access Shared Memory",IDC_USE_MEMORY,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,28,91,9 + EDITTEXT IDC_SHARED_MEM_SIZE,109,26,33,14,ES_AUTOHSCROLL | + ES_NUMBER + LTEXT "K-Bytes",IDC_STATIC,145,29,31,10 +END + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "\0" + VALUE "FileDescription", "CpuStrese MFC Application\0" + VALUE "FileVersion", "1, 0, 0, 1\0" + VALUE "InternalName", "CpuStrese\0" + VALUE "LegalCopyright", "Copyright (c) 1996\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "CpuStres.EXE\0" + VALUE "ProductName", "CpuStrese Application\0" + VALUE "ProductVersion", "1, 0, 0, 1\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // !_MAC + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO DISCARDABLE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 210 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END + + IDD_CPU_STRESS_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 196 + TOPMARGIN, 7 + BOTTOMMARGIN, 240 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog Info +// + +IDD_CPU_STRESS_DIALOG DLGINIT +BEGIN + IDC_1_PRIORITY, 0x403, 5, 0 +0x6449, 0x656c, "\000" + IDC_1_PRIORITY, 0x403, 7, 0 +0x6f4c, 0x6577, 0x7473, "\000" + IDC_1_PRIORITY, 0x403, 13, 0 +0x6542, 0x6f6c, 0x2077, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_1_PRIORITY, 0x403, 7, 0 +0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_1_PRIORITY, 0x403, 13, 0 +0x6241, 0x766f, 0x2065, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_1_PRIORITY, 0x403, 8, 0 +0x6948, 0x6867, 0x7365, 0x0074, + IDC_1_PRIORITY, 0x403, 14, 0 +0x6954, 0x656d, 0x4320, 0x6972, 0x6974, 0x6163, 0x006c, + IDC_1_ACTIVITY, 0x403, 4, 0 +0x6f4c, 0x0077, + IDC_1_ACTIVITY, 0x403, 7, 0 +0x654d, 0x6964, 0x6d75, "\000" + IDC_1_ACTIVITY, 0x403, 5, 0 +0x7542, 0x7973, "\000" + IDC_1_ACTIVITY, 0x403, 8, 0 +0x614d, 0x6978, 0x756d, 0x006d, + IDC_2_PRIORITY, 0x403, 5, 0 +0x6449, 0x656c, "\000" + IDC_2_PRIORITY, 0x403, 7, 0 +0x6f4c, 0x6577, 0x7473, "\000" + IDC_2_PRIORITY, 0x403, 13, 0 +0x6542, 0x6f6c, 0x2077, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_2_PRIORITY, 0x403, 7, 0 +0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_2_PRIORITY, 0x403, 13, 0 +0x6241, 0x766f, 0x2065, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_2_PRIORITY, 0x403, 8, 0 +0x6948, 0x6867, 0x7365, 0x0074, + IDC_2_PRIORITY, 0x403, 14, 0 +0x6954, 0x656d, 0x4320, 0x6972, 0x6974, 0x6163, 0x006c, + IDC_2_ACTIVITY, 0x403, 4, 0 +0x6f4c, 0x0077, + IDC_2_ACTIVITY, 0x403, 7, 0 +0x654d, 0x6964, 0x6d75, "\000" + IDC_2_ACTIVITY, 0x403, 5, 0 +0x7542, 0x7973, "\000" + IDC_2_ACTIVITY, 0x403, 8, 0 +0x614d, 0x6978, 0x756d, 0x006d, + IDC_3_PRIORITY, 0x403, 5, 0 +0x6449, 0x656c, "\000" + IDC_3_PRIORITY, 0x403, 7, 0 +0x6f4c, 0x6577, 0x7473, "\000" + IDC_3_PRIORITY, 0x403, 13, 0 +0x6542, 0x6f6c, 0x2077, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_3_PRIORITY, 0x403, 7, 0 +0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_3_PRIORITY, 0x403, 13, 0 +0x6241, 0x766f, 0x2065, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_3_PRIORITY, 0x403, 8, 0 +0x6948, 0x6867, 0x7365, 0x0074, + IDC_3_PRIORITY, 0x403, 14, 0 +0x6954, 0x656d, 0x4320, 0x6972, 0x6974, 0x6163, 0x006c, + IDC_3_ACTIVITY, 0x403, 4, 0 +0x6f4c, 0x0077, + IDC_3_ACTIVITY, 0x403, 7, 0 +0x654d, 0x6964, 0x6d75, "\000" + IDC_3_ACTIVITY, 0x403, 5, 0 +0x7542, 0x7973, "\000" + IDC_3_ACTIVITY, 0x403, 8, 0 +0x614d, 0x6978, 0x756d, 0x006d, + IDC_4_PRIORITY, 0x403, 5, 0 +0x6449, 0x656c, "\000" + IDC_4_PRIORITY, 0x403, 7, 0 +0x6f4c, 0x6577, 0x7473, "\000" + IDC_4_PRIORITY, 0x403, 13, 0 +0x6542, 0x6f6c, 0x2077, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_4_PRIORITY, 0x403, 7, 0 +0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_4_PRIORITY, 0x403, 13, 0 +0x6241, 0x766f, 0x2065, 0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_4_PRIORITY, 0x403, 8, 0 +0x6948, 0x6867, 0x7365, 0x0074, + IDC_4_PRIORITY, 0x403, 14, 0 +0x6954, 0x656d, 0x4320, 0x6972, 0x6974, 0x6163, 0x006c, + IDC_4_ACTIVITY, 0x403, 4, 0 +0x6f4c, 0x0077, + IDC_4_ACTIVITY, 0x403, 7, 0 +0x654d, 0x6964, 0x6d75, "\000" + IDC_4_ACTIVITY, 0x403, 5, 0 +0x7542, 0x7973, "\000" + IDC_4_ACTIVITY, 0x403, 8, 0 +0x614d, 0x6978, 0x756d, 0x006d, + IDC_PROCESS_PRIORITY, 0x403, 5, 0 +0x6449, 0x656c, "\000" + IDC_PROCESS_PRIORITY, 0x403, 7, 0 +0x6f4e, 0x6d72, 0x6c61, "\000" + IDC_PROCESS_PRIORITY, 0x403, 5, 0 +0x6948, 0x6867, "\000" + 0 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_ABOUTBOX "&About CpuStrese..." +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif +#include "CpuStres.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/private/sdktools/cpustres/cpustres.rc2 b/private/sdktools/cpustres/cpustres.rc2 new file mode 100644 index 000000000..620f00751 --- /dev/null +++ b/private/sdktools/cpustres/cpustres.rc2 @@ -0,0 +1,13 @@ +// +// CpuStres.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED + #error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/private/sdktools/cpustres/makefile b/private/sdktools/cpustres/makefile new file mode 100644 index 000000000..6ee4f43fa --- /dev/null +++ b/private/sdktools/cpustres/makefile @@ -0,0 +1,6 @@ +# +# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source +# file to this component. This file merely indirects to the real make file +# that is shared by all the components of NT OS/2 +# +!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/private/sdktools/cpustres/resource.h b/private/sdktools/cpustres/resource.h new file mode 100644 index 000000000..e48f0898d --- /dev/null +++ b/private/sdktools/cpustres/resource.h @@ -0,0 +1,35 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by CpuStres.rc +// +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_CPU_STRESS_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDC_1_PRIORITY 1001 +#define IDC_1_ACTIVITY 1002 +#define IDC_1_ACTIVE 1003 +#define IDC_2_PRIORITY 1004 +#define IDC_2_ACTIVITY 1005 +#define IDC_3_PRIORITY 1007 +#define IDC_3_ACTIVITY 1008 +#define IDC_USE_MEMORY 1009 +#define IDC_4_PRIORITY 1010 +#define IDC_4_ACTIVITY 1011 +#define IDC_2_ACTIVE 1012 +#define IDC_3_ACTIVE 1013 +#define IDC_4_ACTIVE 1014 +#define IDC_PROCESS_PRIORITY 1015 +#define IDC_SHARED_MEM_SIZE 1016 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1017 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/private/sdktools/cpustres/sources b/private/sdktools/cpustres/sources new file mode 100644 index 000000000..0f4ec113d --- /dev/null +++ b/private/sdktools/cpustres/sources @@ -0,0 +1,52 @@ +!IF 0 + +Copyright (c) 1989 Microsoft Corporation + +Module Name: + + sources. + +Abstract: + + This file specifies the target component being built and the list of + sources files needed to build that component. Also specifies optional + compiler switches and libraries that are unique for the component being + built. + + +Author: + + Steve Wood (stevewo) 12-Apr-1990 + +NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl + +!ENDIF + +!ifndef U_UNICODE +U_UNICODE=0 +!endif + +!if $(U_UNICODE) +C_DEFINES=-DUNICODE=1 -D_UNICODE=1 +!endif + +GPSIZE=32 + +USE_MFC=1 + +INCLUDES= + +TARGETNAME=CpuStres +TARGETPATH=obj +TARGETTYPE=LIBRARY + +SOURCES=stdafx.cpp \ + CpuStres.cpp \ + StresDlg.cpp \ + CpuStres.rc + + +UMTYPE=windows +UMLIBS=obj\*\CpuStres.res \ + obj\*\CpuStres.lib +UMAPPL=CpuStres diff --git a/private/sdktools/cpustres/stdafx.cpp b/private/sdktools/cpustres/stdafx.cpp new file mode 100644 index 000000000..2bf20446b --- /dev/null +++ b/private/sdktools/cpustres/stdafx.cpp @@ -0,0 +1,6 @@ +// stdafx.cpp : source file that includes just the standard includes +// HogProg.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + diff --git a/private/sdktools/cpustres/stdafx.h b/private/sdktools/cpustres/stdafx.h new file mode 100644 index 000000000..de1d0ad0c --- /dev/null +++ b/private/sdktools/cpustres/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include <afxcmn.h> // MFC support for Windows 95 Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + + + diff --git a/private/sdktools/cpustres/stresdlg.cpp b/private/sdktools/cpustres/stresdlg.cpp new file mode 100644 index 000000000..62ac35052 --- /dev/null +++ b/private/sdktools/cpustres/stresdlg.cpp @@ -0,0 +1,716 @@ +// StresDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "CpuStres.h" +#include "StresDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CStressDlg dialog + +CStressDlg::CStressDlg(CWnd* pParent /*=NULL*/) + : CDialog(CStressDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CStressDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + m_dwProcessPriority = NORMAL_PRIORITY_CLASS; + + m_ActivityValue[0] = SLOW_ACTIVITY; + m_ActivityValue[1] = SLOW_ACTIVITY; + m_ActivityValue[2] = SLOW_ACTIVITY; + m_ActivityValue[3] = SLOW_ACTIVITY; + + m_PriorityValue[0] = THREAD_PRIORITY_NORMAL; + m_PriorityValue[1] = THREAD_PRIORITY_NORMAL; + m_PriorityValue[2] = THREAD_PRIORITY_NORMAL; + m_PriorityValue[3] = THREAD_PRIORITY_NORMAL; + + m_Active[0] = TRUE; + m_Active[1] = FALSE; + m_Active[2] = FALSE; + m_Active[3] = FALSE; + + m_ThreadHandle[0] = NULL; + m_ThreadHandle[1] = NULL; + m_ThreadHandle[2] = NULL; + m_ThreadHandle[3] = NULL; + + m_dwLoopValue = 0x00010000; + + m_pMemory = NULL; + m_dwVASize = 0; + m_dwRandomScale = 1; +} + +void CStressDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CStressDlg) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CStressDlg, CDialog) + //{{AFX_MSG_MAP(CStressDlg) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_1_ACTIVE, On1Active) + ON_CBN_SELCHANGE(IDC_1_ACTIVITY, OnSelchange1Activity) + ON_CBN_SELCHANGE(IDC_1_PRIORITY, OnSelchange1Priority) + ON_BN_CLICKED(IDC_2_ACTIVE, On2Active) + ON_CBN_SELCHANGE(IDC_2_ACTIVITY, OnSelchange2Activity) + ON_CBN_SELCHANGE(IDC_2_PRIORITY, OnSelchange2Priority) + ON_BN_CLICKED(IDC_3_ACTIVE, On3Active) + ON_CBN_SELCHANGE(IDC_3_ACTIVITY, OnSelchange3Activity) + ON_CBN_SELCHANGE(IDC_3_PRIORITY, OnSelchange3Priority) + ON_BN_CLICKED(IDC_4_ACTIVE, On4Active) + ON_CBN_SELCHANGE(IDC_4_ACTIVITY, OnSelchange4Activity) + ON_CBN_SELCHANGE(IDC_4_PRIORITY, OnSelchange4Priority) + ON_CBN_SELCHANGE(IDC_PROCESS_PRIORITY, OnSelchangeProcessPriority) + ON_EN_KILLFOCUS(IDC_SHARED_MEM_SIZE, OnKillfocusSharedMemSize) + ON_EN_CHANGE(IDC_SHARED_MEM_SIZE, OnChangeSharedMemSize) + ON_BN_CLICKED(IDC_USE_MEMORY, OnUseMemory) + ON_WM_CLOSE() + ON_WM_DESTROY() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// disable optimization since it will remove the "do-nothing" loops +#pragma optimize ("", off) +DWORD CStressDlg::OnePercentCalibration(DWORD dwLoopValue) +{ + // find how many loops consume 10% of this processor + LARGE_INTEGER liPerfFreq; + LONGLONG llOnePercent; + LARGE_INTEGER liStartTime; + LARGE_INTEGER liEndTime; + LONGLONG llDiff; + LONGLONG llMinDiff; + DWORD dwPriorityClass; + DWORD dwThreadPriority; + HANDLE hProcess; + HANDLE hThread; + DWORD dwLoopCounter; + DWORD dwReturn; + LONGLONG llResult; + BOOL bGoodSample = FALSE; + DWORD dwAttemptCount = 5; + + dwReturn = dwLoopValue; + QueryPerformanceFrequency (&liPerfFreq); + llOnePercent = liPerfFreq.QuadPart / 100; + // the calibration run must take at least 50 ms + llMinDiff = liPerfFreq.QuadPart / 20; + + hProcess = GetCurrentProcess(); + hThread = GetCurrentThread(); + dwPriorityClass = GetPriorityClass (hProcess); + dwThreadPriority = GetThreadPriority (hThread); + + SetPriorityClass (hProcess, HIGH_PRIORITY_CLASS); + SetThreadPriority (hThread, THREAD_PRIORITY_HIGHEST); + + while (!bGoodSample && dwAttemptCount) { + // start timing + QueryPerformanceCounter (&liStartTime); + // do a trial loop + for (dwLoopCounter = dwLoopValue; dwLoopCounter; dwLoopCounter--); + // end timing + QueryPerformanceCounter (&liEndTime); + llDiff = liEndTime.QuadPart - liStartTime.QuadPart; + if (llDiff > llMinDiff) { + bGoodSample = TRUE; + } else { + // increase the loop counter value by a factor of 10 + dwLoopValue *= 10; + dwAttemptCount--; + } + } + // restore the priority since we're done with the critical part + SetPriorityClass (hProcess, dwPriorityClass); + SetThreadPriority (hThread, dwThreadPriority); + + if (!bGoodSample) { + MessageBox("Unable to calibrate delay loop"); + } else { + // findout what the 1% count is + + if (llDiff != llOnePercent) { + // then adjust the initial loop value was too big so reduce + llResult = llOnePercent * dwLoopValue / llDiff; + if (llResult & 0xFFFFFFFF00000000) { + // this processor is TOO FAST! so don't change. + } else { + dwReturn = (DWORD)(llResult & 0x00000000FFFFFFFF); + } + } + } + return dwReturn; +} + +DWORD WorkerProc (LPDWORD dwArg) +{ + DWORD dwLoopCounter; + LPTHREAD_INFO_BLOCK pInfo; + DWORD dwStartingValue; + DWORD dwLocalValue; + DWORD dwLocalIndex; + + pInfo = (LPTHREAD_INFO_BLOCK)dwArg; + + dwStartingValue = pInfo->Dlg->m_dwLoopValue; + + srand( (unsigned)time( NULL ) ); + + while (pInfo->Dlg->m_Active[pInfo->dwId]) { + for (dwLoopCounter = dwStartingValue; dwLoopCounter; dwLoopCounter--) { + if (pInfo->Dlg->m_pMemory != NULL) { + do { + dwLocalIndex = rand(); + dwLocalIndex *= pInfo->Dlg->m_dwRandomScale; + } while (dwLocalIndex >= pInfo->Dlg->m_dwVASize); + pInfo->Dlg->m_pMemory[dwLocalIndex] = dwLocalIndex; + dwLocalValue = pInfo->Dlg->m_pMemory[dwLocalIndex]; + // reduce loop iterations to account for + // accessing memory + if (pInfo->Dlg->m_Active[pInfo->dwId]) { + if (dwLoopCounter > 20) { + dwLoopCounter -= 20; + } else { + dwLoopCounter = 1; + } + } else { + break; // out of loop + } + } + } + if (pInfo->Dlg->m_ActivityValue[pInfo->dwId] > 0) { + Sleep (pInfo->Dlg->m_ActivityValue[pInfo->dwId]); + } + } + pInfo->Dlg->m_ThreadHandle[pInfo->dwId] = NULL; + delete pInfo; + return 0; +} +#pragma optimize ("", on) + +void CStressDlg::CreateWorkerThread (DWORD dwId) +{ + DWORD dwThreadId; + LPTHREAD_INFO_BLOCK pInfo; + + // then start a new thread + pInfo = new THREAD_INFO_BLOCK; + pInfo->Dlg = this; + pInfo->dwId = dwId; + m_Active[dwId] = TRUE; + m_ThreadHandle[dwId] = CreateThread ( + NULL, 0, + (LPTHREAD_START_ROUTINE)WorkerProc, + (LPVOID)pInfo, 0, &dwThreadId); + if (m_ThreadHandle[dwId] == NULL) { + m_Active[dwId] = FALSE; + } else { + // establish thread priority + SetThreadPriority ( + m_ThreadHandle[dwId], + m_PriorityValue[dwId]); + } +} + +void CStressDlg::SetThreadActivity (CComboBox * cActivityCombo, DWORD dwId) +{ + switch (cActivityCombo->GetCurSel()) { + case 0: + m_ActivityValue[dwId] = SLOW_ACTIVITY; + break; + case 1: + m_ActivityValue[dwId] = MEDIUM_ACTIVITY; + break; + case 2: + m_ActivityValue[dwId] = HIGH_ACTIVITY; + break; + case 3: + m_ActivityValue[dwId] = HOG_ACTIVITY; + break; + } +} + +void CStressDlg::SetThreadPriorityLevel (CComboBox * cPriorityCombo, DWORD dwId) +{ + LONG lLastError = ERROR_SUCCESS; + + switch (cPriorityCombo->GetCurSel()) { + case 0: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_IDLE; + break; + case 1: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_LOWEST; + break; + case 2: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_BELOW_NORMAL; + break; + case 3: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_NORMAL; + break; + case 4: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_ABOVE_NORMAL; + break; + case 5: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_HIGHEST; + break; + case 6: + m_PriorityValue[dwId] = (DWORD)THREAD_PRIORITY_TIME_CRITICAL; + break; + } + if (m_ThreadHandle[dwId] != NULL) { + if (!SetThreadPriority (m_ThreadHandle[dwId], m_PriorityValue[dwId])) { + lLastError = GetLastError (); + } + } // else no thread open +} + +///////////////////////////////////////////////////////////////////////////// +// CStressDlg message handlers + +BOOL CStressDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Add "About..." menu item to system menu. + + // IDM_ABOUTBOX must be in the system command range. + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + CString strAboutMenu; + strAboutMenu.LoadString(IDS_ABOUTBOX); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + + // calibrate loop counter + m_dwLoopValue = OnePercentCalibration (m_dwLoopValue) * 10; + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + // set the priority of this thread to "highest" so the UI will be + // responsive + SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_HIGHEST); + + // enable thread 1 & disable all others + ((CComboBox *)GetDlgItem(IDC_PROCESS_PRIORITY))->SetCurSel(1); + + CheckDlgButton (IDC_1_ACTIVE, 1); + ((CComboBox *)GetDlgItem(IDC_1_PRIORITY))->SetCurSel(3); + ((CComboBox *)GetDlgItem(IDC_1_ACTIVITY))->SetCurSel(0); + + CheckDlgButton (IDC_2_ACTIVE, 0); + ((CComboBox *)GetDlgItem(IDC_2_PRIORITY))->SetCurSel(3); + ((CComboBox *)GetDlgItem(IDC_2_ACTIVITY))->SetCurSel(0); + + CheckDlgButton (IDC_3_ACTIVE, 0); + ((CComboBox *)GetDlgItem(IDC_3_PRIORITY))->SetCurSel(3); + ((CComboBox *)GetDlgItem(IDC_3_ACTIVITY))->SetCurSel(0); + + CheckDlgButton (IDC_4_ACTIVE, 0); + ((CComboBox *)GetDlgItem(IDC_4_PRIORITY))->SetCurSel(3); + ((CComboBox *)GetDlgItem(IDC_4_ACTIVITY))->SetCurSel(0); + + // set the process priority + OnSelchangeProcessPriority(); + + // start the first thread + On1Active(); + + // don't access memory by default + CheckDlgButton (IDC_USE_MEMORY, 0); + (GetDlgItem (IDC_SHARED_MEM_SIZE))->EnableWindow (FALSE); + + return TRUE; // return TRUE unless you set the focus to a control +} + +void CStressDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialog::OnSysCommand(nID, lParam); + } +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CStressDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CStressDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + +void CStressDlg::On1Active() +{ + DWORD dwId = 0; + + if (IsDlgButtonChecked(IDC_1_ACTIVE)) { + if (m_ThreadHandle[dwId] == NULL) { + CreateWorkerThread (dwId); + } else { + // thread is already running + } + } else { + m_Active[dwId] = FALSE; + m_ThreadHandle[dwId] = NULL; + } +} + +void CStressDlg::OnSelchange1Activity() +{ + CComboBox * cActivityCombo; + DWORD dwId = 0; + + cActivityCombo = (CComboBox *)GetDlgItem (IDC_1_ACTIVITY); + SetThreadActivity (cActivityCombo, dwId); +} + +void CStressDlg::OnSelchange1Priority() +{ + CComboBox * cPriorityCombo; + DWORD dwId = 0; + + cPriorityCombo = (CComboBox *)GetDlgItem (IDC_1_PRIORITY); + SetThreadPriorityLevel (cPriorityCombo, dwId); +} + +void CStressDlg::On2Active() +{ + DWORD dwId = 1; + + if (IsDlgButtonChecked(IDC_2_ACTIVE)) { + if (m_ThreadHandle[dwId] == NULL) { + CreateWorkerThread (dwId); + } else { + // thread is already running + } + } else { + m_Active[dwId] = FALSE; + m_ThreadHandle[dwId] = NULL; + } +} + +void CStressDlg::OnSelchange2Activity() +{ + CComboBox * cActivityCombo; + DWORD dwId = 1; + + cActivityCombo = (CComboBox *)GetDlgItem (IDC_2_ACTIVITY); + SetThreadActivity (cActivityCombo, dwId); +} + +void CStressDlg::OnSelchange2Priority() +{ + CComboBox * cPriorityCombo; + DWORD dwId = 1; + + cPriorityCombo = (CComboBox *)GetDlgItem (IDC_2_PRIORITY); + SetThreadPriorityLevel (cPriorityCombo, dwId); +} + +void CStressDlg::On3Active() +{ + DWORD dwId = 2; + + if (IsDlgButtonChecked(IDC_3_ACTIVE)) { + if (m_ThreadHandle[dwId] == NULL) { + CreateWorkerThread (dwId); + } else { + // thread is already running + } + } else { + m_Active[dwId] = FALSE; + m_ThreadHandle[dwId] = NULL; + } +} + +void CStressDlg::OnSelchange3Activity() +{ + CComboBox * cActivityCombo; + DWORD dwId = 2; + + cActivityCombo = (CComboBox *)GetDlgItem (IDC_3_ACTIVITY); + SetThreadActivity (cActivityCombo, dwId); +} + +void CStressDlg::OnSelchange3Priority() +{ + CComboBox * cPriorityCombo; + DWORD dwId = 2; + + cPriorityCombo = (CComboBox *)GetDlgItem (IDC_3_PRIORITY); + SetThreadPriorityLevel (cPriorityCombo, dwId); +} + +void CStressDlg::On4Active() +{ + DWORD dwId = 3; + + if (IsDlgButtonChecked(IDC_4_ACTIVE)) { + if (m_ThreadHandle[dwId] == NULL) { + CreateWorkerThread (dwId); + } else { + // thread is already running + } + } else { + m_Active[dwId] = FALSE; + CloseHandle (m_ThreadHandle[dwId]); + m_ThreadHandle[dwId] = NULL; + } +} + +void CStressDlg::OnSelchange4Activity() +{ + CComboBox * cActivityCombo; + DWORD dwId = 3; + + cActivityCombo = (CComboBox *)GetDlgItem (IDC_4_ACTIVITY); + SetThreadActivity (cActivityCombo, dwId); +} + +void CStressDlg::OnSelchange4Priority() +{ + CComboBox * cPriorityCombo; + DWORD dwId = 3; + + cPriorityCombo = (CComboBox *)GetDlgItem (IDC_4_PRIORITY); + SetThreadPriorityLevel (cPriorityCombo, dwId); +} + +void CStressDlg::OnOK() +{ + CDialog::OnOK(); +} + +void CStressDlg::OnSelchangeProcessPriority() +{ + + CComboBox * cPriorityCombo; + DWORD dwPriorityClass; + + cPriorityCombo = (CComboBox *)GetDlgItem (IDC_PROCESS_PRIORITY); + + switch (cPriorityCombo->GetCurSel()) { + case 0: + dwPriorityClass = IDLE_PRIORITY_CLASS; + break; + case 1: + dwPriorityClass = NORMAL_PRIORITY_CLASS; + break; + case 2: + dwPriorityClass = HIGH_PRIORITY_CLASS; + break; + } + SetPriorityClass (GetCurrentProcess(), dwPriorityClass); +} + +void CStressDlg::OnKillfocusSharedMemSize() +{ + return; +} + +void CStressDlg::OnChangeSharedMemSize() +{ + CString csMemSize; + TCHAR szOldValue[MAX_PATH]; + DWORD dwMemSize; + + csMemSize.Empty(); + GetDlgItemText (IDC_SHARED_MEM_SIZE, csMemSize); + dwMemSize = _tcstoul ((LPCTSTR)csMemSize, NULL, 10); + dwMemSize *= 1024 / sizeof(DWORD); + + if (dwMemSize != m_dwVASize) { + // threads must be stopped to change memory size + if (m_Active[0] || m_Active[1] || m_Active[2] || m_Active[3]) { + MessageBox ( + TEXT("All threads must be stopped before this value can be changed")); + _stprintf (szOldValue, TEXT("%d"), ((m_dwVASize * sizeof(DWORD))/1024)); + (GetDlgItem(IDC_SHARED_MEM_SIZE))->SetWindowText(szOldValue); + return; + } else { + if (m_pMemory != NULL) { + delete (m_pMemory); + m_pMemory = NULL; + m_dwVASize = 0; + } + m_dwVASize = dwMemSize; + m_pMemory = new DWORD[m_dwVASize]; + if (m_pMemory == NULL) { + m_dwVASize = 0; + } + } + } +} + +void CStressDlg::OnUseMemory() +{ + CString csMemSize; + DWORD dwMemSize; + BOOL bState; + + if (m_Active[0] || m_Active[1] || m_Active[2] || m_Active[3]) { + MessageBox (TEXT("All threads must be stopped before this value can be changed")); + bState = !IsDlgButtonChecked(IDC_USE_MEMORY); //revert state + } else { + if (IsDlgButtonChecked(IDC_USE_MEMORY)) { + // if no memory is allocated, then allocate it + if (m_pMemory != NULL) { + delete (m_pMemory); + m_pMemory = NULL; + m_dwVASize = 0; + } + //get va size + csMemSize.Empty(); + GetDlgItemText (IDC_SHARED_MEM_SIZE, csMemSize); + dwMemSize = _tcstoul ((LPCTSTR)csMemSize, NULL, 10); + m_dwVASize = dwMemSize * 1024 / sizeof(DWORD); + m_pMemory = new DWORD[m_dwVASize]; + if (m_pMemory == NULL) { + m_dwVASize = 0; + } else { + m_dwRandomScale = (m_dwVASize / RAND_MAX) + 1; + } + bState = TRUE; + } else { + // button is unchecked so free memory + if (m_pMemory != NULL) { + delete (m_pMemory); + m_pMemory = NULL; + m_dwVASize = 0; + } + bState = FALSE; + } + } + CheckDlgButton (IDC_USE_MEMORY, bState); + (GetDlgItem (IDC_SHARED_MEM_SIZE))->EnableWindow (bState); +} + +void CStressDlg::OnClose() +{ + // stop threads first + m_Active[0] = FALSE; + m_Active[1] = FALSE; + m_Active[2] = FALSE; + m_Active[3] = FALSE; + + // wait for the threads to finish + while (m_ThreadHandle[0] || m_ThreadHandle[1] || + m_ThreadHandle[2] || m_ThreadHandle[3]) { + Sleep(100); + } + + // free memory block + if (m_pMemory != NULL) { + delete (m_pMemory); + m_pMemory = NULL; + m_dwVASize = 0; + } + + CDialog::OnClose(); +} + +void CStressDlg::OnDestroy() +{ + CDialog::OnDestroy(); +} diff --git a/private/sdktools/cpustres/stresdlg.h b/private/sdktools/cpustres/stresdlg.h new file mode 100644 index 000000000..6cbc390bb --- /dev/null +++ b/private/sdktools/cpustres/stresdlg.h @@ -0,0 +1,84 @@ +// StresDlg.h : header file +// +#define SLOW_ACTIVITY 640 +#define MEDIUM_ACTIVITY 320 +#define HIGH_ACTIVITY 80 +#define HOG_ACTIVITY 0 + +///////////////////////////////////////////////////////////////////////////// +// CStressDlg dialog + +class CStressDlg : public CDialog +{ +// Construction +public: + CStressDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CStressDlg) + enum { IDD = IDD_CPU_STRESS_DIALOG }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CStressDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +public: + DWORD m_dwProcessPriority; + DWORD m_ActivityValue[4]; + DWORD m_PriorityValue[4]; + DWORD m_Active[4]; + HANDLE m_ThreadHandle[4]; + DWORD m_dwLoopValue; + + // working memory variables + LPDWORD m_pMemory; + DWORD m_dwVASize; // in DWORD elements + DWORD m_dwRandomScale; + +protected: + HICON m_hIcon; + + void CreateWorkerThread (DWORD); + void SetThreadActivity (CComboBox *, DWORD); + void SetThreadPriorityLevel (CComboBox *, DWORD); + DWORD OnePercentCalibration(DWORD); + + // Generated message map functions + //{{AFX_MSG(CStressDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void On1Active(); + afx_msg void OnSelchange1Activity(); + afx_msg void OnSelchange1Priority(); + afx_msg void On2Active(); + afx_msg void OnSelchange2Activity(); + afx_msg void OnSelchange2Priority(); + afx_msg void On3Active(); + afx_msg void OnSelchange3Activity(); + afx_msg void OnSelchange3Priority(); + afx_msg void On4Active(); + afx_msg void OnSelchange4Activity(); + afx_msg void OnSelchange4Priority(); + virtual void OnOK(); + afx_msg void OnSelchangeProcessPriority(); + afx_msg void OnKillfocusSharedMemSize(); + afx_msg void OnChangeSharedMemSize(); + afx_msg void OnUseMemory(); + afx_msg void OnClose(); + afx_msg void OnDestroy(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +typedef struct _ThreadInfoBlock { + CStressDlg * Dlg; + DWORD dwId; +} THREAD_INFO_BLOCK, FAR * LPTHREAD_INFO_BLOCK; + |