Share via

Master Your Quantum

In my last blog article I described thread quantum and, at the end of the article, mentioned that one could change this value. Readers, who were driven nuts by my meager attempt to create suspense, could have searched MSDN on their own to find how to change the quantum setting using the Performance Options system dialog. This dialog only lets one change the quantum to favor foreground or background processes. There are, however, a total of seven functionally unique setting for the quantum.

The Performance Options dialog, it turns out, manipulates system registry value HKLM\SYSTEM \CurrentControlSet\ Control\ PriorityControl\ Win32PrioritySeparation. The Win32PrioritySeparation default value is 2 for XPe or XP Pro (and other versions of the Windows OS family, but you’re reading the wrong blog if you’re interested in them). The Performance Options dialog changes the value of Win32PrioritySeparation to either hexadecimal value 0x26, if you select the “Foreground” option, or 0x18, if you select the “Background” option.

If you’re like me, I found this all a bit odd. Well, Win32PrioritySeparation is composed of three 2-bit bit fields. The most significant bit field, represented by bits 0x10 and 0x20, determine if long or short quantum will be used. Bits represented by 0x04 and 0x08 determine if the foreground threads will get more quantum than background threads (i.e. a boost) or they will get the same quantum. The two least significant bits, 0x01 and 0x02, are used, if foreground boost is enabled, to determine the amount of the boost.

Even though I’m an avid bit twiddler, I’ll resist the urge to go into more detail. So here are the seven functionally unique settings for Win32PrioritySeparation with the resulting foreground and background quantums.

Win32PrioritySeparation Foreground Background
0x28, 0x29, 0x2A 18 18
0x18, 0x19, 0x1A 36 36
0x24 6 6
0x25, 0x14 12 6
0x26 18 6
0x15 24 6
0x16 36 6

Please remember from my last article to divide the quantum by 3 to get the number of clock ticks each thread will receive. Changing Win32PrioritySeparation does not require a restart to see the effect. Also, setting a bit field in Win32PrioritySeparation to values other than those shown in the table will result in the default option being selected. Of course, this all pertains to XPe and XP Pro and there’s no guarantee that the scheduling gurus will conform to the same pattern of behavior in the future.

- Jim