From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26075 invoked by alias); 5 Mar 2013 09:40:19 -0000 Received: (qmail 26066 invoked by uid 22791); 5 Mar 2013 09:40:18 -0000 X-SWARE-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f169.google.com (HELO mail-lb0-f169.google.com) (209.85.217.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Mar 2013 09:40:10 +0000 Received: by mail-lb0-f169.google.com with SMTP id m4so4685915lbo.14 for ; Tue, 05 Mar 2013 01:40:09 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.46.6 with SMTP id r6mr5672591lbm.58.1362476409246; Tue, 05 Mar 2013 01:40:09 -0800 (PST) Received: by 10.112.31.169 with HTTP; Tue, 5 Mar 2013 01:40:08 -0800 (PST) In-Reply-To: References: Date: Tue, 05 Mar 2013 09:40:00 -0000 Message-ID: Subject: Re: Question on volatile functions and GCC From: Jonathan Wakely To: David Paterson Cc: noloader@gmail.com, gcc-help@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2013-03/txt/msg00030.txt.bz2 On 5 March 2013 09:27, David Paterson wrote: > > In addition to Jonathan's answer on the use of "volatile", it's worth adding > that it's not only used for memory mapped hardware. There are many other > uses, such as inter-thread communication, or indeed the example you > show below. Only in broken code. volatile is not for multithreading, you need proper synchronization for interthread communication.