Priorities of UserMode Drivers on CE 6.0 R3 RRS feed

  • Question

  • Hi,

    I was just toying around with Priorities on a CE 6 System and a question came up that I can't solve using the documentation.

    If I run a driver in Usermode, what priorities can I set for its threads? In the Document "Real-Time Priority System Levels (Windows Embedded CE 6.0)" I find the following Remark: "Threads in Normal (as apposed to Privileged) applications can use thread priorities 248 through 255.

    But does this also apply to drivers? And is this in some way enforced?

    I did a little test:

    If I use the CeSetThreadPriority Function in Kernel mode with a value of 0x60 my driver can freeze the whole system if I keep him busy. Which is expected, as it has a higher priority than all other essential drivers.

    If I do the same in Usermode I don't get this behaviour. But I would expect that CeSetThreadPriority would return an error if I try to set 0x60 as Level. Or at least that CeGetThreadPriority would return a different value. But it doesn't.

    Can someone confirm that a driver in Usermode can't starve processes in Kernel Mode? And maybe give some clarification how this is done? 

    It would also be great to have a link on something that explains this a bit more, I wasn't able to find it.

    Wednesday, April 24, 2013 12:32 PM

All replies

  • The OS scheduler does not make a difference whether a thread belongs to driver (kernel or user mode), service or application - they are essentially all the same.
    Any thread in the system can have a priority of 255 down to zero (see, 3rd paragraph).
    This also means that any ill behaved thread (consuming too much CPU) can cause starvation problems.

    The following online presentation named "Building Solutions with Windows Embedded CE 6.0 R2 : Module 3 – Operating System Internals" should give some of the background information you asked for.

    More can be found here:

    MVP Windows Embedded

    Tuesday, April 30, 2013 9:43 PM
  • Below is a simple little app that will confirm that a user mode application can starve the system.  In fact it is so bad that even at low priorities it would appear to starve the system becuase it runs for its entire quantum:

    #include <windows.h>
    WinMain(HINSTANCE hInstance,
    		HINSTANCE hPrevInstance,
    		LPWSTR    lpCmdLine,
    		int       nCmdShow)
    	int Counter;
    	int Priority = 255;
    	HANDLE CurrentThread = GetCurrentThread();
    	for( ; Priority > 0; Priority-- )
    		DWORD CurrentPriority = CeGetThreadPriority( CurrentThread );
    		RETAILMSG( 1, (TEXT("Current %d, Setting %d\n"), CurrentPriority,  Priority));
    		CeSetThreadPriority( CurrentThread, Priority );
    		CurrentPriority = CeGetThreadPriority( CurrentThread );
    		RETAILMSG( 1, (TEXT("Set to %d\n"), CurrentPriority));
    		RETAILMSG( 1, (TEXT("Start busy loop\n")));
    			volatile int busyCount = 65000;
    			while( busyCount > 0 )
    		RETAILMSG( 1, (TEXT("End busy loop\n")));
        return 0;

    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG

    Eurotech Inc.

    Wednesday, May 1, 2013 6:57 PM