MessageAmd the Windows 2000 DDK say:
ExQueueWorkItem
VOID
ExQueueWorkItem(
IN PWORK_QUEUE_ITEM WorkItem,
IN WORK_QUEUE_TYPE QueueType
);
The ExQueueWorkItem support routine is exported to support existing driver binaries and is obsolete. Use IoQueueWorkItem instead.
Don Burn
Windows 2000 Device Driver and Filesystem consulting
----- Original Message -----
From: Don Doan
To: NT Developers Interest List
Sent: Thursday, May 10, 2001 12:41 PM
Subject: [ntdev] RE: Question on Work items!
Let me quote a section from Microsoft Press book: “Windows 2000 provides a new set of functions-IoAllocateWorkItem, IoQueueWorkItem and IoFreeItem…The new functions surround calls to the executive-level functions with code that claims a reference to a device object you specify. That reference prevents your device object from disappearing, but it does not hold off the processing of IRP_MN_REMOVE_DEVICE requests. So long as you understand that you must prevent the disappreance of your driver and any resources that your work-item callback will access until after the callback executes, there’s no compelling reason to use the new functions”. This means the Ex interface is not obsolete and in some cases, it is better to use the executive-level functions (Ex functions). The reason for this is that dynamic allocation and freeing is costly and should not be use if can be avoided. If you need only to queue one work-item at a time, why not use Ex functions? This way, you only need to allocate a work-item once when your driver loads and free it when your driver unloads. To sum it up, it your driver required to asynchronously queuing unknown number of work-items then it may be easier to use Io functions, otherwise use Ex functions to achieve performance if that is your main objective.
-----Original Message-----
From: Varadan Venkatesh [mailto:xxxxx@tataelxsi.co.in]
Sent: Thursday, May 10, 2001 5:29 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Question on Work items!
Thanks a lot Mark and others!
Rgda
Venky
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Mark Roddy
Sent: Thursday, May 10, 2001 4:10 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Question on Work items!
That is correct. The general practice is to allocate as needed and free them in your work task. This does not mean that it is impossible to recycle executive work items, just that it generally is not done. Note that the Ex worker interface is obsolete, replaced by the Io worker interface in W2K and later. The IO_WORK_ITEM api adds a reference to a device object that can only be removed by freeing the work item object.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Varadan Venkatesh
Sent: Wednesday, May 09, 2001 11:53 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Question on Work items!
Mark and others,
Does the below mean that I cannot (or rather not advised to) reuse the same work item till the regd. routine completes its execution and i free the work item? actually then is there a way to find out whether the routine is in the queue or it has already been invoked? So looks like the best way then is to initialise a work item everytime I want to queue one and free the work item once the routine finishes its execution. if what I say is correct, I will be grateful if somebody could just respond with an yes.
Thanks
Venky
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com]On Behalf Of Roddy, Mark
Sent: Wednesday, May 09, 2001 11:33 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Question on Work items!
I think that if you attempt to queue a workitem that is already queued you will crash the system. Likewise if you call ExIntializeWorkItem on a queued work item: BSOD. You might be able to re-use executive workitems, but only by recycling them AFTER the associated task has been invoked. When you queue a work item you no longer ‘own’ the pointer to the work item object. You regain ownership when your worker task executes. The general practice, now made almost mandatory by the replacement of ExQueueWorkItem with IoQueueWorkItem, is to allocate work items as needed rather than attempting to manage a private cache of re-usable work items.
Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
603 321 1032
WindowsNT Windows 2000 Consulting Services
-----Original Message-----
From: Don Doan [mailto:xxxxx@1pdc.com]
Sent: Wednesday, May 09, 2001 1:17 PM
To: NT Developers Interest List
Subject: [ntdev] RE: Question on Work items!
This is what ExInitializeWorkItem does:
#define ExInitializeWorkItem(Item, Routine, Context) \
(Item)->WorkerRoutine = (Routine); \
(Item)->Parameter = (Context); \
(Item)->List.Flink = NULL;
#endif
typedef struct _LIST_ENTRY {
struct _LIST_ENTRY * volatile Flink;
struct _LIST_ENTRY * volatile Blink;
} LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
typedef struct _WORK_QUEUE_ITEM {
LIST_ENTRY List;
PWORKER_THREAD_ROUTINE WorkerRoutine;
PVOID Parameter;
} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
typedef enum _WORK_QUEUE_TYPE {
CriticalWorkQueue,
DelayedWorkQueue,
HyperCriticalWorkQueue,
MaximumWorkQueue
} WORK_QUEUE_TYPE;
typedef
VOID
(*PWORKER_THREAD_ROUTINE)(
IN PVOID Parameter
);
//NTKERNELAPI
extern VOID
ExQueueWorkItem(
IN PWORK_QUEUE_ITEM WorkItem,
IN WORK_QUEUE_TYPE QueueType
);
After ExInitializeWorkItem, you queue the work item using ExQueueWorkItem. ExQueueWorkItem will add your work item to its doubly linked list. Now, if you want to queue the same work item while the first work item still pending, just so that it will call your callback routine twice, you simply ExQueueWorkItem again. But if you want to queue a different work item you need to instantiate another work item and call ExInitializeWorkItem with that new work item.
After that you need to queue the new item with ExQueueWorkItem.
Hope that help.
-----Original Message-----
From: Varadan Venkatesh [mailto:xxxxx@tataelxsi.co.in]
Sent: Wednesday, May 09, 2001 4:30 AM
To: NT Developers Interest List
Subject: [ntdev] Question on Work items!
Hello
I have a question on Work item. I need to queue certain work items so that
the system
worker thread removes the item and gives control to the specified callback
routine.
Now my question is can i just call IoAllocateWorkItem once during
initialisation and use the same work item pointer everytime I invoke
IoQueueWorkItem? is this queueing a work item analogous to a usage of a
message queue (in an RTOS like say vxWorks) with the workitem pointer
analagous to the the message queue id? ie. I just allocate a queue and pass
messages to that queue using that queueid. Hope i am clear.
or is there more to it than what i see???
eagerly awaiting a reply
Thanks
Venky
You are currently subscribed to ntdev as: xxxxx@1pdc.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@tellink.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@tataelxsi.co.in
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@1pdc.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@acm.org
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com