Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ threadpool with shared read only memory

I am a newbie in concurrent programming in C++ I want to code a server( on a linux box ) based on the thread pool pattern where threads need to read ( and only read ) from a shared memory to answer incoming requests

I am very confused :( I wonder if something needs to be done to synchronize threads when they access the read only memory and how to do it ( using memory map file maybe ? )

like image 902
lambda-coder Avatar asked Nov 04 '22 13:11

lambda-coder


1 Answers

If the data is read-only then you don't need to synchronize the reading threads, you only do that if something is writing. Also, threads share their parent's memory space so you don't need to make a shared memory segment or anything like that.

http://en.wikipedia.org/wiki/Thread_safety

like image 124
iabdalkader Avatar answered Nov 12 '22 22:11

iabdalkader