File-Write from KM

I want to write some data to a file from DPC-level. I think none of the
windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja

Why not queue a work item and write to the file from the work item. Are you thinking about realtime deadline issues here?
“Kannan, Raja” wrote in message news:xxxxx@ntdev…
I want to write some data to a file from DPC-level. I think none of the windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja

I guess you really mean DISPATCH_LEVEL, so what’s wrong with a DPC
and doing the file I/O in the callback ?

Or why not implement your own system thread in your driver. There’s
plenty of ways to get around the DISPATCH_LEVEL issue. My own usual
preference for writing files is to queue items up for processing by a
system thread, in that way it’s easier to maintain the correct sequence.

Mark

At 07:24 AM 12/21/2005, Kannan, Raja wrote:

I want to write some data to a file from DPC-level. I think none of
the windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja

Thanks for your reply.

My network device captures packet(s) from line and interrupt processor
to save it in a disc. I shouldn’t do it from ISR. Windows DDK provides
some APIs such as ZwCreateFile, ZwWriteFile and ZwReadFile to access
file, but only from the PASSIVE_LEVEL.

So I can’t do anything in DPC except I can set a event to resume a
worker-thread that is running in PASSIVE_LEVEL and going to do file
write. Here the problem is, in high speed network, that worker-thread
will have a less chances of getting scheduled or it will have very less
time to hold CPU because of thread scheduling, context switching, DPC’s
of my own device / other devices and etc. So I don’t like to break the
packet path (say ISR to DPC, then DPC to worker-thread). Any way to
achieve this?


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Wednesday, December 21, 2005 3:27 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] File-Write from KM

I guess you really mean DISPATCH_LEVEL, so what’s wrong with a DPC and
doing the file I/O in the callback ?

Or why not implement your own system thread in your driver. There’s
plenty of ways to get around the DISPATCH_LEVEL issue. My own usual
preference for writing files is to queue items up for processing by a
system thread, in that way it’s easier to maintain the correct sequence.

Mark

At 07:24 AM 12/21/2005, Kannan, Raja wrote:

I want to write some data to a file from DPC-level. I think none
of the windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@networkgeneral.com

To unsubscribe send a blank email to xxxxx@lists.osr.com

The short answer is no - you are not going to be able to do file writes at
DISPATCH_LEVEL. However your analysis about the inadequacy of a background
worker thread doing the writes is wrong. Unless your network link is
saturating the IO bus and or all the CPUs you should be able to get adequate
service from your worker thread. Yes it will lag behind your packet capture
module, but so what? That is what queues are for. Note that you can adjust
the runtime priority of your worker thread to whatever level is required to
get the job done. Low realtime priority ought to be just fine.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kannan, Raja
Sent: Wednesday, December 21, 2005 6:41 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] File-Write from KM

Thanks for your reply.

My network device captures packet(s) from line and interrupt processor to
save it in a disc. I shouldn’t do it from ISR. Windows DDK provides some
APIs such as ZwCreateFile, ZwWriteFile and ZwReadFile to access file, but
only from the PASSIVE_LEVEL.

So I can’t do anything in DPC except I can set a event to resume a
worker-thread that is running in PASSIVE_LEVEL and going to do file write.
Here the problem is, in high speed network, that worker-thread will have a
less chances of getting scheduled or it will have very less time to hold CPU
because of thread scheduling, context switching, DPC’s of my own device /
other devices and etc. So I don’t like to break the packet path (say ISR to
DPC, then DPC to worker-thread). Any way to achieve this?


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Wednesday, December 21, 2005 3:27 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] File-Write from KM

I guess you really mean DISPATCH_LEVEL, so what’s wrong with a DPC and doing
the file I/O in the callback ?

Or why not implement your own system thread in your driver. There’s plenty
of ways to get around the DISPATCH_LEVEL issue. My own usual preference for
writing files is to queue items up for processing by a system thread, in
that way it’s easier to maintain the correct sequence.

Mark

At 07:24 AM 12/21/2005, Kannan, Raja wrote:

I want to write some data to a file from DPC-level. I think none of the
windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@networkgeneral.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Queue a work item which will write the data.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Kannan, Raja”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, December 21, 2005 10:24 AM
Subject: [ntdev] File-Write from KM

I want to write some data to a file from DPC-level. I think none of the
windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Doing the disk writes from dispatch level won’t solve your problem.

If the system is really so saturated with I/O that you can’t get a
worker thread scheduled to run, then you don’t have the CPU time to
spare issuing write operations through the file system and disk stacks
and waiting for the storage controller to be avaialble. Even if you’re
doing asynchronous I/O there’s a cost to starting a write request and if
you’re that overcomitted on the system you’re going to have to drop
packets in order to write to disk.

Keep a queue and write the data from a worker thread. You may still
need to drop package occasionally in order to avoid running the system
out of memory (or due to running the system out of memory) but the
likelyhood is that your worker can keep up.

-p


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kannan, Raja
Sent: Wednesday, December 21, 2005 3:41 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] File-Write from KM

Thanks for your reply.

My network device captures packet(s) from line and interrupt processor
to save it in a disc. I shouldn’t do it from ISR. Windows DDK provides
some APIs such as ZwCreateFile, ZwWriteFile and ZwReadFile to access
file, but only from the PASSIVE_LEVEL.

So I can’t do anything in DPC except I can set a event to resume a
worker-thread that is running in PASSIVE_LEVEL and going to do file
write. Here the problem is, in high speed network, that worker-thread
will have a less chances of getting scheduled or it will have very less
time to hold CPU because of thread scheduling, context switching, DPC’s
of my own device / other devices and etc. So I don’t like to break the
packet path (say ISR to DPC, then DPC to worker-thread). Any way to
achieve this?


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Mark S. Edwards
Sent: Wednesday, December 21, 2005 3:27 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] File-Write from KM

I guess you really mean DISPATCH_LEVEL, so what’s wrong with a DPC and
doing the file I/O in the callback ?

Or why not implement your own system thread in your driver. There’s
plenty of ways to get around the DISPATCH_LEVEL issue. My own usual
preference for writing files is to queue items up for processing by a
system thread, in that way it’s easier to maintain the correct sequence.

Mark

At 07:24 AM 12/21/2005, Kannan, Raja wrote:

I want to write some data to a file from DPC-level. I think none
of the windows API supports this.

Would I have to write any filter(intermediate) driver for that?

Raja


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@networkgeneral.com

To unsubscribe send a blank email to xxxxx@lists.osr.com

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com