concurrent reader and writer on a pmem memory block

34 views
Skip to first unread message

Himanshu Chatterjee

unread,
Dec 14, 2016, 5:34:15 PM12/14/16
to pm...@googlegroups.com
Hi,

Is it possible that multiple readers in multiple processes, can do pmemobj_open() on the same file simultaneously ? I tried that with reader.c example but found only first process gets success and all other processes gets "resource unavailable" error. Also is it caller responsibility to serialize read and write on a piece of PMEM memory or libpmemobj has those serialization built in. And is it even possible to simultaneously open such file for writing and reading and caller or libpmemobj serializes, writer and reader based on the the memory region granularity.

Thanks
Himanshu



Marcin Ślusarz

unread,
Dec 14, 2016, 6:09:27 PM12/14/16
to Himanshu Chatterjee, pmem
2016-12-14 23:34 GMT+01:00 Himanshu Chatterjee <himanshu....@gmail.com>:
> Hi,
Hi

> Is it possible that multiple readers in multiple processes, can do
> pmemobj_open() on the same file simultaneously ?
No, currently it's not possible.

> I tried that with reader.c
> example but found only first process gets success and all other processes
> gets "resource unavailable" error.
This is because we are locking the file on open, so 2nd open gets EWOULDBLOCK
error from flock(2).

> Also is it caller responsibility to
> serialize read and write on a piece of PMEM memory or libpmemobj has those
> serialization built
It's a responsibilty of an application. Pmemobj exposes pmem locks to let you
protect your data structures from simultaneous access (from multiple threads).

> And is it even possible to simultaneously open such
> file for writing and reading and caller or libpmemobj serializes, writer and
> reader based on the the memory region granularity.
I don't understand the question. Could you rephrase?

Marcin
Reply all
Reply to author
Forward
0 new messages