Re: [ntdev] Sequencially executing the WorkItem

The short answer is no: you cannot force the order of execution of pre-emptable code. Even in a single core environment this will not work reliably and in a multi-core environment you will routinely see different ordering.

If you need order, you need to queue the work and then use work items to trigger a thread to process it. Typically you would use some kind of lock to prevent multiple threads from draining the queue simultaneously (and ruining your order) and a volatile to reduce the number of work items you need to post (if there is one 'en route’ you need not post another)

Sent from Surface Pro

From: Ravish Yadav
Sent: ‎Monday‎, ‎May‎ ‎11‎, ‎2015 ‎8‎:‎48‎ ‎PM
To: Windows System Software Devs Interest List

Hi,

is there a way we can execute WorkItem in sequence, In sequence i mean whichever workitem enqueued first should be executed first.

As per my knowledge after we enqueue the workitem system thread will remove the workitem and start executing but if suppose in workitem i am holding any lock for synchronization then it might be the situation where the workitem which is en-queued later might get the lock than the workitem which was en-queued before that.

The only way i see to sequentially do it create our own queue and push the data to it and create a thread that will pick those events and executes it.

Please suggest!

Regars,

Rabish
— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Your reply seems to have cut off the context. Can you explain what point you would like more help with?

Sent from Surface Pro

From: Ravish Yadav
Sent: ‎Wednesday‎, ‎May‎ ‎13‎, ‎2015 ‎8‎:‎57‎ ‎AM
To: Windows System Software Devs Interest List

Hi Maxim,

Could not get you how it will help can you elaborate more on this.

Regards,

Rabish

On Wed, May 13, 2015 at 5:14 PM, Maxim S. Shatskih wrote:

Enqueue the second work item from within the first work item.

“Ravish Yadav” wrote in message news:xxxxx@ntdev…

Hi,

is there a way we can execute WorkItem in sequence, In sequence i mean whichever workitem enqueued first should be executed first.

As per my knowledge after we enqueue the workitem system thread will remove the workitem and start executing but if suppose in workitem i am holding any lock for synchronization then it might be the situation where the workitem which is en-queued later might get the lock than the workitem which was en-queued before that.

The only way i see to sequentially do it create our own queue and push the data to it and create a thread that will pick those events and executes it.

Please suggest!

Regars,

Rabish


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
— NTDEV is sponsored by OSR Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev OSR is HIRING!! See http://www.osr.com/careers For our schedule of WDF, WDM, debugging and other seminars visit: http://www.osr.com/seminars To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer