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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

I take it back, you really can’t queue another same work item and expect it
to callback twice. The reason is (Item)->List.Flink will be overwritten with
the second call to ExQueueWorkItem.

So, if you have only one work item and want to reuse it, you need to make
sure that item is not pending. In this case, you don’t need to call
ExInitializeWorkItem every time.
A work item is removed from the queue when the callback routine is called.
The only way to have multiple items queued is to instantiate each one either
dynamically or at compile time and ExInitializeWorkItem them.
If the item is dynamically allocated, you must free the item in your
callback routine.

-----Original Message-----
From: Don Doan [mailto:xxxxx@1pdc.com]
Sent: Wednesday, May 09, 2001 10:17 AM
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
mailto:xxxxx ]
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@1pdc.com
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</mailto:xxxxx>

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
mailto:xxxxx ]
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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</mailto:xxxxx>

RE: [ntdev] 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

WORKER_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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

MessageThanks 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

WORKER_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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

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
mailto:xxxxx ]
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: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com</mailto:xxxxx>

Yeah sure, that is why I kept saying the ‘general practice’. In the special
case where you have a strictly quantified (i.e. fixed) number of work items
that can be outstanding (as in one,) allocate an executive work item and
keep it. Otherwise it is really rather silly to add your own overhead of a
private cache, which of course can be exhausted, of work items. I’ve written
lots of drivers that use work items, and off hand I can’t think of one that
met this criteria.

The DDK, now both the W2K and the XP versions, however keeps insisting that
ExAlocateWorkItems is obsolete. I read this to mean that it could completely
go away in a future release of the OS.

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: Thursday, May 10, 2001 12:41 PM
To: NT Developers Interest List
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
mailto:xxxxx ]
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@stratus.com
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</mailto:xxxxx>

> Now my question is can i just call IoAllocateWorkItem once during

initialisation and use the same work item pointer everytime I invoke
IoQueueWorkItem?

The DDK advises to allocate the new work item each time and to free it
inside the work item routine.

Max


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

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

Message>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

Yes, but it solves the problem (unsolvable otherwise) of the driver image
unmapped during unload from under the feet of your work item.
As about the race between the work item and REMOVE_DEVICE - this is your
driver’s own problems, and it must solve them itself.

So, ExQueueWorkItem is obsolete and must not be used in w2k/WDM code where
there is no NT4 portability goal.

Max


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