Monster Hunter
Monster Hunter

Reputation: 866

Thread affinity vs Process affinity

I have a latency sensitive application that consists of 2 logical parts which can run in parallel. My original design is to make each logical part a standalone program and run them on separate cores passing information by file mapped shared memory. But after knowing that even 2 threads from the same process can run in separate cores, I'm think of merging the 2 programs into one process, each running on a thread tied to standalone core. And since all threads in a process share the memory space, I can eliminate the shared memory and use program memory space directly, which will be faster.

Is my reasoning correct? If correct, what's the advantage of separating an application into processes instead of using thread affinity in one process?

Upvotes: 1

Views: 550

Answers (1)

hhy
hhy

Reputation: 174

1) Yes, your reasoning is correct. In Linux you can bind different threads with different cores, so you can get rid of file mapped shared memory.

2) File mapped shared memory (I would use the term inter-process shared memory) mostly serves as a way of communication/messaging between different processes, e.g. between a monitor process that needs to run in the background all the time, and a user interface process that can be opened/closed at any time. In your case, you only need thread affinity.

Upvotes: 2

Related Questions