1.. _cn_volatile_considered_harmful:
2
3.. include:: ../disclaimer-zh_CN.rst
4
5:Original: :ref:`Documentation/process/volatile-considered-harmful.rst
6           <volatile_considered_harmful>`
7
8������������������������������������������������������������������������������������������������������
9������������������������������������������������������������������������������������������������������
10���������������������������������������������::
11
12        ��������������������� Jonathan Corbet <corbet@lwn.net>
13        ��������������������� ������  Bryan Wu <bryan.wu@analog.com>
14        ��������������������� ������  Bryan Wu <bryan.wu@analog.com>
15        ��������������������� ���������  Eugene Teo <eugeneteo@kernel.sg>
16                       ������  Dave Young <hidave.darkstar@gmail.com>
17                       ��������� Alex Shi <alex.shi@linux.alibaba.com>
18
19���������������������������volatile���������
20==============================
21
22C���������������������volatile������������������������������������������������������������������������������������
23���������������������������������������������C���������������������volatile���������������������������������������
24���������volatile���������������������������������������������������������������������������������volatile���
25���������������������������������������������������������
26
27������volatile���������������������������������������������������������������������������������������������������
28���������������������������������������������������������������������������������������������������������������������
29���������������������������������������������������������������������������������������������������������������������
30���������
31
32���volatile���������������������������������������������������������������������������������������, ���������,���
33���������������������������������������������������������������������������������������������������������������������
34���������������volatile���������������������������volatile���������������������������������������������������
35���bug���������������������������������������volatile���������������������������������������
36
37���������������������������������������::
38
39    spin_lock(&the_lock);
40    do_something_on(&shared_data);
41    do_something_else_with(&shared_data);
42    spin_unlock(&the_lock);
43
44������������������������������������������������������the_lock������������������������������������shared_data���
45������������������������������������������������������������������������������������������������������������������������ ���
46��������������������������������� ������ ���������������������������������������������������������������������������������
47������������shared_data���������������������������������spin_lock()������������������������������������������
48���������������������������������������������������������������������������������������������
49
50������shared_data������������volatile���������������������������������������������������������������������������
51���������������������������������������������������������shared_data������������������������������������
52shared_data������volatile���������������������������������������������������������������������������
53volatile ������ ������������������������������
54
55volatile������������������������������������������������I/O���������������������������������������������������������
56���������������������������������������������������������������������������������������������������������I/O���������������
57���������������������������������������������������������I/O������������������������������������������������������������
58���������������������������������������������������������������������������������������������������volatile���������
59���������������
60
61���������������������������������volatile���������������������������������������������������������������������������
62������������������������::
63
64    while (my_variable != what_i_want)
65        cpu_relax();
66
67cpu_relax()���������������CPU���������������������������������������������������������������������������������������
68���������������������������volatile������������������������������������������������������������������������������
69
70���������������������������������������volatile������������������������
71
72  - ���������������������������������������������������I/0������������������������������������������������������������
73    volatile������������������������������������������������������������������������������������������������������
74    ���������������������������������������������
75
76  - ���������������������������������������������������������������������������������������������������GCC������������
77    ���������������������������������volatile������������������������������������������
78
79  - Jiffies���������������������������������������������������������������������������������������������jiffies
80    ������������������������������������������������������jiffies������������������volatile������������������
81    ���������jiffies������������������������volatile���Jiffies���������������������������������������"
82    ���Linus������������������������������������������������������������������
83
84  - ������������I/0������������������������������������������,������������,���������������������������������������
85    ������������������������������volatile������������������������������������������������������������������������
86    ���������������������������������������������������������������������������������
87
88���������������������������������������������volatile���������������������������������������volatile���������
89bug���������������������������������������������������������������������volatile������������������������������������
90������������������������������������
91
92������������������volatile��������������� ��� ���������������������������������������������������������
93
94������
95----
96
97[1] https://lwn.net/Articles/233481/
98[2] https://lwn.net/Articles/233482/
99
100������
101----
102
103���������Randy Dunlap������������������������
104���Jonathan Corbet������
105������Satyam Sharma���Johannes Stezenbach���Jesper Juhl���Heikki Orsila���
106H. Peter Anvin���Philipp Hahn���Stefan Richter���������������������������
107