mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* proper way to use memory barriers in userspace?
@ 2003-11-12 16:06 Chris Friesen
  0 siblings, 0 replies; only message in thread
From: Chris Friesen @ 2003-11-12 16:06 UTC (permalink / raw)
  To: linux-kernel


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-12 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-12 16:06 proper way to use memory barriers in userspace? Chris Friesen

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