Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Inside Windows 8: Pedro Teixeira - Thread pools

Download

Right click “Save as…”

Continuing with our series of conversations with engineers in Windows, we meet Pedro Teixeira, a software developer on the Windows kernel team (aka core OS) who has improved the Windows thread pools in Windows 8. Thread pools are thread management subsystems (user mode and kernel mode) where threads are created and queued for any number of arbitrary tasks (work) required by applications and services. As it turns out, there are some significant improvements to the thread pool pattern in Windows 8. Pedro takes the time necessary - at the whiteboard for the entire interview - to dig into the details, beginning with first principles. So, if you don't really know what a thread pool is, then you will after the first 5 minutes of this interview. As the conversation progresses, the complexity will increase, but will remain suitable for most user mode application developers. Speaking of user mode, much of the time in this interview is spent on the Windows 8 user mode thread pool. The kernel mode thread pool is addressed towards the end of the conversation.

In Windows 8, there is a new thread pool model and new thread creation policy. What is the new policy? How is the new user mode thread pool designed? How is it better than its predecessors? What does this all mean for developers?

Tune in. Learn. Huge thanks to Pedro for taking the time to dig in - and for explain things in such a clear way.

Tags:

Follow the Discussion

  • Hmm maybe this new threadppol policy is the reason why latest Firefox is dead slow, but also many application startup time grew from <1sec to 3-4 seconds since the Win7->Win8 upgrade Expressionless

    Anyway, really nice to see so much passion on an interesting topic, thank you! Smiley

  • felix9felix9 the cat that walked by itself

    Good.

    Thread pool is my working horse for everything not in the UI. I use QueueUserWorkItem to do async work, RegisterWaitForSingleObject to do notification/timeout/timer, and I use it to do (overlapped) IO too, I wish I can use BindIoCompleionRoutine to do IO but that dont have a async timeout notification as far as I can see, so I use RegisterWaitForSingleObject with the event in OVERLAPPED instead, which works, but its kinda wierd that BindIoCompletionRoutine has such a flaw, and I wonder if using RegisterWaitForSingleObject for IO completion has any performance hit, since its TP_WAIT while BindIoCompletionRoutine uses TP_IO ? on the other hand I wish there is RegisterWaitForMultipleObjects which would be super useful.

  • Felix9, note that all the APIs you have listed are actually quite dated. The Win32 API has gone through significant changes in Vista which make it easier to develop by orders of magnitude (given it has built-in reference count, support for synchronization and cancelation). Please refer to this link: http://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx.

  • McHalls, You seem to be describing a pervasive impact on all applications startup. ThreadPool has been tested thoroughly not to affect any such generic scenario. In fact, the loader remains mostly single-threaded to this day. There are multiple factors that could be influencing your results, such as storage drivers. Also note that Win8 does come with Defender complemented by Security Essentials anti-malware, where Win7 did not. Smart screening is also turned on by default validating the binaries being loaded are not back-listed as malware. A delicate balance with "secure by default".

  • Very very interesting.

    But what about conventional .NET thread pool in .NET 4.5 (on Win 8 but not Win RT apps)? Is it based on this new OS thread pool?

  • felix9felix9 the cat that walked by itself

    @pmsjt: Thank you, I never really looked into those shiny new APIs because, well, I need to target XP, and in a foreseeable future, so the first thing I do with a new C++ project is setting _WIN32_WINNT to 0x0501. Expressionless

    But actually, async timeout notification is useless in XP anyway since there is no CancelIoEx, and CancelIo can only be called in the same thread that started it. Sad So I kinda understand why MS teams all left XP support behind, because XP stinks. but I'm not Microsoft so I still have to.

    Now I still want to ask, if I use those new Vista APIs, can I start a socket (TCP/UDP) overlapped io and let the threadpool notify me if its not yet completed after a timeout ?? I mean, I know maybe I CAN do that, but maybe I need both ...Wait APIs and ...Io APIs, and set 2 callbacks, but IMHO thats too much for such a common task, can I get the notification with just ...Io APIs ?

  • oskarkoskark

    Really interesting stuff. @Charles, will you be looking into the internals and implementation of the RIO http://bit.ly/t14OoV sockets.

  • br1br1

    Best c9 show yet.  The complexity level was just right.

  • Thanks for the great video. Enjoyed it!

  • Excellent! More like this please.

     

  • C64C64

    Very good interview! Thanks both Pedro and Charles.

    One thing I'm curious is what development tools you guys in the kernel world use.

    We in the user mode world use Visual Studio with its convenience and facilities; but when you are writing code for the kernel, what are your tools? What editors do you use? What debuggers? Is there a special build of the C compiler for kernel mode, or do you use our classical "user mode" cl.exe?

    A video on "development tools for kernel mode devs" would be interesting.

    Thanks.

     

  • Manuel Filipe VilhenaManuel Filipe Vilhena

    Great presentation! Congratulations for all Pedro.

  • Andrew ShaAndrew Sha

    It was mentioned that a full blown thread pool (as opposed to work items handled by ExQueueWorkItem) is implemented in the Win8 kernel – is API exposed/ documented?

  • Fantastic video.  I agree that the complexity level was just right; enough to be educational, but not too pedantic.  I very much appreciate it.

  • Pedro LamasPedro Lamas Pedro Lamas

    Awesome presentation, Pedro! Congratulations!!

    Ou como dirĂ­amos por terras de Portugal, ParabĂ©ns! Wink

  • You got this behaving with .NET garbage collections finally? SWEET!!  Now make it so I don't need a separate IOCP/blocking thread for job object events, or a separate IOCP/blocking thread for registered I/O. Come on, you dropped the ball with that after solving everything else. No I'm not gonna go use event handles, that's for n00bz.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.