вот случай:
I am talking about general linux concurrent programming environment
Definition:
Node: a machine with a processor.
file system: can be accessed both locally and remotely.
it includes large set of files varied in random size.
Node I: Process A with multithreads access A's file system, operations include
read and write. Process B, similar to A. Think about more similar processes
C,D,etc.
Then, thinking about scaling. The same FS system is located on a separate node.
Operated by processes E,F,G etc on node II, and processes A,B,C,D on Node I.
thinking about similar node III,IV,V, etc.
Это практический вопрос и вопрос для интервью. Вот мое решение:
I can use mutex and signal resolve multi reader and writer of the same
file within a process. And also using IPC resolve multiprocesses
communication and synchronization.
the code could work very well for single node multiprocesses.
But, when dealing with multi node. We need similar but more
complicated mechanism to detect are there any node
writting on the FS, if yes, wait; otherwise, access
writting mutex and write, then notify waiting guys.
После долгих раздумий моя идея:
From the point of a NFS, we define file lock of course based on file.
My target is:
at each moment,there is only one writer write the file,
there can be more than one reader read the file.
Then, all the processes on different nodes are the same.
they should have their own mechanism to acquire either read or write lock,
of course, dealing with connection, failures and retries.
Мне интересно, есть ли какой-нибудь прототип для такой проблемы?