EvtUsbTargetPipeReadComplete callback and global resources

OSROSBFX2 WDF Sample driver contains EvtUsbTargetPipeReadComplete callback. From function notes: “This can called concurrently on multiprocessor system if there are more than one readers configured. So make sure to protect access to global resources.”
I understand that this driver is 100% correct because there is only one reader. Assuming that there are more than one readers, how should I protect the global data?
My guess is that “Global data” is device context structure, and I should add WDFWAITLOCK member to it. When I want to access device context members, I need to acquire lock before.
Is this right, can I get some details about synchronization?
Thank you.


Yahoo! Mail
Use Photomail to share photos without annoying attachments.

You have to define global as the scope of the functions which touch that data. 99.99% of the time, yes, the data will be in your device context. You will need to protect your data with a spinlock (KSPINLOCK or WDFSPINLOCK) since completion routines can run at IRQL == DISPATCH_LEVEL, while a WDFWAITLOCK can only be synchronously waited on at IRQL == PASSIVE_LVEL.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alex Farber
Sent: Tuesday, February 28, 2006 1:59 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] EvtUsbTargetPipeReadComplete callback and global resources

OSROSBFX2 WDF Sample driver contains EvtUsbTargetPipeReadComplete callback. From function notes: “This can called concurrently on multiprocessor system if there are more than one readers configured. So make sure to protect access to global resources.”
I understand that this driver is 100% correct because there is only one reader. Assuming that there are more than one readers, how should I protect the global data?
My guess is that “Global data” is device context structure, and I should add WDFWAITLOCK member to it. When I want to access device context members, I need to acquire lock before.
Is this right, can I get some details about synchronization?
??? Thank you.


Yahoo! Mail
Use Photomail to share photos without annoying attachments. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you.

Doron Holan wrote: You have to define global as the scope of the functions which touch that data. 99.99% of the time, yes, the data will be in your device context. You will need to protect your data with a spinlock (KSPINLOCK or WDFSPINLOCK) since completion routines can run at IRQL == DISPATCH_LEVEL, while a WDFWAITLOCK can only be synchronously waited on at IRQL == PASSIVE_LVEL.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alex Farber
Sent: Tuesday, February 28, 2006 1:59 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] EvtUsbTargetPipeReadComplete callback and global resources

OSROSBFX2 WDF Sample driver contains EvtUsbTargetPipeReadComplete callback. From function notes: “This can called concurrently on multiprocessor system if there are more than one readers configured. So make sure to protect access to global resources.”
I understand that this driver is 100% correct because there is only one reader. Assuming that there are more than one readers, how should I protect the global data?
My guess is that “Global data” is device context structure, and I should add WDFWAITLOCK member to it. When I want to access device context members, I need to acquire lock before.
Is this right, can I get some details about synchronization?
Thank you.

Yahoo! Mail
Use Photomail to share photos without annoying attachments. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


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

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.