mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Friesen <cfriesen@nortelnetworks.com>
To: linux-kernel@vger.kernel.org
Subject: proper way to use memory barriers in userspace?
Date: Wed, 12 Nov 2003 11:06:14 -0500	[thread overview]
Message-ID: <3FB25A76.1020701@nortelnetworks.com> (raw)


I've got a number of processes on an SMP box that communicate via shared 
memory.  I want to avoid locking, so I am considering using flags and 
memory barriers.

However, I've run into a snag--the barriers are buried within __KERNEL 
ifdefs.  Is the proper way to handle this just to copy/paste into userspace?

Also, I wanted to double-check that my barrier usage was correct.  The 
data consists of a flag indicating whether a scan was done, and the 
results of the scan.  The main  may check the flag at any time, so I 
want to make sure that there is no way that it can see the flag as set 
but have inconsistant data in the results field.  My plan was to do the 
following:


main process:
clear flag
mb
kick other process
wait (may be kicked by others here too)
for all other processes:
	if flag set
		check data


other process:
wait to be kicked
do scan
update results
wmb
set flag
mb
kick main


Is this the proper way to do it?

Thanks,

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


                 reply	other threads:[~2003-11-12 16:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FB25A76.1020701@nortelnetworks.com \
    --to=cfriesen@nortelnetworks.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome