Inter Process Synchronisation
Resit Sahin
resit.sahin at inforcept.com
Tue Jun 5 12:15:26 UTC 2012
Hello Everybody,
I am working on a multi process system. I have 10 or more processes
(that are created with fork) and i want to synchronise them. There is a
data structure which must be shared among the processes. The data
structure contains statistics about some users which are more then some
thousands. Each process needs to "read from" / "write to" this data
structure thousands of times in a second. They all may need to update it
500.000 times a second in total. This is the scenario i need to build.
I am using NUMA architecture and ia64 CPUs like E5506.
I have investigated the options i have in FreeBSD and come up with few
solutions. I am already using sockets for inter-process communication
but it does not seem to be suitable for the above scenario. It is very
slow.
The most suitable way seems to create a shared memory between the
processes. The question is how to synchronise the access to the memory:
I have found two solutions for synchronisation. One is mutexes and
other is semaphores.
The mutexes works only between threads but not between processes. Is
there any support for inter process mutexes in FreeBSD 8.2 ?
The second option is semaphores. There are two types of semaphores, they
are named semaphores and the memory based semaphores. Memory based
semaphores seem to be a better option but they do not support inter
process operation in FreeBSD 8.2 .
The only option seems to be using named semaphores and locking the whole
data structure for each access. Would it be feasible to use named
semaphores for locking 500.000 times a second?
I have read about atomic operations here:
http://www.freebsd.org/cgi/man.cgi?query=atomic_add&apropos=0&sektion=0&manpath=FreeBSD+9.0-RELEASE&arch=default&format=html
Would atomic operations be an option in my case?
The manual page says :
"On the i386 architecture, the cache coherency
model requires that the hardware perform this task, thus the atomic oper-
ations are atomic across multiple processors. On the ia64 architecture,
coherency is only guaranteed for pages that are configured to using a
caching policy of either uncached or write back."
Is it safe to use named semaphores for*ia64* architecture ? Does FreeBSD
8.2 support interprocess locking for ia64 architecture?
Kind Regards
Res,i S,ahin
More information about the freebsd-threads
mailing list