Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1654004imc; Mon, 11 Mar 2019 20:05:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRdQljrPBpqOk55C4ZW8If/rn8kE5y92w7fIFw0FKLBVpeBwry3bYKHKpgQ1kHBq772Dwx X-Received: by 2002:a63:4c18:: with SMTP id z24mr33357040pga.62.1552359921234; Mon, 11 Mar 2019 20:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552359921; cv=none; d=google.com; s=arc-20160816; b=EKPMTgsVNrxb+3hnlszOFNbSnvHuEWYtMUt5XSSVqSh30Tytg9SIe1BwqZB7Q/k7DC pWB7jB9xouPdAi/mHKH6JpEgBwjoGxt6F7PSlcfVrz0WR48NfAfM/3L41Y45DfXrfwSq vFeIhqR94Vy9Dupu029ZMTr9WiDz0Nzb1nD2W0UQ5qVRfkXz4uVWF1S5FEICyIAJPv13 6YnM0a3xY8qTkggc2gIDR1NIeAcNXWWEcOSHJBVLuPZucKvBMzEGuM5MVjf2TwdA98vu t8mIo+MAku53vtcVZ5VxpFYH1ZxIvks/b6uMl/p3u1Aod7P0gSaihqdIKHJK6g6g0eJW AVeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xTZnyyi/lfJbE+sjeyKKS08JjzGToqc/hu6zXOTwzfI=; b=oyNXRb6u7OQAfY4yE78voxSLAYhduqUAVVj9+Mfxjx9G855vv72/HKRHlETaL3A+5K R0UP6E8SVMZjWucqve8haUn4QWzURX2m0wkNhwabICk4CpRrlNipRucfRPXDe0Gi9Alu S2gwyOVrRhY6PbevXqhAJXEtl/eafCljtPGBWlzs+mDWAcLx5aoOf264QVL0GbEMBqCp OmnWmgQ8rXBV4P4viF7VrvdaRJh6ToPk76MWxRrtiHCRSkx0QXzcmdrYniLFm7L4Nxes aQx2JxIW3I0SoJB0U+hC6w+CaRTc3kuXqdsV/yONJA7tygqEhV5OmDMBAvJnVccL3AzR MWIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si6999457pls.287.2019.03.11.20.05.05; Mon, 11 Mar 2019 20:05:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbfCLDEE (ORCPT + 99 others); Mon, 11 Mar 2019 23:04:04 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:60503 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbfCLDCI (ORCPT ); Mon, 11 Mar 2019 23:02:08 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R551e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04452;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0TMW6jBd_1552359724; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TMW6jBd_1552359724) by smtp.aliyun-inc.com(127.0.0.1); Tue, 12 Mar 2019 11:02:05 +0800 From: Alex Shi To: corbet@lwn.net, harryxiyou@gmail.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Alex Shi , Bryan Wu , Li Zefan , Shawn Guo , Fengguang Wu , Coly Li Subject: [PATCH v4 14/31] docs/zh_CN: volatile doc format changes Date: Tue, 12 Mar 2019 11:01:12 +0800 Message-Id: <20190312030129.47511-15-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.856.g8858448bb In-Reply-To: <20190312030129.47511-1-alex.shi@linux.alibaba.com> References: <20190312030129.47511-1-alex.shi@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org make it readble as rst format for html etc doc making. Signed-off-by: Alex Shi Cc: Harry Wei Cc: Jonathan Corbet Cc: Bryan Wu Cc: Li Zefan Cc: Shawn Guo Cc: Fengguang Wu Cc: Coly Li --- .../process/volatile-considered-harmful.rst | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/Documentation/translations/zh_CN/process/volatile-considered-harmful.rst b/Documentation/translations/zh_CN/process/volatile-considered-harmful.rst index 475125967197..48b32ce58ef1 100644 --- a/Documentation/translations/zh_CN/process/volatile-considered-harmful.rst +++ b/Documentation/translations/zh_CN/process/volatile-considered-harmful.rst @@ -1,30 +1,23 @@ -Chinese translated version of Documentation/process/volatile-considered-harmful.rst +.. _cn_volatile_considered_harmful: -If you have any comment or update to the content, please contact the -original document maintainer directly. However, if you have a problem -communicating in English you can also ask the Chinese maintainer for -help. Contact the Chinese maintainer if this translation is outdated -or if there is a problem with the translation. +.. include:: ../disclaimer-zh_CN.rst -Maintainer: Jonathan Corbet -Chinese maintainer: Bryan Wu ---------------------------------------------------------------------- -Documentation/process/volatile-considered-harmful.rst 的中文翻译 +:Original: :ref:`Documentation/process/volatile-considered-harmful.rst + ` 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻 -译存在问题,请联系中文版维护者。 +译存在问题,请联系中文版维护者:: -英文版维护者: Jonathan Corbet -中文版维护者: 伍鹏 Bryan Wu -中文版翻译者: 伍鹏 Bryan Wu -中文版校译者: 张汉辉 Eugene Teo - 杨瑞 Dave Young -以下为正文 ---------------------------------------------------------------------- + 英文版维护者: Jonathan Corbet + 中文版维护者: 伍鹏 Bryan Wu + 中文版翻译者: 伍鹏 Bryan Wu + 中文版校译者: 张汉辉 Eugene Teo + 杨瑞 Dave Young + 时奎亮 Alex Shi 为什么不应该使用“volatile”类型 ------------------------------- +============================== C程序员通常认为volatile表示某个变量可以在当前执行的线程之外被改变;因此,在内核 中用到共享数据结构时,常常会有C程序员喜欢使用volatile这类变量。换句话说,他们经 @@ -41,7 +34,7 @@ C程序员通常认为volatile表示某个变量可以在当前执行的线程 必要再使用volatile。如果仍然必须使用volatile,那么几乎可以肯定在代码的某处有一 个bug。在正确设计的内核代码中,volatile能带来的仅仅是使事情变慢。 -思考一下这段典型的内核代码: +思考一下这段典型的内核代码:: spin_lock(&the_lock); do_something_on(&shared_data); @@ -66,7 +59,7 @@ volatile的存储类型最初是为那些内存映射的I/O寄存器而定义。 是必需的。 另一种引起用户可能使用volatile的情况是当处理器正忙着等待一个变量的值。正确执行一 -个忙等待的方法是: +个忙等待的方法是:: while (my_variable != what_i_want) cpu_relax(); -- 2.19.1.856.g8858448bb