slight.frost.byte                          Login
Feb
2

Vista Kernel Improvements

Series - Vista Kernel

  1. Vista Laptops Won't Melt in Your Bag Anymore
  2. Vista Kernel Improvements

There have been numerous improvements to the Vista kernel which greatly improve user experiences and deterministic application behavior. I’ve mentioned one such improvement earlier in my post about Vista not melting laptops (a form of I/O cancellation I talk about below), and will mention a few others here. I learned about these improvements by attending a lecture from Mark Russinovich from SysInternals fame a few months back.

Better Thread Fairness

In prior versions of Windows, the kernel scheduler had to make some rather unfair assumptions about thread execution time because CPU cycle counters (these registers are available in modern processors) were not taken into consideration. By way of example, in Windows XP, if both thread-A and thread-B have the same priority and are ready to be run at the same time, one is chosen (let’s say thread-A) and is executed for a pre-defined time slice. However, if another higher priority thread comes along during thread-A’s execution, the scheduler will interrupt thread-A and run the higher priority thread. The scheduler doesn’t keep track of this though, so sticks with its assumption that thread-A ran for the entire time slice even though it ran for much less because of the interruption. After the time slice is up, thread-B is ran; which if un-interrupted, is free to run for the entire time slice (same amount of time thread-A was supposed to get). In this situation, thread-B got much more CPU time than thread-A, even though they had the same priority.

In Vista, the scheduler makes use of cycle counter registers in modern processors, and is able to estimate how many cycles a thread uses per clock tick. This way, the scheduler can divvy up CPU time much more fairly. For the example above, thread-A would be allowed to run for another time slice after being interrupted, before thread-B would be allowed to execute. Now this scheme isn’t completely fair (I’m not sure it’s feasible to be 100% fair) because thread-A would actually get a few more ticks of execution time than thread-b, but it is *much more* fair than Windows XP and before.

Multimedia Class Scheduling

Multimedia (audio/video) is a core scenario for Vista, and as such, it is critical that these experiences are great even in the face of concurrently running, resource sucking, applications. A great example is if you are watching a high-resolution video with Windows Media Player on XP and anti-virus scanning kicks into action in the background. It’s likely you’ll see video glitches. To remedy this, Windows Vista introduces the Multimedia Class Scheduling Service (MMCSS) to manage CPU priorities of multimedia threads.

Multimedia applications like Media Center and Media Player can register with this new service via newly available Vista APIs for describing their characteristics. The characteristics have to be one described in this registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks

MMCSS manages the priorities of registered multimedia applications, while at the same time, ensuring that they don’t starve other applications. If you were to try the above example on Vista (media player with anti-virus concurrently), you’d see the video playback glitch free.

I/O Completion Performance & Cancellation

A common approach for doing asynchronous I/O is to use completion ports; which is a programming construct for use as a synchronization object. Prior to Vista, when such an I/O completed, the thread which issued the I/O is the same that executes the I/O completion work. This required a context switch that introduced a performance penalty (especially if there is a lot of I/O). Once the I/O completed, the I/O system would update the completion port status to wake up a thread monitoring its status.

On Vista, the I/O completion processing is done by the thread that is waiting for the completion port to be updated. The very minor change negates the need for thread scheduling and the context switches that can degrade an application’s (and system’s) overall performance. Even better, the results of multiple I/O operations from a completion can be retrieved with a single request, avoiding transitions to kernel mode from a user mode application.

A new capability for Vista is I/O cancellation prior to reaching timeouts. You’ve experienced not being able to cancel an I/O operation if you have ever tried to cancel (Ctrl + C) an attempt to access an offline network share; you had to wait until the timeout expired while the system was unresponsive. Now in Vista, you can cancel these operations! In fact, most I/O operations can be canceled (I’m not sure which ones can’t be) including the open file I/O that net view and Explorer use. If 3rd party applications don’t rely on the file I/O provided by Windows, they will have to update to support the new cancellation capability.

I/O Priority

Finally! My background processes like search indexing, anti-virus, malware scans, disk defragments, etc. won’t bog down foreground tasks. Vista enables both I/O priority for individual operations, as well as I/O bandwidth reservations. Note I’m talking about disk bandwidth, not network bandwidth (Windows doesn’t support network bandwidth reservations for good reason). All the background processes built-in to Vista use low I/O priority (Windows Defender, search indexing, etc.), but 3rd party applications (think Anti-Virus) have to take advantage of this capability to provide a better user experience. Regarding I/O bandwidth reservations, applications like Windows Media Player use this to ensure local playback of multimedia files is glitch free. Disk I/O priority combined with process priority provided by MMCSS discussed above enables a really great user experience of multimedia, even in the presence of other substantial system activity.

There are *many* other kernel improvements that I haven’t discussed here, but hopefully I’ll get to those in future posts. If there are any other areas folks have interest in, let me know. I’ll do my best to provide details.

Posted in windows vista |

4 Responses

  1. Mark Muehlbauer Says:

    Thank you for that. So often I hear how XP is good enough. This topology on multi-cpu hardware environments will be especially beneficial. Conversly, this is the marketing area, in my opinion, Microsoft has failed to expose for the simple end user scenario. Analogies are great and easy to understand. I won’t go into detail but again, it is my opinion that MS really dropped the ball in the area of making Vista handle the problems of tomorrow while at the same time not shooting their own foot. . errr XP. . .
    I mean, if I’m on the phone there is no way I can also write this response at the same time and watch TV while trying to get my better half to stop. . umm. . ah. . .never mind :)

  2. Mark Muehlbauer Says:

    Sorry Gabe, don’t know where best to add this. . but it is ticking me off! Vista is out, yet some of my favorite hardware is lacking in driver support. Previous operating systms from MS have gone through hell because 3rd party drivers were written poorly. I understand the rock and hard spot situations here and understanding what you just wrote I really wonder what is up these people’s a.. . .minds when it comes to getting a driver available by the time Vista has become available. It’s a damn car with out the tires. I am an audiophile and love to game. I want my tires. . .love to hear them on the road and see them turn. With out a doubt, the best selling audio card (Sound Blaster X-Fi) still has beta drivers with only partial hardware support. I won’t bother to mention the poor quality in the video card drivers from Nvidia. Come on Nvidia, don’t port your texture mapping code with a copy/paste. I can see that is what you did with a few modifications. In my opinion they are telling the consumor that unless it is DirectX 10 we aren’t bothering to support it in Vista. Business for Vista, hell yes. . .audio and video for gaming and advanced multimedia. . .at this time. . hell no. I recognized this is not a Vista issue in the box of that context. Yet for Microsoft I wonder how closely they have been working with major 3rd party vendors? Also, does Microsoft and 3rd party hardware/software really understand their intimacy in a very delicate ecosystem hinged on consumer adoption based on efficient and stable functionality of hardware/software?

  3. gabe frost . looking forward » Blog Archive » Comments About Annoying Vista Things Says:

    […] All Vista offerings bring significant security value over Windows XP, including Home Basic. Also, the kernel improvements I went into limited detail in a prior post also add significant value to the Basic edition. Tightly integrated search, vast improvements for setting up, discovering, and diagnosing devices and services on a home network, Parental Controls, streamlined Start menu, ReadyBoost for speeding up your system, and many more seen and mostly unseen but felt features make Home Basic a valuable upgrade. I won’t spend any time talking about the Sidebar or built-in apps like Photo Gallery because you can arguably download similar 3rd party apps on XP. Also, things like SuperFetch that are provided in the Home Basic edition do have memory requirements, so I’ll take that off the table too (even though it is there) […]

  4. gabe frost . looking forward » Blog Archive » Vista Media Center Won’t Use 3rd-Party Decoders Says:

    […] Speaking of a protected media path, new to Windows Vista is the Enhanced Video Renderer (EVR), which provides many enhancements over video rendering platforms prior to Vista, in addition to support for Protected Video Path - Output Protection Manager (PVP-OPM) and Protected Video Path - User Accessible Bus (PVP-UAB). A couple noteworthy are support for DirectX Video Acceleration (DXVA), and resilience to glitches (see Multimedia Class Scheduling section in my post about Vista Kernel Improvements). While the MS MPEG-2 decoder supports other (pre-Vista) renderers for output of the decoded stream, only EVR supports the protected media path (and the many other enhancements). If you’re the geek type, and want intricate details, check out the EVR WinHec presentation. Also, recognize that EVR is for rendering on display attached to the Windows Vista PC, not when streaming content across a network for rendering within a Media Center Extender for display on a TV. While the PC-network-TV end-to-end “path” is also fully protected, EVR is not a component used in this scenario. […]

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.