Re: Thread safe circular buffer.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you have an interrupt context write to the head and a different context reading the head then I would make the variable volatile. Doing so ensures that the reader actually loads the variable from memory when you intend for it to do so and not have to worry about register optimizations getting in the way.

Stuart

----- Original Message ----- From: "Tzahi Fadida" <Tzahi.ML2@xxxxxxxxx>
To: "Anupam Kapoor" <anupam.kapoor@xxxxxxxxx>
Cc: "Stuart Macdonald" <stuart@xxxxxxxxxxxxx>; "Stavros Passas" <stabat@xxxxxxxxxxxx>; <kernelnewbies@xxxxxxxxxxxx>
Sent: Thursday, March 08, 2007 2:33 AM
Subject: Re: Thread safe circular buffer.


On Thursday 08 March 2007 10:30, Anupam Kapoor wrote:
On 3/8/07, Tzahi Fadida <Tzahi.ML2@xxxxxxxxx> wrote:
> On Wednesday 07 March 2007 20:45, Stuart Macdonald wrote:
> > If you are on IA32 architecture then memory reads and writes are > > atomic
> > provided that they don't cross a cache line.
>
> And how do i make sure of that? declare the variable head volatile?

don't use volatile in the kernel. straight from horse's mouth :

I don't understand, LDD3 uses volatile in drivers. Now they say i can't.
What is the alternative?


http://thread.gmane.org/gmane.linux.kernel/423487/focus=424677

anupam

--
Regards,
Tzahi.
--
Tzahi Fadida
Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info
WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux