Support for shared memory

83 views
Skip to first unread message

Brian Nichols

unread,
Aug 17, 2015, 6:05:13 PM8/17/15
to Concurrency Kit
Does concurrency kit support atomic operations from multiple processes on variables located in shared memory? 
Are there any restrictions that I need to be aware of?

I'm mainly interested in shared memory support for the following functions on Linux/Intel64:

ck_pr_load_*
ck_pr_store_*
ck_pr_cas_*
ck_spinlock_lock
ck_spinlock_unlock

-Brian

Devon H. O'Dell

unread,
Aug 20, 2015, 1:57:27 PM8/20/15
to Concurrency Kit
We've used at least load / store / cas effectively, which leads me to believe that things built on top of this (e.g. ck_spinlock) will work as well.

If you are using primitives directly, you should be careful to understand your system's memory model. Since you haven't posted the architecture you're using, it's unclear whether to advise you on any particular use of memory barriers. Not sure of your familiarity with that problem space; if you're unfamiliar, I recommend reading https://queue.acm.org/detail.cfm?id=2492433 and http://www.akkadia.org/drepper/cpumemory.pdf.

You may run into further issues if your shared memory area is file-backed and does not reside in a memory filesystem like tmpfs.

--dho

Samy Al Bahra

unread,
Aug 24, 2015, 7:22:52 PM8/24/15
to concurr...@googlegroups.com
Hey Brian,

Sorry about the delayed response, been hectic this month.

CK does support atomic operations on shared memory, and so does ck_spinlock_t, no issue there. So do most other synchronization primitives (but not all) and ck_ring_t (and upcoming disruptor).

The restriction (assuming normal backing for the memory and no other weirdness) is that data structures that involve pointers require that addresses match, if that's done then things should just work.

A rule of thumb you can go with here is that if init is taking a pointer to a buffer of some kind or there is a ck_malloc callback, then CK is probably using pointers: addresses must match and your shared memory mechanism must consider this.

Pointer-less ck_epoch is sitting in my queue, and I plan on pushing that to master for some internal projects slated for September.

If you've some cool real-world use-cases for pointerless implementations of other data structures, I'm all ears (ck_ht/ck_*hs/ck_hm comes to mind, as well as ck_epoch which is covered).

Regards.

--
You received this message because you are subscribed to the Google Groups "Concurrency Kit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to concurrencyki...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brian Nichols

unread,
Aug 24, 2015, 10:12:17 PM8/24/15
to Concurrency Kit
Our shared memory data consists of fixed size data structures with offsets.  Having a process-safe variable sized shared memory list/map would be nice, but it's not a requirement for us.

-Brian
Reply all
Reply to author
Forward
0 new messages