static variable

I have some notes that say that static variable in driver coding should be
avoided. I can avoid this by taking this into device extension. But I can’t
remember why I should avoid, can anyone confirm this?

Thanks,
Hakim

Static as in static local function variable? As the programming model is
multi-threaded such variables, absent a surrounding serialization mechanism,
are highly suspect.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
Sent: Thursday, November 11, 2004 7:07 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] static variable

I have some notes that say that static variable in driver
coding should be avoided. I can avoid this by taking this
into device extension. But I can’t remember why I should
avoid, can anyone confirm this?

Thanks,
Hakim


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

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

So, is it safe to use in ISR routine?

Thanks,
Hakim

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> Static as in static local function variable? As the programming model is
> multi-threaded such variables, absent a surrounding serialization
> mechanism,
> are highly suspect.
>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
>> Sent: Thursday, November 11, 2004 7:07 PM
>> To: Windows System Software Devs Interest List
>> Subject: [ntdev] static variable
>>
>> I have some notes that say that static variable in driver
>> coding should be avoided. I can avoid this by taking this
>> into device extension. But I can’t remember why I should
>> avoid, can anyone confirm this?
>>
>> Thanks,
>> Hakim
>>
>>
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> You are currently subscribed to ntdev as:
>> xxxxx@hollistech.com To unsubscribe send a blank email to
>> xxxxx@lists.osr.com
>>
>
>
>
>

Probably not, since you could have multiple devices being supported by your
driver. A static would give you one instance of this for all drivers.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Hakim” wrote in message news:xxxxx@ntdev…
> So, is it safe to use in ISR routine?
>
> Thanks,
> Hakim
>
> “Mark Roddy” wrote in message news:xxxxx@ntdev…
> > Static as in static local function variable? As the programming model is
> > multi-threaded such variables, absent a surrounding serialization
> > mechanism,
> > are highly suspect.
> >
> >> -----Original Message-----
> >> From: xxxxx@lists.osr.com
> >> [mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
> >> Sent: Thursday, November 11, 2004 7:07 PM
> >> To: Windows System Software Devs Interest List
> >> Subject: [ntdev] static variable
> >>
> >> I have some notes that say that static variable in driver
> >> coding should be avoided. I can avoid this by taking this
> >> into device extension. But I can’t remember why I should
> >> avoid, can anyone confirm this?
> >>
> >> Thanks,
> >> Hakim
> >>
> >>
> >>
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> >> http://www.osronline.com/article.cfm?id=256
> >>
> >> You are currently subscribed to ntdev as:
> >> xxxxx@hollistech.com To unsubscribe send a blank email to
> >> xxxxx@lists.osr.com
> >>
> >
> >
> >
> >
>
>
>

Not if you can have more than one device.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
Sent: Thursday, November 11, 2004 7:25 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] static variable

So, is it safe to use in ISR routine?

Thanks,
Hakim

“Mark Roddy” wrote in message
> news:xxxxx@ntdev…
> > Static as in static local function variable? As the
> programming model
> > is multi-threaded such variables, absent a surrounding
> serialization
> > mechanism, are highly suspect.
> >
> >> -----Original Message-----
> >> From: xxxxx@lists.osr.com
> >> [mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
> >> Sent: Thursday, November 11, 2004 7:07 PM
> >> To: Windows System Software Devs Interest List
> >> Subject: [ntdev] static variable
> >>
> >> I have some notes that say that static variable in driver coding
> >> should be avoided. I can avoid this by taking this into device
> >> extension. But I can’t remember why I should avoid, can anyone
> >> confirm this?
> >>
> >> Thanks,
> >> Hakim
> >>
> >>
> >>
> >> —
> >> Questions? First check the Kernel Driver FAQ at
> >> http://www.osronline.com/article.cfm?id=256
> >>
> >> You are currently subscribed to ntdev as:
> >> xxxxx@hollistech.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:
> xxxxx@hollistech.com To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

> I have some notes that say that static variable in driver coding should be

avoided. I can avoid this by taking this into device extension. But I can’t
remember why I should avoid, can anyone confirm this?

Driver must support several devices. Static variables are global and not
per-device.

The common bug is to use static variable instead of the device extension field,
assuming that the driver will have only 1 device. The real need in static is
rare.

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

Thanks all. I’ll write down in my notes these things.

Hakim

“Hakim” wrote in message news:xxxxx@ntdev…
> So, is it safe to use in ISR routine?
>
> Thanks,
> Hakim
>
> “Mark Roddy” wrote in message news:xxxxx@ntdev…
>> Static as in static local function variable? As the programming model is
>> multi-threaded such variables, absent a surrounding serialization
>> mechanism,
>> are highly suspect.
>>
>>> -----Original Message-----
>>> From: xxxxx@lists.osr.com
>>> [mailto:xxxxx@lists.osr.com] On Behalf Of Hakim
>>> Sent: Thursday, November 11, 2004 7:07 PM
>>> To: Windows System Software Devs Interest List
>>> Subject: [ntdev] static variable
>>>
>>> I have some notes that say that static variable in driver
>>> coding should be avoided. I can avoid this by taking this
>>> into device extension. But I can’t remember why I should
>>> avoid, can anyone confirm this?
>>>
>>> Thanks,
>>> Hakim
>>>
>>>
>>>
>>> —
>>> Questions? First check the Kernel Driver FAQ at
>>> http://www.osronline.com/article.cfm?id=256
>>>
>>> You are currently subscribed to ntdev as:
>>> xxxxx@hollistech.com To unsubscribe send a blank email to
>>> xxxxx@lists.osr.com
>>>
>>
>>
>>
>>
>
>
>