UK_The Volatile Organic Compounds in Paints, Varnishes and

UK_The Volatile Organic Compounds in Paints, Varnishes and
UK_The Volatile Organic Compounds in Paints, Varnishes and

S T A T U T O R Y I N S T R U M E N T S

2005 No. 2773

ENVIRONMENTAL PROTECTION The V olatile Organic Compounds in Paints, Varnishes and Vehicle Refinishing Products Regulations 2005

Octob e r

2005

Mad e - - - - 9th

Laid before Parliament 11th October 2005

Coming into force - - 1st November 2005

The Secretary of State, in exercise of the powers conferred upon her by section 2(2) of the European Communities Act 1972(a), being a Minister designated(b) for the purpose of that subsection in relation to the control of air pollution, makes the following Regulations:

Citation, commencement and extent

1.—(1) These Regulations may be cited as the Volatile Organic Compounds in Paints, Varnishes and Vehicle Refinishing Products Regulations 2005 and come into force on 1st November 2005. (2)With the exception of regulation 9, which extends to England and Wales only, these Regulations extend to the whole of the United Kingdom.

Definitions

2. In these Regulations—

“organic compound” means any compound containing at least the element carbon and one or more of hydrogen, oxygen, sulphur, phosphorus, silicon, nitrogen, or a halogen, with the exception of carbon oxides and inorganic carbonates and bicarbonates;

“relevant product” has the meaning given by regulation 3(1);

“volatile organic compound” (VOC) means any organic compound having an initial boiling point less than or equal to 250°C measured at a standard pressure of 101,3 kPa;

“VOC content” means the mass of volatile organic compounds, expressed in grams/litre (g/l), in the formulation of the product in its ready to use condition; the mass of volatile organic compounds in a given product which react chemically during drying to form part of the coating shall not be considered part of the VOC content.

(a) 1972 c.68.

(b) S.I. 1988/785. In so far as these regulations deal with matters that are not reserved matters in Scotland, the power of the

Secretary of State to make regulations in relation to those matters, in or as regards Scotland is preserved by section 57(1) of the Scotland Act 1998.

Scope

3.—(1) Subject to paragraphs (2) and (3) below, these Regulations apply to the paints, varnishes, vehicle refinishing products and subcategories as defined in Schedule 1 to these Regulations (“the relevant products”).

(2)These Regulations do not apply to relevant products that are to be used in a country or territory outside the customs territory of the European Community.

(3)These Regulations shall not apply to products which are sold for exclusive use in an activity—

(a)which is a SED (solvent emissions directive) Activity; and

(b)carried out in a SED installation.

(4)In this regulation—

“SED Activity” means any activity falling within —

(i)section 7 of Part 1 of Schedule 1of the Pollution Prevention and Control (England

and Wales) Regulations 2000(a);

(ii)the section in Chapter 7 of Part 1 of Schedule 1 of the Pollution Prevention and Control (Scotland) Regulations 2000(b) where operated above the solvent

consumption thresholds specified for that activity as set out in that section of that

Chapter; and

(iii)section 7 of Part 1 of Schedule 1of the Pollution Prevention and Control Regulations (Northern Ireland) 2003(c);

“SED installation” means—

(i)a stationary technical unit where one or more SED activities are carried out; and

(ii)any other location on the same site where any other directly associated activities are carried out.

Limitations on marketing paints and varnishes and vehicle refinishing products

4.—(1) Subject to regulation 10, it shall not be lawful to place on the market any relevant product after the dates laid down for that product in Schedule 2 to these Regulations(d), unless that product—

(a)has a VOC content not exceeding the limit value set out for that product in Schedule 2;

and

(b)carries a label in compliance with regulation 5.

(2)In determining compliance with the VOC content limit values set out in Schedule 2, the analytical methods set out in Schedule 3(e) apply.

(a) S.I.2000/1973 as amended by the Solvent Emissions (England and Wales) Regulations 2004, S.I. 2004/107, which

implement in England and Wales D irective 1999/13/EC, O.J. L85, 23.3.1999, p.1 (and cover new and existing solvent emissions installations or SED installations and SED activities), as amended by Regulation (EC) No. 1882/2003, O.J. L2884,

31.10.2003, p.1. There are other amending instruments but none is relevant.

(b) S.S.I. 2000/323 as amended by the Solvent Emissions (Scotland) Regulations 2004, S.S.I. 2004/126 and the Pollution

Prevention and Control (Scotland) Amendment (No.2) Regulations 2005, S.S.I. 2005/340, which implement in Scotland

D irective 1999/13/EC, O.J. L85, 23.3.1999, p.1 (and cover new and existing solvent emissions installations or SED

installations and SED activities), as amended by Regulation (EC) No. 1882/2003, O.J. L2884, 31.10.2003, p.1. There are other amending instruments but none is relevant.

(c) S.R. 2003 No.46 as amended by the Solvent Emissions Regulations (Northern Ireland) 2004 S.R. 2004 No.36 and the

Pollution Prevention and Control (Amendment) and Connected Provisions (No.2) Regulations (Northern Ireland) 2005 S.R.2005 No.285 which implement in Northern Ireland Directive 1999/13/EC. O.J.L85,23.3.1999.p1 (and cover new and existing solvent emissions installations or SED installations and SED activities)as amended by Regulation (EC) No.1882/2003,O.J. L2884,31.10.2003 p.1. There are other amending instruments but none is relevant.

(d) Schedule 2 sets out the maximum VOC content limit values in Annex II to the Directive.

(e) Schedule 3 sets out the analytical methods in Annex III to the Directive and referred to in Article 3.1 of that Directive.

(3)For relevant products to which solvents or other components containing solvents have to be added for the product to be ready for use, the limit values in Schedule 2 shall apply to the VOC content of the product in its ready for use condition.

Labelling

5.—(1) A label referred to in regulation 4(1)(b) must indicate—

(a)the sub-category of the product and the relevant VOC limit values, measured in g/l, as set

out in Schedule 2; and

(b)the maximum content of VOC in g/l of the product in a ready to use condition.

(2)Paragraph (1) is without prejudice to any requirement in any other enactment that requires a relevant product to be marked or labelled.

Designation of competent authority

6.—(1) The Secretary of State is designated as the competent authority for the purposes of Article 5 (responsibility for fulfilment of obligations) of the Directive.

(2)In exercising her responsibilities under these Regulations, insofar as relevant responsibilities have been devolved to them the Secretary of State shall consult—

(a)the Scottish Ministers;

(b)the Welsh Assembly Government; and

(c)the Northern Ireland Department of the Environment.

Monitoring and enforcement

7.—(1) The Secretary of State shall establish and maintain a programme of monitoring for the purpose of verifying compliance with these Regulations.

(2)Subject to paragraph (3) the Secretary of State shall enforce these Regulations.

(3)Nothing in paragraph (2) above authorises the Secretary of State to prosecute for an offence under these Regulations in Scotland.

(4)The Secretary of State may delegate any or all of her functions under this regulation and may make such delegation to such extent (including geographical extent), and subject to such conditions, as she may determine.

(5)After making any delegation under paragraph (4), the Secretary of State shall forthwith give notice of the delegation, including its extent and where further details, including any conditions which the delegation is subject to, can be obtained, as follows—

(a)for a delegation affecting England, Wales, or both, in the London Gazette;

(b)for a delegation affecting Scotland, in the Edinburgh Gazette;

(c)for a delegation affecting Northern Ireland, in the Belfast Gazette.

(6)The enforcement provisions in relation to Northern Ireland are set out in Schedule 4(a). Offences

8.—(1) It shall be an offence to contravene regulation 4(1).

(2)Where an offence under paragraph (1) above, which has been committed by a body corporate, is proved to have been committed with the consent or connivance of, or to have been attributable to, any neglect on the part of a director, manager, secretary or other similar officer of the body corporate, or any person who was purporting to act in any such capacity, he, as well as the body corporate, shall be liable to prosecution.

(a) In England, Wales and Scotland, the enforcement powers in section 108 of the Environment Act 1995 apply.

(3)Where the affairs of a body corporate are managed by its members, paragraph (2) shall apply in relation to the acts or defaults of a member in connection with his functions of management as if he were a director of the body corporate.

(4)Where an offence under paragraph (1) has been committed by a Scottish Partnership and has been committed with the consent or connivance of, or is attributable to the neglect of, a partner or a person who was purporting to act as such, that person as well as the partnership is guilty of the offence.

(5)Where a person charged with an offence under this regulation claims that the product was produced before the appropriate date in Schedule 2, it is for that person to prove that the product was produced before that date and had not been placed on the market for more than 12 months following the appropriate date applicable to that product.

(6)The maximum penalty on conviction for an offence under paragraph (1) shall be—

(a)on summary conviction, a fine not exceeding the statutory maximum; or

(b)on conviction on indictment, a fine.

Amendment to the Pollution Prevention and Control (England and Wales) Regulations 2000 9. The definition of “vehicle refinishing” in paragraph (2) of Section 7 (SED Activities) of Part 1 of Schedule 1 (Activities, Installations and Mobile Plant) to the Pollution Prevention and Control (England and Wales) Regulations 2000 shall be amended as respects England and Wales by deleting sub-paragraph (a) (the coating of road vehicles).

Transitional provisions

10. Any relevant product which—

(a)does not meet the VOC limits required by Schedule 2; and

(b)was produced before the dates specified in Schedule 2,

may be placed on the market for a period of 12 months following the dates applicable to that product in Schedule 2.

Ben Bradshaw

Parliamentary Under Secretary of State 9th October 2005 Department for Environment, Food and Rural Affairs

SCHE

1

D ULE

Regulation 3(1)

1.—(1) For the purposes of these Regulations, “paints and varnishes” means products listed in the sub-categories below, excluding aerosols. They are coatings applied to buildings, their trim and fittings, and associated structures for decorative, functional and protective purpose.

(2)The sub-categories referred to in sub-paragraph (1) are—

(a)“matt coatings for interior walls and ceilings” means coatings designed for application to

indoor walls and ceilings with a degree of gloss 25@60°;

(b)“glossy coatings for interior walls and ceilings” means coatings designed for application

to indoor walls and ceilings with a degree of gloss >25@60°;

(c)“coatings for exterior walls of mineral substrate” means coatings designed for application

to outdoor walls of masonry, brick or stucco;

(d)“interior/exterior trim and cladding paints for wood, metal or plastic” means coatings

designed for application to trim and cladding which produce an opaque film. These coatings are designed for either a wood, metal or a plastic substrate. This subcategory includes undercoats and intermediate coatings;

(e)“interior/exterior trim varnishes and woodstains” means coatings designed for application

to trim which produce a transparent or semi-transparent film for decoration and protection of wood, metal and plastics. This subcategory includes opaque woodstains. Opaque woodstains means coatings producing an opaque film for the decoration and protection of wood, against weathering, as defined in EN 927-1, within the semi-stable category;

(f)“minimal build woodstains” means woodstains which, in accordance with EN 927-

1:1996, have a mean thickness of less than 5μm when tested according to ISO 2808: 1997, method 5A;

(g)“primers” means coatings with sealing and/or blocking properties designed for use on

wood or walls and ceilings;

(h)“binding primers” means coatings designed to stabilise loose substrate particles or impart

hydrophobic properties and/or to protect wood against blue stain;

(i)“one-pack performance coatings” means performance coatings based on film-forming

material. They are designed for applications requiring a special performance, such as primer and topcoats for plastics, primer coat for ferrous substrates, primer coat for reactive metals such as zinc and aluminium, anticorrosion finishes, floor coatings, including for wood and cement floors, graffiti resistance, flame retardant, and hygiene standards in the food or drink industry or health services;

(j)“two-pack performance coatings” means coatings with the same use as one-performance coatings, but with a second component (e.g. tertiary amines) added prior to application;

(k)“multicoloured coatings” means coatings designed to give a two-tone or multiple-colour effect, directly from the primary application;

(l)“decorative effect coatings” means coatings designed to give special aesthetic effects over specially prepared pre-painted substrates or base coats and subsequently treated with various tools during the drying period.

2.—(1) For the purposes of these Regulations, “vehicle refinishing products” means products listed in the sub-categories below. They are used for the coating of road vehicles as defined in D irective 70/156/EEC(a), or part of them, carried out as part of vehicle repair, conservation or decoration outside of manufacturing installations.

(2)The sub-categories referred to in sub-paragraph (1) are—

(a) O.J. L42, 23.2.1970, p.1, as last amended by Directive 2004/3/EC, O.J. L49, 19.2.2004, p.36.

(a)“preparatory and cleaning” means products designed to remove old coatings and rust,

either mechanically or chemically, or to provide a key for new coatings:

(i)preparatory products include gunwash (a product designed for cleaning spray-guns

and other equipment), paint strippers, degreasers (including anti-static types for

plastic) and silicone removers;

(ii)“precleaner” means a cleaning product designed for the removal of surface contamination during preparation for and prior to the application of coating

materials;

(b)“Bodyfiller/stopper” means heavy-bodied compounds designed to be applied to fill deep

surface imperfections prior to the application of the surfacer/filler;

(c)“primer” means any coating that is designed for application to bare metal or existing

finishes to provide corrosion protection prior to application of a primer surfacer:

(i) “surfacer/filler” means a coating designed for application immediately prior to the

application of topcoat for the purpose of corrosion resistance, to ensure adhesion of

the topcoat, and to promote the formation of a uniform surface finish by filling in

minor surface imperfections;

(ii)“general metal primer” means a coating designed for application as primers, such as adhesion promoters, sealers, surfacers, undercoats, plastic primers, wet-on-wet, non-

sand fillers and spray fillers;

(iii)“wash primer” means coatings containing at least 0,5 % by weight of phosphoric acid designed to be applied directly to bare metal surfaces to provide corrosion

resistance and adhesion; coatings used as weldable primers; and mordant solutions

for galvanised and zinc surfaces;

(d)“topcoat” means any pigmented coating that is designed to be applied either as a single-

layer or as a multiple-layer base to provide gloss and durability. It includes all products involved such as base coatings and clear coatings:

(i)“base coatings” means pigmented coatings designed to provide colour and any

desired optical effects, but not the gloss or surface resistance of the coating system;

(ii)“clear coating” means a transparent coating designed to provide the final gloss and resistance properties of the coating system;

(e)“special finishes” means coatings designed for application as topcoats requiring special

properties, such as metallic or pearl effect, in a single layer, high-performance solid-colour and clear coats, (e.g. anti-scratch and fluorinated clear- coat), reflective base coat, texture finishes (e.g. hammer), anti-slip, under-body sealers, anti-chip coatings, interior finishes; and aerosols.

(3)In this Schedule—

”coating” means any preparation, including all the organic solvents or preparations containing organic solvents necessary for its proper application, which is used to provide a film with decorative, protective or other functional effect on a surface;

“film” means a continuous layer resulting from the application of one or more coats to a substrate;

“organic solvent” means any VOC which is used—

(i)alone or in combination with other agents to dissolve or dilute raw materials,

products, or waste materials;

(ii)as a cleaning agent to dissolve contaminants;

(iii)as a dispersion medium;

(iv)as a viscosity adjuster;

(v)as a surface tension adjuster;

(vi)as a plasticiser; or

(vii)as a preservative;

“preparation” means mixtures or solutions composed of two or more substances; and

“substances” means any chemical element and its compounds, as they occur in the natural state or as produced by industry, whether in solid or liquid or gaseous form.

SCHE

D ULE

2Regulations 4 and 5 A. MAXIMUM VOC CONTENT LIMIT VALUES FOR PAINTS AND

VARNISHES

Product Subcategory Type

(*)

Phas

e I (g/l

(**))(from 1.1.2007)

Phas

e II (g/l

(**))(from 1.1.2010)

a Interior matt walls and ceilings (Gloss

25@60°) WB

SB

75

400

30

30

b Interior glossy walls and ceilings (Gloss

>25@60°) WB

SB

150

400

100

100

c Exterior walls of mineral substrate WB

SB 75

450

40

430

d Interior/exterior

trim and cladding paints for wood and metal WB

SB

150

400

130

300

e Interior/exterior trim varnishes and woodstains,

including opaque woodstains WB

SB

150

500

130

400

f Interior and exterior minimal build woodstains WB

SB 150

700

130

700

g Primers WB

SB 50

450

30

350

h Binding

primers WB

SB 50

750

30

750

i One-pack performance coatings WB

SB 140

600

140

500

j Two-pack reactive performance coatings for specific end use such as floors WB

SB

140

550

140

500

k Multi-coloured

coatings WB

SB 150

400

100

100

l Decorative effect coatings WB

SB 300

500

200

200

(*)“solvent-borne coatings (SB)” means coatings the viscosity of which is adjusted by the use of organic solvent; and

“water-borne coatings (WB)” means coatings the viscosity of which is adjusted by the use of water; where “coatings” has the meaning defined in paragraph 3 of Schedule 1.

(**) g/l ready to use

B. MAXIMUM VOC CONTENT LIMIT VALUES FOR VEHICLE

REFINISHING PRODUCTS

Product Subcategory Coatings VOC g/l (*) (1.1.2007)

a Preparatory and cleaning Preparatory

Pre-cleaner 850 200

b Bodyfiller/stopper All

types 250

c Primer Surfacer/filler an

d general

(metal) primer

Wash primer 540 780

d Topcoat All

types 420

e Special finishes All types 840

(*) g/l of ready for use product. Except for subcategory (a) any water content of the product ready for use should be discounted.

SCHE

D ULE

3

Regulation 4(2) METHODS REFERRED TO IN REGULATION 3(3)

Test

Param

e t

e r Unit

Method Date of publication VOC content g/l ISO 11890-2) 2002

VOC content where

reactive diluents are present g/l ASTM

D2369)

2003

SCHE

D ULE

4

Regulation 7(6) ENFORCEMENT POWERS AND RELATED OFFENCES IN

NORTHERN IRELAND

PART 1

POWERS OF ENTRY

1. An authorised person may, on production (if so required) of his authority, exercise any of the powers specified in paragraph 2 for the purpose of determining whether any provision of these Regulations is being, or has been, complied with.

2. The powers of an authorised person are—

(a)to enter at any reasonable time any premises which he has reason to believe it is

necessary for him to enter;

(b)on entering any premises by virtue of sub-paragraph (a), to take with him—

(i)any other person duly authorised by the enforcing authority and, if the authorised

person has reasonable cause to apprehend any serious obstruction in the execution of

his duty, a constable; and

(ii)any equipment or materials required for any purpose for which the power of entry is being exercised;

(c)to make such examination and investigation as may in any circumstances be necessary;

(d)as regards any premises which he has power to enter, to direct that those premises or any

part of them, or anything in them, shall be left undisturbed (whether generally or in particular respects) for so long as is reasonably necessary for the purpose of any examination or investigation under sub-paragraph (c);

(e)to take such measurements and photographs and make such recordings as he considers

necessary for the purpose of any examination or investigation under sub-paragraph (c);

(f)to take samples, or cause samples to be taken, of any relevant product found in or on any

premises which he has power to enter, and of the air, in, on, or in the vicinity of, the premises;

(g)to require any person whom he has reasonable cause to believe to be able to give any

information relevant to any examination or investigation under sub-paragraph (c) to answer (in the absence of persons other than a person nominated by that person to be present and any persons whom the authorised person may allow to be present) such questions as the authorised person thinks fit to ask and to sign a declaration of the truth of his answers;

(h)to require the production of, or where the information is recorded in computerised form,

the furnishing of extracts from, any records which it is necessary for him to see for the purposes of an examination or investigation under sub-paragraph (c), and to inspect and take copies of, or of any entry in, the records;

(i)to require any person to afford him such facilities and assistance with respect to any

matters or things within that person’s control or in relation to which that person has responsibilities as are necessary to enable the authorised person to exercise any of the powers conferred on him by paragraph 1 and this paragraph;

3. The powers which under paragraphs 1 and 2 are conferred in relation to any premises for the purpose of enabling an enforcing authority to determine whether any provision of these Regulations is being, or has been, complied with shall include power, in order to obtain the information on which that determination may be made, to install, keep or maintain monitoring and other apparatus there.

4. In any case where it is proposed to enter any premises used for residential purposes, any entry by virtue of this Part shall only be effected—

(a)after the expiration of at least seven days’ notice of the proposed entry given to a person

who appears to the authorised person in question to be in occupation of the premises in question, and

(b)with the consent of a person who is in occupation of those premises;

5. No answer given by a person in pursuance of a requirement imposed under paragraph 2(g) shall be admissible in evidence against that person in any proceedings.

6. Nothing in this Part shall be taken to compel the production by any person of a document of which he would on grounds of legal professional privilege be entitled to withhold production on an order for discovery in an action in the High Court.

7. Nothing in section 98 of the Local Government Act (Northern Ireland) 1972 (c. 9) shall apply to powers conferred on an authorised person by a district council under this Part.

PART II

OFFENCES

8. It is an offence for a person intentionally to obstruct an authorised person in the exercise of his powers or duties.

9. It is an offence for a person, without reasonable excuse—

(a)to fail to comply with any requirement imposed under Part I;

(b)to fail or refuse to provide facilities or assistance or any information or to permit any

inspection reasonably required by an authorised person in the exercise of his powers or duties under that Part; or

(c)to prevent any other person from appearing before an authorised person, or answering any

question to which an authorised person may require an answer under that Part.

10. A person guilty of an offence under paragraph 8 or 9 shall be liable on summary conviction to a fine not exceeding level 5 on the standard scale.

PART III

DEFINITIONS

11. In this Schedule—

“authorised person” means a person who is authorised in writing by an enforcing authority for the purposes of these Regulations;

“constable” has the meaning given to it by section 43A of the Interpretation Act (Northern Ireland) 1954(a);

“enforcing authority” means—

(a)the Secretary of State; or

(b)where the Secretary of State has delegated any or all of her functions under Regulation

7(4) of these Regulations to the Department of the Environment or to a district council in Northern Ireland, that Department or district council;

“mobile plant” means plant which is designed to move or to be moved whether on roads or otherwise;

“premises” includes any land, vehicle, vessel or mobile plant.

(a) 1954 c.33 (N.I.).

EXPLANATORY NOTE

(This note is not part of the Regulations)

These Regulations are made in implementation of D irective 2004/42/EC (“the VOCs in Paints Directive”) on the limitation of emissions of volatile organic compounds due to the use of organic solvents in certain paints and varnishes and vehicle refinishing products, and amending Directive 1999/13/EC (the Solvent Emissions Directive).

The Volatile Organic Compounds in Paints Directive lays down maximum content limit values for volatile organic compounds (VOCs) which apply in two phases for paints and varnishes, that is to say, from 1st January 2007 for the first phase limits, and from 1st January 2010 for the tighter, second phase limits. These limits are set out in Part A of Annex II to the Directive. The directive lays down a single set of content limit values for VOCs in vehicle refinishing products in Part B of Annex 2, which apply from 1st January 2007. Annex II is set out in Schedule 2 to these Regulations.

Regulation 3 applies the regulations to the products covered by Annex I of the VOCs in Paints Directive, unless they are for use outside the European Community or are for uses regulated by the regulations implementing Directive 1999/13/EC.

Regulation 4 limits the marketing of paints and varnishes and vehicle refinishing products, listed in Schedule 1, unless they have a VOC (volatile organic compound) content which does not exceed the limit values set out in Schedule 2 by the dates set out in that Schedule. Schedule 3 sets out the analytical methods to be applied in determining the VOC content of products. Regulation 5 requires that products in Schedule 1 carry a label concerning the maximum VOC content of that product in a ready to use condition.

Regulation 6 designates the Secretary of State as the competent authority for the United Kingdom for ensuring fulfilment of the obligations of Directive 2004/42/EC, and requires that she consult the devolved administrations as necessary in the exercise of these responsibilities.

Regulation 7 provides that it is the Secretary of State’s function to enforce the Regulations (though not to prosecute in Scotland, where the procurator fiscal prosecutes), and requires the Secretary of State to establish and maintain a programme of monitoring for the purpose of determining whether the Regulations are being complied with. The Secretary of State may delegate her monitoring and enforcement functions to others to such extent as she determines, but must publish appropriate notice of any such delegation. Except in Northern Ireland, section 108 of the Environment Act 1995 provides powers for persons authorised by (among other authorities) the Secretary of State to establish whether the regulations, being pollution control enactments, are being complied with and to obtain evidence necessary to take enforcement action. These powers include the power to enter premises and to take samples, which may be tested. Special provisions in relation to enforcement powers in Northern Ireland are set out in Schedule 4.

Regulation 8 creates offences of contravening regulation 4, and prescribes penalties. Directors and similar officers of bodies corporate are liable to conviction in certain circumstances where the offence is attributable to their fault. An evidential burden rests on a person relying on the transitional provision in regulation 10 to show when the product was produced. The maximum penalties are a fine on conviction on indictment, and on summary conviction, a fine of the statutory maximum, which, at the time of making these Regulations, is £5,000.

Regulation 9, which applies to England and Wales only, amends Section 7 of Part 1 of Schedule 1 to the Pollution Prevention and Control (England and Wales) Regulations 2000. This in turn gives effect to the implementation of the Solvent Emissions D irective by the Solvent Emissions (England and Wales) Regulations 2004. Regulation 9 deletes from the scope of the 2000 Regulations one category of “vehicle refinishing” which has been removed by Article 13 of Directive 2004/42/EC. Similar amendments will be made by the devolved administrations to the relevant regulations applicable to Scotland and Northern Ireland.

Regulation 10 provides transitional provisions. A product to which these Regulations apply may be placed on the market for 12 months after the appropriate date specified above if it was produced before that date.

The EN standards referred to in paragraph 1e) and f) of Schedule 1, may be obtained from any of the sales outlets operated by the British Standards Institute or the BSI via their website – https://www.360docs.net/doc/eb18025130.html,/index.xalter. The ISO standards referred to in paragraph 1e) of Schedule 1 and in Schedule 3, may be obtained from the International Organisation for Standardisation (ISO) via their website - https://www.360docs.net/doc/eb18025130.html,/iso/en/ISOOnline.frontpage. The ASTM standard referred to in Schedule 3, can be obtained from ASTM International via their website - https://www.360docs.net/doc/eb18025130.html,.

A full Regulatory Impact Assessment and a transposition note has been prepared in connection with the amendments made by these Regulations, and placed in the library of each House of Parliament. Copies are obtainable from Ian Oldfield, Air and Environmental Quality D ivision, D epartment for Environment, Food and Rural Affairs, Room 4/G15, Ashdown House, 123 Victoria Street, London SW1E 6DE (email: ian.oldfield@https://www.360docs.net/doc/eb18025130.html,).

£3.00

¤ Crown copyright 2005

Printed and published in the UK by The Stationery Office Limited

under the authority and superintendence of Carol Tullo, Controller of Her Majesty’s

Stationery Office and Queen’s Printer of Acts of Parliament.

E1414 10/2005 151414T 19585

关键字const有什么含意? 我只要一听到被面试者说:“const意味着常数”,我就知道我正在和一个业余者打交道。去年Dan Saks已经在他的文章里完全概括了const的所有用法,因此ESP(译者:Embedded Systems Programming)的每一位读者应该非常熟悉const能做什么和不能做什么.如果你从没有读到那篇文章,只要能说出const意味着“只读”就可以了。尽管这个答案不是完全的答案,但我接受它作为一个正确的答案。(如果你想知道更详细的答案,仔细读一下Saks的文章吧。) 如果应试者能正确回答这个问题,我将问他一个附加的问题: 下面的声明都是什么意思? const int a; int const a; const int *a; int * const a; int const * a const; /******/ 前两个的作用是一样,a是一个常整型数。第三个意味着a是一个指向常整型数的指针(也就是,整型数是不可修改的,但指针可以)。第四个意思a是一个指向整型数的常指针(也就是说,指针指向的整型数是可以修改的,但指针是不可修改的)。最后一个意味着a是一个指向常整型数的常指针(也就是说,指针指向的整型数是不可修改的,同时指针也是不可修改的)。如果应试者能正确回答这些问题,那么他就给我留下了一个好印象。顺带提一句,也许你可能会问,即使不用关键字const,也还是能很容易写出功能正确的程序,那么我为什么还要如此看重关键字const呢?我也如下的几下理由: ?; 关键字const的作用是为给读你代码的人传达非常有用的信息,实际上,声明一个参数为常量是为了告诉了用户这个参数的应用目的。如果你曾花很多时间清理其它人留下的垃圾,你就会很快学会感谢这点多余的信息。(当然,懂得用const的程序员很少会留下的垃圾让别人来清理的。) ?; 通过给优化器一些附加的信息,使用关键字const也许能产生更紧凑的代码。 ?; 合理地使用关键字const可以使编译器很自然地保护那些不希望被改变的参数,防止其被无意的代码修改。简而言之,这样可以减少bug的出现。 Volatile 8. 关键字volatile有什么含意?并给出三个不同的例子。 一个定义为volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用保存在寄存器里的备份。下面是volatile变量的几个例子: ?; 并行设备的硬件寄存器(如:状态寄存器) ?; 一个中断服务子程序中会访问到的非自动变量(Non-automatic variables) ?; 多线程应用中被几个任务共享的变量 回答不出这个问题的人是不会被雇佣的。我认为这是区分C程序员和嵌入式系统程序员的最基本的问题。搞嵌入式的家伙们经常同硬件、中断、RTOS等等打交道,所有这些都要求用到volatile变量。不懂得volatile的内容将会带来灾难。 假设被面试者正确地回答了这是问题(嗯,怀疑是否会是这样),我将稍微深究一下,看一下这家伙是不是直正懂得volatile 完全的重要性。 ?; 一个参数既可以是const还可以是volatile吗?解释为什么。 ?; 一个指针可以是volatile 吗?解释为什么。

本文主要讲述c语言的一点基础语法和在内核的应用中其中的一点例子。 #,##分别在c语言中是怎么作用? 文章代码编译的环境: 桌面环境:Ubuntu10.04 内核:linux2.6.32 编译器:gcc4.4.3 一、基本的用法 1、#.参数名以#作为前缀则结果将被扩展为由实际参数的带引号的字符串。如: #define dprint(expr)printf(#expr"=%d\n",expr); intmain() { inta=20,b=10; dprint(a/b); return0; } 上面的例子会打印出: a/b=2 2、##.预处理器运算符##为宏提供了一种连接实际参数的手段。如果替换文本中的参数与##相邻,则该参数将被实际参数替换,##与前后的空白将被删除,并对替换后的结果重新扫描。 形成一个新的标号,如果这样产生的记号无效,或者结果依赖于##运算顺序,则结果没有定义。 如: #definepaste(front,back)front##back 因此,宏调用paste(name,_xiaobai)的结果为name_xiaobai. 如: #define createfun(name1,name2)\ void name1##name2()\ {\ printf("%scalled\n",__FUNCTION__);\ } createfun(the,function); intmain() { thefunction(); return0; } 输出的结果是:thefunctioncalled 二、##可以嵌套吗?

看下面的例子: #define cat(x,y)x##y 宏调用cat(var,123)讲生成var123. 但是,宏调用cat(cat(1,2),3)没有定义:##阻止了外层调用的参数的扩展。因此,它将生成下列的记号串: cat(1,2)3. 如果要再引入第二层的宏定义,如下定义: #define xcat(x,y)cat(x,y) 那么xcat(xcat(1,2),3)将生成123, 这是因为xcat自身的扩展不包含##运算符。 三、linux内核中例子 因为是做mips架构的,所以以mips为例子。 Linux2.6.25内核,include/asm-mips/io.h文件。拷贝一部分的代码出来。 #define__BUILD_MEMORY_SINGLE(pfx,bwlq,type,irq)\ \ staticinlinevoidpfx##write##bwlq(typeval,\ volatilevoid__iomem*mem)\ {\ volatiletype*__mem;\ type__val;\ \

一、volatile的作用 我们已经知道可见性、有序性及原子性问题,通常情况下我们可以通过Synchronized关键字来解决这些个问题,不过如果对Synchronized原理有了解的话,应该知道Synchronized是一个比较重量级的操作,对系统的性能有比较大的影响,所以,如果有其他解决方案,我们通常都避免使用Synchronized来解决问题。 而volatile关键字就是Java中提供的另一种解决可见性和有序性问题的方案。对于原子性,需要强调一点,也是大家容易误解的一点:对volatile变量的单次读/写操作可以保证原子性的,如long和double类型变量,但是并不能保证i++这种操作的原子性,因为本质上i++是读、写两次操作。 二、volatile的使用 关于volatile的使用,我们可以通过几个例子来说明其使用方式和场景。 1、防止重排序 我们从一个最经典的例子来分析重排序问题。大家应该都很熟悉单例模式的实现,而在并发环境下的单例实现方式,我们通常可以采用双重检查加锁(DCL)的方式来实现。其源码如下: package com.paddx.test.concurrent; public class Singleton { public static volatile Singleton singleton; /** * 构造函数私有,禁止外部实例化 */ private Singleton() {}; public static Singleton getInstance() { if (singleton == null) { synchronized (singleton) { if (singleton == null) { singleton = new Singleton(); } } } return singleton; } } 现在我们分析一下为什么要在变量singleton之间加上volatile关键字。要理解这个问题,先要了解对象的构造过程,实例化一个对象其实可以分为三个步骤: ?分配内存空间。 ?初始化对象。

转载来自hbtian的笔记 讲讲volatile的作用 一个定义为volatile的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用保存在寄存器里的备份。下面是volatile变量的几个例子: 1). 并行设备的硬件寄存器(如:状态寄存器) 2). 一个中断服务子程序中会访问到的非自动变量(Non-automatic variables) 3). 多线程应用中被几个任务共享的变量 回答不出这个问题的人是不会被雇佣的。我认为这是区分C程序员和嵌入式系统程序员的最基本的问题。嵌入式系统程序员经常同硬件、中断、RTOS等等打交道,所用这些都要求volatile 变量。不懂得volatile内容将会带来灾难。 假设被面试者正确地回答了这是问题(嗯,怀疑这否会是这样),我将稍微深究一下,看一下这家伙是不是直正懂得volatile完全的重要性。 1). 一个参数既可以是const还可以是volatile吗?解释为什么。 2). 一个指针可以是volatile 吗?解释为什么。 3). 下面的函数有什么错误: int square(volatile int *ptr) { return *ptr * *ptr; } 下面是答案:

1). 是的。一个例子是只读的状态寄存器。它是volatile因为它可能被意想不到地改变。它是const因为程序不应该试图去修改它。 2). 是的。尽管这并不很常见。一个例子是当一个中服务子程序修该一个指向一个buffer的指针时。 3). 这段代码的有个恶作剧。这段代码的目的是用来返指针*ptr指向值的平方,但是,由于*ptr指向一个volatile型参数,编译器将产生类似下面的代码: int square(volatile int *ptr) { int a,b; a = *ptr; b = *ptr; return a * b; } 由于*ptr的值可能被意想不到地该变,因此a和b可能是不同的。结果,这段代码可能返不是你所期望的平方值!正确的代码如下: long square(volatile int *ptr) { int a; a = *ptr; return a * a; }

计算机二级C技巧:c语言中的volatile关键字 来源:考试大 2009年06月10日10:36 volatile关键字是一种类型修饰符,用它声明的类型变量表示可以被某些编译器未知的因素更改。 用volatile关键字声明的变量i每一次被访问时,执行部件都会从i相应的内存单元中取出i的值。 没有用volatile关键字声明的变量i在被访问的时候可能直接从cpu的寄存器中取值(因为之前i被访问过,也就是说之前就从内存中取出i的值保存到某个寄存器中),之所以直接从寄存器中取值,而不去内存中取值,是因为编译器优化代码的结果(访问cpu寄存器比访问ram快的多)。 以上两种情况的区别在于被编译成汇编代码之后,两者是不一样的。之所以这样做是因为变量i可能会经常变化,保证对特殊地址的稳定访问。 volatile关键字是一种类型修饰符,用它声明的类型变量表示可以被某些编译器未知的因素更改,比如:操作系统、硬件或者其它线程等。遇到这个关键字声明的变量,编译器对访问该变量的代码就不再进行优化,从而可以提供对特殊地址的稳定访问。 使用该关键字的例子如下: int volatile nVint; 当要求使用volatile 声明的变量的值的时候,系统总是重新从它所在的内存读取数据,即使它前面的指令刚刚从该处读取过数据。而且读取的数据立刻被保存。 例如: volatile int i=10; int a = i; ... //其他代码,并未明确告诉编译器,对i进行过操作 int b = i; volatile 指出i是随时可能发生变化的,每次使用它的时候必须从i的地址中读取,因而编译器生成的汇编代码会重新从i的地址读取数据放在b中。而优化做法是,由于编译器发现两次从i读数据的代码之间的代码没有对i进行过操作,它会自动把上次读的数据放在b中。而不是重新从i里面读。这样以来,如果i是一个寄存器变量或者表示一个端口数据就容易出错,所以说volatile可以保证对特殊地址的稳定访问。 注意,在vc6中,一般调试模式没有进行代码优化,所以这个关键字的作用看不出来。下面通过插入汇编代码,测试有无volatile关键字,对程序最终代码的影响: 首先,用classwizard建一个win32 console工程,插入一个voltest.cpp文件,输入下面的代码:#i nclude void main() { int i=10; int a = i; printf("i= %d\n",a); //下面汇编语句的作用就是改变内存中i的值,但是又不让编译器知道

C语言关键字 int char float double long short unsigned sizeof scanf printf 整型字符单精度双精度长整型短整型无符号计算字节格式输入格式输出 putchar getchar if else swtich case break (while do-while for) continue 字符输出字符输入判断多分支判断跳出循环循环提前结束循环goto 字符(puts gets strcmp strcpy strcat strlen )return 无条件转移串输出串输入串比较串拷贝串连接串长度测试函数返回 auto static register struct FLIE 自动型静态寄存器结构文件结构 (fopen fclose fgetc fread fscanf fputc fwrite fprintf rewind fseek ftell)打开关闭单字符组数据格式化入单字符组数据格式化出开头指定返回enum union void default extern const trpedef volatile 定义枚举联合无返回无,结束外部变量修饰作用定义新名修饰 非缓冲(open creat close read write lseek tell) 文件打开文件创建文件关闭文件读文件写定位指定文件返回 C语言各语法定义 int :int 变量名;int x,y; Char: char 变量名;char x,y; Float: float 变量名;float x,y; Double: double 变量名;double x,y; Long: long int 变量名;long int x,y; Short: short int 变量名;short int x,y; Unsigned: unsigned 变量名; unsigned int x,y; Sizeof: sizeof(类型名); sizeof(int); Scanf: scanf(格式控制,地址表);(" %d%o%x%c%f%e%s ",&十,&八,&十六,&单, &浮点,&浮点,&以'\0'为结束) ; Printf: printf(格式控制,输出表);("%d%o%x%u%c%f%e%s%", 十,八,十六,单,浮点, 浮点,以%0为结束); Putchar:putchat(c); Getchar:getchar(c); If: if(条件表达式){ 语句} Else: if(条件表达式){语句1;else 语句2;}

本文主要讲述c语言的一点基础语法与在内核的应用中其中的一点例子。 #,##分别在c语言中就是怎么作用? 文章代码编译的环境: 桌面环境:Ubuntu10、04 内核:linux2、6、32 编译器:gcc4、4、3 一、基本的用法 1、#、参数名以#作为前缀则结果将被扩展为由实际参数的带引号的字符串。如: #define dprint(expr)printf(#expr"=%d\n",expr); intmain() { inta=20,b=10; dprint(a/b); return0; } 上面的例子会打印出: a/b=2 2、##、预处理器运算符##为宏提供了一种连接实际参数的手段。如果替换文本中的参数与##相邻,则该参数将被实际参数替换,##与前后的空白将被删除,并对替换后的结果重新扫描。 形成一个新的标号,如果这样产生的记号无效,或者结果依赖于##运算顺序,则结果没有定义。 如: #definepaste(front,back)front##back 因此,宏调用paste(name,_xiaobai)的结果为name_xiaobai、 如: #define createfun(name1,name2)\ void name1##name2()\ {\ printf("%scalled\n",__FUNCTION__);\ } createfun(the,function); intmain() { thefunction(); return0; } 输出的结果就是:thefunctioncalled 二、##可以嵌套不? 瞧下面的例子: #define cat(x,y)x##y

C语言中auto,register,static,const,volatile的区别 (1)auto 这个关键字用于声明变量的生存期为自动,即将不在任何类、结构、枚举、联合和函数中定义的变量视为全局变量,而在函数中定义的变量视为局部变量。这个关键字不怎么多写,因为所有的变量默认就是auto的。 (2)register 这个关键字命令编译器尽可能的将变量存在CPU内部寄存器中而不是通过内存寻址访问以提高效率。 (3)static 常见的两种用途: 1>统计函数被调用的次数; 2>减少局部数组建立和赋值的开销.变量的建立和赋值是需要一定的处理器开销的,特别是数组等含有较多元素的存储类型。在一些含有较多的变量并且被经常调用的函数中,可以将一些数组声明为static类型,以减少建立或者初始化这些变量的开销. 详细说明: 1>、变量会被放在程序的全局存储区中,这样可以在下一次调用的时候还可以保持原来的赋值。这一点是它与栈变量和堆变量的区别。 2>、变量用static告知编译器,自己仅仅在变量的作用范围内可见。这一点是它与全局变量的区别。 3>当static用来修饰全局变量时,它就改变了全局变量的作用域,使其不能被别的程序extern,限制在了当前文件里,但是没有改变其存放位置,还是在全局静态储存区。 使用注意: 1>若全局变量仅在单个C文件中访问,则可以将这个变量修改为静态全局变量,以降低模块间的耦合度; 2>若全局变量仅由单个函数访问,则可以将这个变量改为该函数的静态局部变量,以降低模块间的耦合度; 3>设计和使用访问动态全局变量、静态全局变量、静态局部变量的函数时,需要考虑重入问题(只要输入数据相同就应产生相同的输出)。 (4)const 被const修饰的东西都受到强制保护,可以预防意外的变动,能提高程序的健壮性。它可以修饰函数的参数、返回值,甚至函数的定义体。 作用: 1>修饰输入参数 a.对于非内部数据类型的输入参数,应该将“值传递”的方式改为“const引用传递”,目的是提高效率。例如将void Func(A a) 改为void Func(const A &a)。 b.对于内部数据类型的输入参数,不要将“值传递”的方式改为“const引用传递”。否则既达不到提高效率的目的,又降低了函数的可理解性。例如void Func(int x) 不应该改为void Func(const int &x)。 2>用const修饰函数的返回值 a.如果给以“指针传递”方式的函数返回值加const修饰,那么函数返回值(即指针)的内容不能被修改,该返回值只能被赋给加const修饰的同类型指针。 如对于:const char * GetString(void); 如下语句将出现编译错误: char *str = GetString();//cannot convert from 'const char *' to 'char *'; 正确的用法是:

八大浪费是定义工厂在JIT生产方式中的,其浪费的含义与社会上通常所说的浪费有所区别。对于JIT 来讲,凡是超出增加产品价值所必需的绝对最少的物料、设备、人力、场地和时间的部分都是浪费。因此,JIT生产方式所讲的工厂的浪费归纳为八大种,分别是:不良、修理的浪费,过分加工的浪费,动作的浪费,搬运的浪费,库存的浪费,制造过多过早的浪费,等待的浪费和管理的浪费,简称为八大浪费。 2具体表现 1.不良、修理的浪费 所谓不良、修理的浪费,指的是由于工厂内出现不良品,需要进行处置的时间、人力、物力上的浪费,以及由此造成的相关损失。这类浪费具体包括:材料的损失、不良品变成废品;设备、人员和工时的损失; 额外的修复、鉴别、追加检查的损失;有时需要降价处理产品,或者由于耽误出货而导致工厂信誉的下降。 2.加工的浪费 加工的浪费也叫过分加工的浪费,主要包含两层含义:第一是多余的加工和过分精确的加工,例如实际加工精度过高造成资源浪费;第二是需要多余的作业时间和辅助设备,还要增加生产用电、气压、油等能源的浪费,另外还增加了管理的工时。 3.动作的浪费 动作的浪费现象在很多企业的生产线中都存在,常见的动作浪费主要有以下12种:两手空闲、单手空闲、作业动作突然停止、作业动作过大、左右手交换、步行过多、转身的角度太大,移动中变换“状态”、不明技巧、伸背动作、弯腰动作以及重复动作和不必要的动作等,这些动作的浪费造成了时间和体力上的不必要消耗。 4.搬运的浪费 从JIT的角度来看,搬运是一种不产生附加价值的动作,而不产生价值的工作都属于浪费。搬运的浪费具体表现为放置、堆积、移动、整列等动作浪费,由此而带来物品移动所需空间的浪费、时间的浪费和人力工具的占用等不良后果。 国内目前有不少企业管理者认为搬运是必要的,不是浪费。因此,很多人对搬运浪费视而不见,更谈不上去消灭它。也有一些企业利用传送带或机器搬运的方式来减少人工搬运,这种做法是花大钱来减少工人体力的消耗,实际上并没有排除搬运本身的浪费。 5.库存的浪费 按照过去的管理理念,人们认为库存虽然是不好的东西,但却是必要的。JIT的观点认为,库存是没有必要的,甚至认为库存是万恶之源。如图1-1,由于库存很多,将故障、不良品、缺勤、点点停、计划有误、调整时间过长、品质不一致、能力不平衡等问题全部掩盖住了。 例如,有些企业生产线出现故障,造成停机、停线,但由于有库存而不至于断货,这样就将故障造成停机、停线的问题掩盖住了,耽误了故障的排除。如果降低库存,就能将上述问题彻底暴露于水平面,进而能够逐步地解决这些库存浪费.。 6.制造过多过早的浪费 制造过多或过早,提前用掉了生产费用,不但没有好处,还隐藏了由于等待所带来的浪费,失去了持续改善的机会。有些企业由于生产能力比较强大,为了不浪费生产能力而不中断生产,增加了在制品,使得制品周期变短、空间变大,还增加了搬运、堆积的浪费。此外,制造过多或过早,会带来庞大的库存量,利息负担增加,不可避免地增加了贬值的风险。 7.等待的浪费 由于生产原料供应中断、作业不平衡和生产计划安排不当等原因造成的无事可做的等待,被称为等待的浪费。生产线上不同品种之间的切换,如果准备工作不够充分,势必造成等待的浪费;每天的工作量变动幅度过大,有时很忙,有时造成人员、设备闲置不用;上游的工序出现问题,导致下游工序无事可做。此外,生产线劳逸不均等现象的存在,也是造成等待浪费重要原因。

#define用法以及#define和typedef区别1.简单的define定义 #define MAXTIME 1000 2.define的“函数定义” define可以像函数那样接受一些参数,如下 #define max(x,y) (x)>(y)?(x):(y); 因为这个“函数”没有类型检查,就好像一个函数模板似的,没有模板那么安全就是了。 但是这样做的话存在隐患,例子如下: #define Add(a,b) a+b;如果遇到如:c * Add(a,b) * d的时候就会出现问题。 另外举一个例子: #define pin (int*); pin a,b; 本意是a和b都是int型指针,但是实际上变成int* a,b; a是int型指针,而b是int型变量。 这时应该使用typedef来代替define,这样a和b就都是int型指针了。 我们在定义的时候,养成一个良好的习惯,建议所有的层次都要加括号。 3.宏的单行定义(少见用法) #define A(x) T_##x #define B(x) #@x #define C(x) #x 我们假设:x=1,则有: A(1)------〉T_1 B(1)------〉'1' C(1)------〉"1" 4.define的多行定义 define可以替代多行的代码,例如MFC中的宏定义(非常的经典,虽然让人看了恶心)

#define MACRO(arg1, arg2) do { \ /* declarations */ \ stmt1; \ stmt2; \ /* ... */ \ } while(0) /* (no trailing ; ) */ 关键是要在每一个换行的时候加上一个"\" 5.在大规模的开发过程中,特别是跨平台和系统的软件里,define最重要的功能是条件编译。 就是: #ifdef WINDOWS ...... ...... #endif #ifdef LINUX ...... ...... #endif 可以在编译的时候通过#define设置编译环境。 6.如何定义宏、取消宏 #define [MacroName] [MacroValue] //定义宏 #undef [MacroName] //取消宏 #define PI (3.1415926) //普通宏 #define max(a,b) ((a)>(b)? (a),(b)) //带参数的宏 7.条件编译 #ifdef XXX…(#else) … #endif 例如 #ifdef DV22_AUX_INPUT #define AUX_MODE 3

标签:*(volatile unsigned char*) (*(volatile unsigned char *)0x56000010) 以前看到#define SREG (*(volatile unsigned char *)0x5F)这样的定义,总是感觉很奇怪,不知道为什么,今天终于有了一点点心得,请大虾们多多批砖~~~ 嵌入式系统编程,要求程序员能够利用C语言访问固定的内存地址。既然是个地址,那么按照C语言的语法规则,这个表示地址的量应该是指针类型。所以,知道要访问的内存地址后,比如0x5F, 第一步是要把它强制转换为指针类型 (unsigned char *)0x5F,AVR的SREG是八位寄存器,所以0x5F强制转换为指向unsi gned char类型。 volatile(可变的)这个关键字说明这变量可能会被意想不到地改变,这样编译器就不会去假设这个变量的值了。这种“意想不到地改变”,不是由程序去改变,而是由硬件去改变——意想不到。 第二步,对指针变量解引用,就能操作指针所指向的地址的内容了 *(volatile unsigned char *)0x5F 第三步,小心地把#define宏中的参数用括号括起来,这是一个很好的习惯,所以#defi ne SREG (*(volatile unsigned char *)0x5F) 类似的,如果使用一个32位处理器,要对一个32位的内存地址进行访问,可以这样定义: #define RAM_ADDR (*(volatile unsigned long *)0x0000555F) 然后就可以用C语言对这个内存地址进行读写操作了 读:tmp = RAM_ADDR; 写:RAM_ADDR = 0x55; zhiwei 发表于 2005-4-30 18:59 AVR 单片机 定义未volatile是因为它的值可能会改变,大家都知道为什么改变了; 如果在一个循环操作中需要不停地判断一个内存数据,例如要等待SREG的I标志位置位,因为SREG也是映射在SRAM空间,为了加快速度,编译器可能会编译出这样的代码:把SREG 读取到Register中,然后不停地判断Register相应位。而不会再读取SREG,这样当然是不行了,因为程序或其它事件(中断等)会改变SREG,结果很可能是一个死循环出不来了。如果定义成volatile型变量,编译的代码是这样的:每次要操作一个变量的时候都从内存中读取一次。 #define SREG (*(volatile unsigned char *)0x5F) 之后,可以进行如下基本操作,unsigned char temp,*ptr; temp=SREG;把SREG值保存到temp中 SREG=temp;把temp的值赋给SREG ptr = & SREG; 不知对否,大家试一下。

#define用法集锦[修正版] Definition[定义]: The #define Directive You can use the #define directive to give a meaningful name to a constant in your program. The two forms of the syntax are: Syntax #define identifier token-stringopt #define identifier[( identifieropt, ... , identifieropt )] token-stringopt Usage[用法]: 1.简单的define定义 #define MAXTIME 1000 一个简单的MAXTIME 就定义好了,它代表1000,如果在程序里面写 if(i(y)?(x):(y); 这个定义就将返回两个数中较大的那个,看到了吗?因为这个“函数”没有类型检查,就好像一个函数模板似的,当然,它绝对没有模板那么安全就是了。可以作为一个简单的模板来使用而已。 但是这样做的话存在隐患,例子如下: #define Add(a,b) a+b; 在一般使用的时候是没有问题的,但是如果遇到如:c * Add(a,b) * d 的时候就会出现问题,代数式的本意是a+b 然后去和c,d 相乘,但是因为使用了define(它只是一个简单的替换),所以式子实际上变成了c*a + b*d 另外举一个例子: #define pin (int*); pin a,b; 本意是a 和b 都是int 型指针,但是实际上变成int* a,b; a 是int 型指针,而 b 是int 型变量。 这是应该使用typedef 来代替define,这样a 和b 就都是int 型指针了。

【IT168 技术】简介: Java? 语言包含两种内在的同步机制:同步块(或方法)和 volatile 变量。这两种机制的提出都是为了实现代码线程的安全性。其中 V olatile 变量的同步性较差(但有时它更简单并且开销更低),而且其使用也更容易出错。在这期的 Java 理论与实践 中,Brian Goetz 将介绍几种正确使用 volatile 变量的模式,并针对其适用性限制提出一些建议。 Java 语言中的 volatile 变量可以被看作是一种 “程度较轻的 synchronized”;与 synchronized 块相比,volatile 变量所需的编码较少,并且运行时开销也较少,但是它所能实现的功能也仅是 synchronized 的一部分。本文介绍了几种有效使用 volatile 变量的模式,并强调了几种不适合使用 volatile 变量的情形。 锁提供了两种主要特性:互斥(mutual exclusion) 和可见性(visibility)。互斥即一次只允许一个线程持有某个特定的锁,因此可使用该特性实现对共享数据的协调访问协议,这样,一次就只有一个线程能够使用该共享数据。可见性要更加复杂一些,它必须确保释放锁之前对共享数据做出的更改对于随后获得该锁的另一个线程是可见的 —— 如果没有同步机制提供的这种可见性保证,线程看到的共享变量可能是修改前的值或不一致的值,这将引发许多严重问题。 Volatile 变量 V olatile 变量具有 synchronized 的可见性特性,但是不具备原子特性。这就是说线程能够自动发现 volatile 变量的最新值。V olatile 变量可用于提供线程安全,但是只能应用于非常有限的一组用例:多个变量之间或者某个变量的当前值与修改后值之间没有约束。因此,单独使用 volatile 还不足以实现计数器、互斥锁或任何具有与多个变量相关的不变式(Invariants)的类(例如 “start <=end”)。 出于简易性或可伸缩性的考虑,您可能倾向于使用 volatile 变量而不是锁。当使用 volatile 变量而非锁时,某些习惯用法(idiom)更加易于编码和阅读。此外,volatile 变量不会像锁那样造成线程阻塞,因此也很少造成可伸缩性问题。在某些情况下,如果读操作远远大于写操作,volatile 变量还可以提供优于锁的性能优势。 正确使用 volatile 变量的条件 您只能在有限的一些情形下使用 volatile 变量替代锁。要使 volatile 变量提供理想的线程安全,必须同时满足下面两个条件: 对变量的写操作不依赖于当前值。 该变量没有包含在具有其他变量的不变式中。 实际上,这些条件表明,可以被写入 volatile 变量的这些有效值独立于任何程序的状态,包括变量的当前状态。 第一个条件的限制使 volatile 变量不能用作线程安全计数器。虽然增量操作(x++)看上去类似一个单独操作,实际上它是一个由读取-修改-写入操作序列组成的组合操作,必须以原子方式执行,而 volatile 不能提供必须的原子特性。实现正确的操作需要使 x 的值在操作期间保持不变, 而 volatile 变量无法实现这点。(然而,如果将值调整为只从单个线程写入,那么可以忽略第一个条件。) 大多数编程情形都会与这两个条件的其中之一冲突,使得 volatile 变量不能像 synchronized 那样普遍适用于实现线程安全。清单 1 显示了一个非线程安全的数值范围类。它包含了一个不变式 —— 下界总是小于或等于上界。

volatile变量定义的意义和该用在哪里 一个定义为volaTIle的变量是说这变量可能会被意想不到地改变,这样,编译器就不会去假设这个变量的值了。精确地说就是,优化器在用到这个变量时必须每次都小心地重新读取这个变量的值,而不是使用保存在寄存器里的备份。下面是volaTIle变量的几个例子: 1). 并行设备的硬件寄存器(如:状态寄存器) 2). 一个中断服务子程序中会访问到的非自动变量(Non-automaTICvariables) 3). 多线程应用中被几个任务共享的变量 回答不出这个问题的人是不会被雇佣的。我认为这是区分C程序员和嵌入式系统程序员的最基本的问题。嵌入式系统程序员经常同硬件、中断、RTOS等等打交道,所用这些都要求volaTIle变量。不懂得volatile内容将会带来灾难。 假设被面试者正确地回答了这是问题(嗯,怀疑这否会是这样),我将稍微深究一下,看一下这家伙是不是直正懂得volatile完全的重要性。 1). 一个参数既可以是const还可以是volatile吗?解释为什么。 2). 一个指针可以是volatile 吗?解释为什么。 3). 下面的函数有什么错误: 下面是答案: 1). 是的。一个例子是只读的状态寄存器。它是volatile因为它可能被意想不到地改变。它是const因为程序不应该试图去修改它。 2). 是的。尽管这并不很常见。一个例子是当一个中服务子程序修该一个指向一个buffer 的指针时。 3). 这段代码的有个恶作剧。这段代码的目的是用来返指针*ptr指向值的平方,但是,由于*ptr指向一个volatile型参数,编译器将产生类似下面的代码: int square(volatile int *ptr) {

生产制造的八大浪费与消除 八大浪费是定义工厂在JIT生产方式中的,其浪费的含义与社会上通常所说的浪费有所区别。对于JIT来讲,凡是超出增加产品价值所必需的绝对最少的物料、设备、人力、场地和时间的部分都是浪费。因此,JIT生产方式所讲的工厂的浪费归纳为八大种,分别是:不良、修理的浪费,过分加工的浪费,动作的浪费,搬运的浪费,库存的浪费,制造过多过早的浪费,等待的浪费和管理的浪费,简称为八大浪费。 1.不良、修理的浪费 所谓不良、修理的浪费,指的是由于工厂内出现不良品,需要进行处置的时间、人力、物力上的浪费,以及由此造成的相关损失。这类浪费具体包括:材料的损失、不良品变成废品; 设备、人员和工时的损失;额外的修复、鉴别、追加检查的损失;有时需要降价处理产品,或者由于耽误出货而导致工厂信誉的下降。 2.加工的浪费 加工的浪费也叫过分加工的浪费,主要包含两层含义:第一是多余的加工和过分精确的加工,例如实际加工精度过高造成资源浪费;第二是需要多余的作业时间和辅助设备,还要增加生产用电、气压、油等能源的浪费,另外还增加了管理的工时。 3.动作的浪费 动作的浪费现象在很多企业的生产线中都存在,常见的动作浪费主要有以下12种:两手空闲、单手空闲、作业动作突然停止、作业动作过大、左右手交换、步行过多、转身的角度太大,移动中变换“状态”、不明技巧、伸背动作、弯腰动作以及重复动作和不必要的动作等,这些动作的浪费造成了时间和体力上的不必要消耗。 4.搬运的浪费 从JIT的角度来看,搬运是一种不产生附加价值的动作,而不产生价值的工作都属于浪费。搬运的浪费具体表现为放置、堆积、移动、整列等动作浪费,由此而带来物品移动所需空间的浪费、时间的浪费和人力工具的占用等不良后果。 国内目前有不少企业管理者认为搬运是必要的,不是浪费。因此,很多人对搬运浪费视而不见,更谈不上去消灭它。也有一些企业利用传送带或机器搬运的方式来减少人工搬运,这种做法

与结构定义相仿,其形式为: struct 位域结构名 { 位域列表 }; 其中位域列表的形式为:类型说明符位域名:位域长度例如: struct bs {int a:8;int b:2;int c:6;}; 位域变量的说明

与结构变量说明的方式相同。可采用先定义后说明,同时定义说明或者直接说明这三种方式。例如: struct bs {int a:8;int b:2;int c:6;}data; 说明data为bs变量,共占2个字节。其中位域a占8位,位域b占2位,位域c占6位。 位域定义的几点说明 对于位域的定义尚有以下几点说明: 1. 宽度为 0 的一个未命名位域强制下一位域对齐到其下一type边界,其中type是该成员的类型。例如: struct bs { unsigned a:4; unsigned :0 ;/*空域*/ char b:4 ;/*从下一单元开始存放*/ unsigned c:4; }data; VC6(默认的配置,未作任何优化选择)对空域的处理。 实验中,0x0012ff74为变量data的起始地址,位域a填充0x0012ff74的后四位,位域b从0x0012ff78开始,占据0x0012ff78的后四位。所以空域占据了从a开始的4个位剩余部分。 乍看 VC6对空域的处理是依据空域的类型,即unsigned。其实不然。 经试验,空域所占大小和 a的类型及空域的类型二者皆相关。 即以下四种情况, a,空域皆为char时,二者共占据1字节; a 为unsigned,空域为unsigned; a 为char,空域为unsigned; a 为unsigned,空域为char;这三种情况,二者共占据4字节。 2. 位域的长度不能大于指定类型固有长度,比如说int的位域长度不能超过32,bool的位域长度不能超过8。 3. 位域可以无位域名,这时它只用来作填充或调整位置。无名的位域是不能使用的。例如: struct k {int a:1int :2 /*该2位不能使用*/int b:3int c:2}; 从以上分析可以看出,位域在本质上就是一种结构类型,不过其成员是按二进位分配的 位域的使用和结构成员的使用相同,其一般形式为:位域变量名·位域名位域允许用各种格式输出。

工厂中常见的八大浪费 浪费的定义 在JIT生产方式中,浪费的含义与社会上通常所说的浪费有所区别。对于JIT来讲,凡是超出增加产品价值所绝对必须的最少量的物料、设备、人力、场地和时间的部分都是浪费。因此,JIT生产方式所讲的浪费不仅仅是指不增加价值的活动,还包括所用资源超过“绝对最少”界限的活动。 各种各样的浪费现象在很多尚未实行5S活动的企业中普遍存在,如表1-1所示。为了杜绝工厂中的浪费现象,首先需要发现不合理的地方,然后才是想办法解决问题,这就需要推行5S、JIT等较为先进的管理方法。 表1-1 未实施5S活动的企业中的浪费 浪费表现危害 成员仪容不整有损企业形象,影响士气,易生危 险,不易识别 设备布置不合理半成品数目大,增加搬运,无效作业 设备保养不当易生故障,增加修理成本,影响品 质 物品随意摆放易混料,寻找费时间,易成呆料 通道不畅作业不畅,易生危险,增加搬运 常见的八大浪费 在工厂中最为常见的浪费主要有八大类,分别是:不良、修理的浪

费,过分加工的浪费,动作的浪费,搬运的浪费,库存的浪费,制造过多?过早的浪费,等待的浪费和管理的浪费。下面具体分析各类浪费现象。 1.不良、修理的浪费 所谓不良、修理的浪费,指的是由于工厂内出现不良品,需要进行处置的时间、人力、物力上的浪费,以及由此造成的相关损失。这类浪费具体包括:材料的损失、不良品变成废品;设备、人员和工时的损失;额外的修复、鉴别、追加检查的损失;有时需要降价处理产品,或者由于耽误出货而导致工厂信誉的下降。 2.加工的浪费 加工的浪费也叫过分加工的浪费,主要包含两层含义:第一是多余的加工和过分精确的加工,例如实际加工精度过高造成资源浪费;第二是需要多余的作业时间和辅助设备,还要增加生产用电、气压、油等能源的浪费,另外还增加了管理的工时。 3.动作的浪费 动作的浪费现象在很多企业的生产线中都存在,常见的动作浪费主要有以下12种:两手空闲、单手空闲、作业动作突然停止、作业动作过

volatile关键字是一种类型修饰符,用它声明的类型变量表示可以被某些编译器未知的因素更改。 用volatile关键字声明的变量i每一次被访问时,执行部件都会从i相应的内存单元中取出i 的值。 没有用volatile关键字声明的变量i在被访问的时候可能直接从cpu的寄存器中取值(因为之前i被访问过,也就是说之前就从内存中取出i的值保存到某个寄存器中),之所以直接从寄存器中取值,而不去内存中取值,是因为编译器优化代码的结果(访问cpu寄存器比访问ram快的多)。 以上两种情况的区别在于被编译成汇编代码之后,两者是不一样的。之所以这样做是因为变量i可能会经常变化,保证对特殊地址的稳定访问。 =====以下为转载====== volatile关键字是一种类型修饰符,用它声明的类型变量表示可以被某些编译器未知的因素更改 ,比如:操作系统、硬件或者其它线程等。遇到这个关键字声明的变量,编译器对访问该变量的 代码就不再进行优化,从而可以提供对特殊地址的稳定访问。 使用该关键字的例子如下: int volatile nVint; 当要求使用volatile 声明的变量的值的时候,系统总是重新从它所在的内存读取数据,即 使它前面的指令刚刚从该处读取过数据。而且读取的数据立刻被保存。 例如: volatile int i=10; int a = i; ... //其他代码,并未明确告诉编译器,对i进行过操作 int b = i; volatile 指出i是随时可能发生变化的,每次使用它的时候必须从i的地址中读取,因而编 译器生成的汇编代码会重新从i的地址读取数据放在b中。而优化做法是,由于编译器发现两次从 i读数据的代码之间的代码没有对i进行过操作,它会自动把上次读的数据放在b中。而不是重新 从i里面读。这样以来,如果i是一个寄存器变量或者表示一个端口数据就容易出错,所以说vola tile可以保证对特殊地址的稳定访问。 注意,在vc6中,一般调试模式没有进行代码优化,所以这个关键字的作用看不出来。下面 通过插入汇编代码,测试有无volatile关键字,对程序最终代码的影响: 首先,用classwizard建一个win32 console工程,插入一个voltest.cpp文件,输入下面的 代码: #i nclude

相关文档
最新文档