Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > File Object Lock with WDK

Reply
Thread Tools Display Modes

File Object Lock with WDK

 
 
Asaf Shelly
Guest
Posts: n/a

 
      08-15-2010
Hi All,

I know that it is possible to have an automatic synchronization that is
based on File Object:
http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx

Can't find anywhere that says how.

TIA,
Asaf

 
Reply With Quote
 
 
 
 
Pavel A.
Guest
Posts: n/a

 
      08-16-2010
"Asaf Shelly" <> wrote in message
news:6D71B953-80CB-43AA-BA78-...
> Hi All,
>
> I know that it is possible to have an automatic synchronization that is
> based on File Object:
> http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
>
> Can't find anywhere that says how.
>
> TIA,
> Asaf


Automatic synchronization is not _based_ on file objects.
Rather, callbacks of a file object, that belongs to certain device object,
can be synchronized with other callbacks of that file object, and with
other callbacks of that device object.
This is implemented by taking a lock in the device object.

Call WdfDeviceInitSetFileObjectConfig
with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
and ExecutionLevel as needed.

-- pa


 
Reply With Quote
 
Abhishek Ram [MSFT]
Guest
Posts: n/a

 
      08-17-2010
As mentioned in Pavel's response, automatic synchronization is not based on
FileObject. Rather, the callbacks listed in the table on that page are
synchronized with respect to each other, either at the device-level or at
the queue-level, depending on what you choose.

"Asaf Shelly" <> wrote in message
news:6D71B953-80CB-43AA-BA78-...
> Hi All,
>
> I know that it is possible to have an automatic synchronization that is
> based on File Object:
> http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
>
> Can't find anywhere that says how.
>
> TIA,
> Asaf
>

 
Reply With Quote
 
Asaf Shelly
Guest
Posts: n/a

 
      08-17-2010
Hi Pavel and Abhishek,

Thanks for the answers. So basically if I need File-Object based
synchronization then I should not use Queue based synchronization and instead
do this manually, correct?

Is there any lock object attached to the File Object?

TIA,
Asaf


"Pavel A." wrote:

> "Asaf Shelly" <> wrote in message
> news:6D71B953-80CB-43AA-BA78-...
> > Hi All,
> >
> > I know that it is possible to have an automatic synchronization that is
> > based on File Object:
> > http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
> >
> > Can't find anywhere that says how.
> >
> > TIA,
> > Asaf

>
> Automatic synchronization is not _based_ on file objects.
> Rather, callbacks of a file object, that belongs to certain device object,
> can be synchronized with other callbacks of that file object, and with
> other callbacks of that device object.
> This is implemented by taking a lock in the device object.
>
> Call WdfDeviceInitSetFileObjectConfig
> with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
> and ExecutionLevel as needed.
>
> -- pa
>
>
> .
>

 
Reply With Quote
 
Maxim S. Shatskih
Guest
Posts: n/a

 
      08-17-2010
> Is there any lock object attached to the File Object?

Yes, there is, used to synchronize threads on non-overlapped FO and thus to protect ->CurrentByteOffset from races.

--
Maxim S. Shatskih
Windows DDK MVP

http://www.storagecraft.com

 
Reply With Quote
 
Abhishek Ram [MSFT]
Guest
Posts: n/a

 
      08-18-2010
Can you provide a little more information on what you are trying to
accomplish? Which callbacks do you need to synchronize based on file object?

"Asaf Shelly" <> wrote in message
news:4578B801-0376-498D-8046-...
> Hi Pavel and Abhishek,
>
> Thanks for the answers. So basically if I need File-Object based
> synchronization then I should not use Queue based synchronization and
> instead
> do this manually, correct?
>
> Is there any lock object attached to the File Object?
>
> TIA,
> Asaf
>
>
> "Pavel A." wrote:
>
>> "Asaf Shelly" <> wrote in message
>> news:6D71B953-80CB-43AA-BA78-...
>> > Hi All,
>> >
>> > I know that it is possible to have an automatic synchronization that is
>> > based on File Object:
>> > http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
>> >
>> > Can't find anywhere that says how.
>> >
>> > TIA,
>> > Asaf

>>
>> Automatic synchronization is not _based_ on file objects.
>> Rather, callbacks of a file object, that belongs to certain device
>> object,
>> can be synchronized with other callbacks of that file object, and with
>> other callbacks of that device object.
>> This is implemented by taking a lock in the device object.
>>
>> Call WdfDeviceInitSetFileObjectConfig
>> with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
>> and ExecutionLevel as needed.
>>
>> -- pa
>>
>>
>> .
>>

 
Reply With Quote
 
Asaf Shelly
Guest
Posts: n/a

 
      08-18-2010
Hi Maxim,

Thanks. Is this lock something that I can use as a user of KMDF?

Asaf


"Maxim S. Shatskih" wrote:

> > Is there any lock object attached to the File Object?

>
> Yes, there is, used to synchronize threads on non-overlapped FO and thus to protect ->CurrentByteOffset from races.
>
> --
> Maxim S. Shatskih
> Windows DDK MVP
>
> http://www.storagecraft.com
>
> .
>

 
Reply With Quote
 
Asaf Shelly
Guest
Posts: n/a

 
      08-18-2010
Hi Abhishek,

I have a driver which is a higher level to the COM port, so it is using a
Serial Port as the lower driver.
My application opens my driver for communication and the driver can either
read, write, send periodic buffers, and manipulate data. Currently I need an
instance of the driver for every COM port so basically if I have 5 COM ports
on the machine then I also need 5 instances of my virtual device.
What I would like to do is open my device with the COM number so instead of
using \\?\MyDevice1 for COM1 and \\?\MyDevice2 for COM2, I would like to use
\\?\MyDevice\COM1 and \\?\MyDevice\COM2.
This is working, except that if my device is forwading a request in
transparent mode then it is possible that the lower level driver will block
to completion and my driver cannot handle any other request till completion.
I can solve this in many ways but am looking for a clean design with KMDF
support.

From what I have seen there is some support for FOs in KMDF but fewer
samples than any other solution. Is FO support limited in this version of
KMDF?

Thanks for the fast response.

Regards,
Asaf


"Abhishek Ram [MSFT]" wrote:

> Can you provide a little more information on what you are trying to
> accomplish? Which callbacks do you need to synchronize based on file object?
>
> "Asaf Shelly" <> wrote in message
> news:4578B801-0376-498D-8046-...
> > Hi Pavel and Abhishek,
> >
> > Thanks for the answers. So basically if I need File-Object based
> > synchronization then I should not use Queue based synchronization and
> > instead
> > do this manually, correct?
> >
> > Is there any lock object attached to the File Object?
> >
> > TIA,
> > Asaf
> >
> >
> > "Pavel A." wrote:
> >
> >> "Asaf Shelly" <> wrote in message
> >> news:6D71B953-80CB-43AA-BA78-...
> >> > Hi All,
> >> >
> >> > I know that it is possible to have an automatic synchronization that is
> >> > based on File Object:
> >> > http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
> >> >
> >> > Can't find anywhere that says how.
> >> >
> >> > TIA,
> >> > Asaf
> >>
> >> Automatic synchronization is not _based_ on file objects.
> >> Rather, callbacks of a file object, that belongs to certain device
> >> object,
> >> can be synchronized with other callbacks of that file object, and with
> >> other callbacks of that device object.
> >> This is implemented by taking a lock in the device object.
> >>
> >> Call WdfDeviceInitSetFileObjectConfig
> >> with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
> >> and ExecutionLevel as needed.
> >>
> >> -- pa
> >>
> >>
> >> .
> >>

> .
>

 
Reply With Quote
 
Doron Holan [MSFT]
Guest
Posts: n/a

 
      08-18-2010
you can create your own set of queues per WDFFILEOBJECT. specify the
WDFFILEOBJECT as the parent when you create the queues in
EvtDeviceFileCreate. from your top level dispatching queue, you find the
WDFFILEOBJECT specific queue and forward the request to that queue. you can
then use queue level synchronization and each file object is separate from
each other.

d

"Asaf Shelly" wrote in message
news:EEF1F838-3A0A-4788-816C-...

Hi Abhishek,

I have a driver which is a higher level to the COM port, so it is using a
Serial Port as the lower driver.
My application opens my driver for communication and the driver can either
read, write, send periodic buffers, and manipulate data. Currently I need an
instance of the driver for every COM port so basically if I have 5 COM ports
on the machine then I also need 5 instances of my virtual device.
What I would like to do is open my device with the COM number so instead of
using \\?\MyDevice1 for COM1 and \\?\MyDevice2 for COM2, I would like to use
\\?\MyDevice\COM1 and \\?\MyDevice\COM2.
This is working, except that if my device is forwading a request in
transparent mode then it is possible that the lower level driver will block
to completion and my driver cannot handle any other request till completion.
I can solve this in many ways but am looking for a clean design with KMDF
support.

From what I have seen there is some support for FOs in KMDF but fewer
samples than any other solution. Is FO support limited in this version of
KMDF?

Thanks for the fast response.

Regards,
Asaf


"Abhishek Ram [MSFT]" wrote:

> Can you provide a little more information on what you are trying to
> accomplish? Which callbacks do you need to synchronize based on file
> object?
>
> "Asaf Shelly" <> wrote in message
> news:4578B801-0376-498D-8046-...
> > Hi Pavel and Abhishek,
> >
> > Thanks for the answers. So basically if I need File-Object based
> > synchronization then I should not use Queue based synchronization and
> > instead
> > do this manually, correct?
> >
> > Is there any lock object attached to the File Object?
> >
> > TIA,
> > Asaf
> >
> >
> > "Pavel A." wrote:
> >
> >> "Asaf Shelly" <> wrote in message
> >> news:6D71B953-80CB-43AA-BA78-...
> >> > Hi All,
> >> >
> >> > I know that it is possible to have an automatic synchronization that
> >> > is
> >> > based on File Object:
> >> > http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
> >> >
> >> > Can't find anywhere that says how.
> >> >
> >> > TIA,
> >> > Asaf
> >>
> >> Automatic synchronization is not _based_ on file objects.
> >> Rather, callbacks of a file object, that belongs to certain device
> >> object,
> >> can be synchronized with other callbacks of that file object, and with
> >> other callbacks of that device object.
> >> This is implemented by taking a lock in the device object.
> >>
> >> Call WdfDeviceInitSetFileObjectConfig
> >> with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
> >> and ExecutionLevel as needed.
> >>
> >> -- pa
> >>
> >>
> >> .
> >>

> .
>


 
Reply With Quote
 
Abhishek Ram [MSFT]
Guest
Posts: n/a

 
      08-18-2010
> This is working, except that if my device is forwading a request in
> transparent mode then it is possible that the lower level driver will
> block
> to completion and my driver cannot handle any other request till
> completion.


Are you saying your driver does not receive any other request for that
device object? Or is it for that file object?
What synchronization scope did you set in the case that you observed this?
Also does the application use FILE_FLAG_OVERLAPPED when it opens the handle?

"Asaf Shelly" <> wrote in message
news:EEF1F838-3A0A-4788-816C-...
> Hi Abhishek,
>
> I have a driver which is a higher level to the COM port, so it is using a
> Serial Port as the lower driver.
> My application opens my driver for communication and the driver can either
> read, write, send periodic buffers, and manipulate data. Currently I need
> an
> instance of the driver for every COM port so basically if I have 5 COM
> ports
> on the machine then I also need 5 instances of my virtual device.
> What I would like to do is open my device with the COM number so instead
> of
> using \\?\MyDevice1 for COM1 and \\?\MyDevice2 for COM2, I would like to
> use
> \\?\MyDevice\COM1 and \\?\MyDevice\COM2.
> This is working, except that if my device is forwading a request in
> transparent mode then it is possible that the lower level driver will
> block
> to completion and my driver cannot handle any other request till
> completion.
> I can solve this in many ways but am looking for a clean design with KMDF
> support.
>
> From what I have seen there is some support for FOs in KMDF but fewer
> samples than any other solution. Is FO support limited in this version of
> KMDF?
>
> Thanks for the fast response.
>
> Regards,
> Asaf
>
>
> "Abhishek Ram [MSFT]" wrote:
>
>> Can you provide a little more information on what you are trying to
>> accomplish? Which callbacks do you need to synchronize based on file
>> object?
>>
>> "Asaf Shelly" <> wrote in message
>> news:4578B801-0376-498D-8046-...
>> > Hi Pavel and Abhishek,
>> >
>> > Thanks for the answers. So basically if I need File-Object based
>> > synchronization then I should not use Queue based synchronization and
>> > instead
>> > do this manually, correct?
>> >
>> > Is there any lock object attached to the File Object?
>> >
>> > TIA,
>> > Asaf
>> >
>> >
>> > "Pavel A." wrote:
>> >
>> >> "Asaf Shelly" <> wrote in message
>> >> news:6D71B953-80CB-43AA-BA78-...
>> >> > Hi All,
>> >> >
>> >> > I know that it is possible to have an automatic synchronization that
>> >> > is
>> >> > based on File Object:
>> >> > http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
>> >> >
>> >> > Can't find anywhere that says how.
>> >> >
>> >> > TIA,
>> >> > Asaf
>> >>
>> >> Automatic synchronization is not _based_ on file objects.
>> >> Rather, callbacks of a file object, that belongs to certain device
>> >> object,
>> >> can be synchronized with other callbacks of that file object, and with
>> >> other callbacks of that device object.
>> >> This is implemented by taking a lock in the device object.
>> >>
>> >> Call WdfDeviceInitSetFileObjectConfig
>> >> with WDF_OBJECT_ATTRIBUTES where you specify SynchronizationScope
>> >> and ExecutionLevel as needed.
>> >>
>> >> -- pa
>> >>
>> >>
>> >> .
>> >>

>> .
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
testing smart card minidriver leochou Windows Vista Drivers 0 05-31-2010 11:58 AM
Copying Shared folders and retaining share and file permissions Bry M Server Networking 7 03-24-2010 01:12 PM
Leftover folders after Microsoft Update mme000 \(add @yahoo.it to my nick\) Windows Update 21 12-26-2009 10:11 PM
Guest Only after Bill ActiveSync 1 07-23-2006 07:22 PM
ActiveSync 4.1, Calendar and "Processing" Dale Reeck ActiveSync 10 12-20-2005 12:44 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59