Systems Internals Tips and Trivia | |||||||||||||||||||||||||||||||||||||||||
Copyright © 1996-1998 Mark Russinovich | |||||||||||||||||||||||||||||||||||||||||
Last
Updated July 30, 1998
Miscellaneous NT Information |
|||||||||||||||||||||||||||||||||||||||||
Introduction | This page is an ever-expanding collection of NT information that we accumulate over time. You'll find practical tips as well useless trivia, with new items added at the top of the page. | ||||||||||||||||||||||||||||||||||||||||
BOOT.INI Option Reference | There
are number of BOOT.INI switches that are useful for driver developers
that wish to test their drivers under a variety of different system
configurations without having to have a seperate machine for every one.
For example, limiting the amount of memory NT sees can be useful for
stressing memory loads, and limiting the number of processors for
testing scalability. I've compiled a complete list of the options that
BOOT.INI currently supports.
|
||||||||||||||||||||||||||||||||||||||||
Hidden Registry Keys? | A
subtle but significant difference between the Win32 API and the Native
API (see Inside the Native API for
more information on this largely undocumented interface) is the way that
names are described. In the Win32 API strings are interpreted as
NULL-terminated ANSI (8-bit) or wide character (16-bit) strings. In the
Native API names are counted Unicode (16-bit) strings. While
this distinction is usually not important, it leaves open an interesting
situation: there is a class of names that can be referenced using the
Native API, but that cannot be described using the Win32 API. How is this possible? The answer is that a name which is a counted Unicode string can explicitly include NULL characters (0) as part of the name. For example, "Key\0". To include the NULL at the end the length of the Unicode string is specified as 4. There is absolutely no way to specify this name using the Win32 API since if "Key\0" is passed as a name, the API will determine that the name is "Key" (3 characters in length) because the "\0" indicates the end of the name. When a key (or any other object with a name such as a named Event, Semaphore or Mutex) is created with such a name any applications using the Win32 API will be unable to open the name, even though they might seem to see it. The program below, RegHide(source code is included), illustrates this point. It creates a key called "HKEY_LOCAL_MACHINE\Software\Systems Internals\Can't touch me!\0" using the Native API, and inside this key it creates a value. Then the program pauses to give you an opportunity to see if you can view the value using any Registry editor you have handy (Regedit, Regedt32 or a third-party Registry editor). Because Regedit and Regedt32 (and likely an third party Registry editor) use the Win32 API, they will see the key listed as a child of Systems Internals, but when you try to open the key you'll get an error. This is because the Registry editor will try to open "Can't touch me!" without the trailing NULL (which is interpreted as the end of the string) and won't find this name. After you've verified this exit the program and this special key will be deleted. Download RegHide (24KB) |
||||||||||||||||||||||||||||||||||||||||
Fault Tolerance on Workstation? |
One of
the differences I highlighted in my November 1996 Windows NT
Magazine article, "Inside the Difference Between Windows NT
Workstation and Windows NT Server," was that fault tolerant disk
configurations are only available on Server. This is because the Windows
NT disk administrative program, Windisk.exe, checks to see if
its running on a Workstation, and if so, does not display its Fault
Tolerance menu, which contains the entries that are used to create
mirrors and parity striped sets.
It turns out that whoever wrote the Workstation Resource Kit program FTEDIT was unaware of Microsoft's official policy on fault tolerance and Workstation: it appears you can use this utility to create mirrors and striped sets with parity on Workstations. Update: several people have complained that this doesn't work, which isn't surprising since I left out an important step: the Fault-tolerant disk driver must be enabled. If you have an existing volume-set then it is already is, but if you don't, use a Registry editor to set the value of:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\FtDisk\Start to 0. The next time you boot your workstation, the fault-tolerant drives you have created will be functional. |
||||||||||||||||||||||||||||||||||||||||
The Native API | NT's native API are services that are core operating system services available to device drivers and user-mode applications. The Win32 subsystem relies heavily on this API, as do many Microsoft Windows NT Resource Kit utilities. There are over 200 system calls in NT's native API and only 21 of them are documented by Microsoft. | ||||||||||||||||||||||||||||||||||||||||
Idle Trivia | Did you
know that unlike all the other threads in an NT system, the idle-thread
executes at an IRQL (interrupt request level) of DISPATCH_LEVEL (rather
than PASSIVE_LEVEL)? See Advanced DPCs
for more information. On uniprocessor x86 systems the idle-thread actually performs a HLT (Halt) instruction, which effectively turns the CPU off to everything except for hardware interrupts. |
||||||||||||||||||||||||||||||||||||||||
Never-ending Quantum? | In NT, as with most time-sharing operating systems, threads run in turns called quantums. Normally, a thread executes until its quantum runs out. The next time it is scheduled it starts with a full quantum. However, in NT a thread also gets its quantum refreshed every time its thread or process priority is set. This means that a thread can reset its quantum by calling SetThreadPriority (without changing its priority) before its turn runs out. If it continues to do this it will effectively have an infinite quantum. Why does NT do this? Its not clear, but it appears to be a bug. | ||||||||||||||||||||||||||||||||||||||||
NTOSKRNL's Main |
NTOSKRNL.EXE,
the core file of the kernel-mode component of Windows NT, contains the
Cache Manager, the Executive, the Kernel, the Security Reference
Monitor, the Memory Manager, and the Scheduler, among other things, and
is in charge of getting NT up and running. You may be surprised to know
that it has a standard main() that is executed when it is loaded by the
OSLOADER:
//
|
||||||||||||||||||||||||||||||||||||||||
Tuning Workstation for Server-like Loads |
NT
Workstation and NT Server have vastly different performance
characteristics due to the internal tuning that the NT operating system,
which is identical on both, performs. Most tuning parameters are
inaccessible, but a few are located in the Registry. If you are running
Server and you double-click on the Server entry of the Services tab in
the Control Panel's Network applet, you will get a dialog that lets you
determine what type of application you want the machine to be tuned for.
Choices let you select between "Minimize Memory Used", "Balance",
"Maximize Usage for File Sharing", and "Maximize Usage
for Network Applications". This dialog box is not presented on
Workstation installations. The various selections actually change the
values of two Registry values:
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\LargeSystemCache and HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\Size This table (which was derived from sessions with NTRegmon) presents the settings you should select on a Workstation to achieve the same effect you would get using the dialog box were your system a Server.
|
||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||