Interlocked Operations and Executive Resources

I’ve almost explained all the Kernel-Mode synchronization mechanisms, and therefore you should have a clear understanding or least a foundation of knowledge to research further into the internals of Kernel-Mode synchronization mechanisms if you wish to do so.

Interlocked Operations

Interlocked operations isn’t a very large topic, and the MSDN article explains the Interlocked Operations topic comprehensively. Here’s the link – Interlocked Operations

Executive Resources

Executive Resources are a another form of synchronization, and in fact are not actually dispatcher objects like Mutexes and Semaphores, they are data structures allocated with non-paged pool. They are only available to Kernel-Mode, and can provide exclusive access and shared read access. Normal Kernel-Mode APC delivery must be disabled, when you are wishing to acquire a Executive Resource.

Executive Resources data structure can be seen in WinDbg:

You can use the !locks extension to list all executive resources which are currently owned.

So, let’s continue with Executive Resources; any threads wishing to acquire the resource for shared read access must wait for a semaphore which is associated with the resource, in order to acquire it. On the other hand, any threads wishing to acquire the resource for exclusive access must wait upon a event object associated with the resource. 

In regards, to semaphores associated with resources, usually the semaphore will have a unlimited count, since this enables all the threads waiting to woken up simultaneously and gain access, once the resource has become available. With a thread waiting for exclusive access, it waits upon a synchronization event object, since only one waiting thread will be woken up.

As a side note, the Contention Count field indicates the number of times a thread has attempted to access the resource, and told to wait because another thread is still using it.

Executive Resources can be used at IRQL Levels less than DISPATCH_LEVEL (Level 2).

More Information – 

ERESOURCEs Close Cousin: Implementing Reader/Writer Locks in User-Mode 

Help on analyzing the ERESOURCE status 



 

Advertisements

About 0x14c

I'm currently a Software Developer. My primary interests are Graph Theory, Number Theory, Programming Language Theory, Logic and Windows Debugging.
This entry was posted in Windows Internals. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s