Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2145944imb; Sun, 3 Mar 2019 20:00:26 -0800 (PST) X-Google-Smtp-Source: APXvYqx5yt/ksZo9M1pOZ4WWN7im5tqxhuXNAHneXY4vommdQDNbdXDc6nSygHl+V1BSdT7Q0Jty X-Received: by 2002:a62:5652:: with SMTP id k79mr4028181pfb.59.1551672026385; Sun, 03 Mar 2019 20:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551672026; cv=none; d=google.com; s=arc-20160816; b=bJTs2GUE4Kc/mOu9sZzlmitOw6bGNmWyoYvRyPNm2h9NBJbDmvWD3ACDAPSAcNKN9h 3ckgjIIniH5DEVvg7K6wAG8JyjIV5bKk/Z9kgDXE29L30A4e9d4LnX2zYHorP6JWAvUg hU0YY773EGqPGIOKS7Uq74njs7Bo0L7WBINXINdGYILUrr4q6D82t/vRVGsHaIvchCYl 7rcScU6RkKuhrBFNAhqH/0zxsjp3AUkIGZTiYGr5OuII1a0SA9ANLd2ft0slP1gBBpCs hXVs6IialNApD+sQI3tBwVyYtuqpt0yqUS34NEH9HVacdZNlSxQF2AW4jYxbhihNR08f 0JXQ== 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=FUUdsjUlAnKAYrIdXwe1+k3b2lbOkylosuA3tDE2V19R0CcthcAE+ZiumL78M4w+KW DUF+IMpKLHC9zLToZ6hMk+a60jEtM3zLr1b57lZXRSV9qfy6+rG/nlXqHYUTYmABYgJL rKiuurNq1VjsP5NyF2k0pVgLOqGPINIr3S/N+y984cIFLsmYiQGMvPSEpfyiBvtJLBWA /xbRv/lidFwrwuDYgO3RJAapNwPBrQUHzmuUxjLHFdZBPMs2l/PfsBH4IS0AXMbgvR5o QVYjiyEb0XNdIn2LBzXqZEjWMYNrrUeXPrV6Ow6MGqjgbhhc6ovKKfxkmqox2h0Gpk8y jP4g== 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 w189si4308471pgd.486.2019.03.03.20.00.11; Sun, 03 Mar 2019 20:00:26 -0800 (PST) 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 S1726476AbfCDD7B (ORCPT + 99 others); Sun, 3 Mar 2019 22:59:01 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:44059 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbfCDD6W (ORCPT ); Sun, 3 Mar 2019 22:58:22 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R851e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07487;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0TLtryVh_1551671898; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TLtryVh_1551671898) by smtp.aliyun-inc.com(127.0.0.1); Mon, 04 Mar 2019 11:58:18 +0800 From: Alex Shi To: linux-kernel@zh-kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, harryxiyou@gmail.com, corbet@lwn.net Cc: Alex Shi , Bryan Wu , Li Zefan , Shawn Guo , Fengguang Wu , Coly Li Subject: [PATCH 14/20] docs/zh_CN: volatile doc format changes Date: Mon, 4 Mar 2019 11:57:37 +0800 Message-Id: <20190304035744.155203-15-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.856.g8858448bb In-Reply-To: <20190304035744.155203-1-alex.shi@linux.alibaba.com> References: <20190304035744.155203-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