c - filesystem shared by multiprecoesses with multithreads -



c - filesystem shared by multiprecoesses with multithreads -

here case:

i talking general linux concurrent programming environment definition: node: machine processor. file system: can accessed both locally , remotely. includes big set of files varied in random size. node i: process multithreads access a's file system, operations include read , write. process b, similar a. think more similar processes c,d,etc. then, thinking scaling. same fs scheme located on separate node. operated processes e,f,g etc on node ii, , processes a,b,c,d on node i. thinking similar node iii,iv,v, etc.

this both practical , interview question. here solution:

i can utilize mutex , signal resolve multi reader , author of same file within process. , using ipc resolve multiprocesses communication , synchronization. code work single node multiprocesses. but, when dealing multi node. need similar more complicated mechanism observe there node writting on fs, if yes, wait; otherwise, access writting mutex , write, notify waiting guys.

after more thinking, follows idea:

from point of nfs, define file lock of course of study based on file. target is: @ each moment,there 1 author write file, there can more 1 reader read file. then, processes on different nodes same. should have own mechanism acquire either read or write lock, of course, dealing connection, failures , retries.

i wondering if there prototype such kind of problem?

i assume "node" means "network node", i.e. entity running own re-create of operating system. actual machine or virtual machine.

the question pretty badly worded, honestly. it's not clear beingness asked; assume they're not asking inter-node synchronization or locking.

so you're on first part: mutexes between threads, ipc semaphores between processes on same machine.

if want handle interactions between separate nodes, first need have networked filesystem, such nfs or cifs. second, need file locks (or lock files) manage access shared files. file locks can used @ other levels, inter-thread , inter-process, though they're not straightforward mutexes , semaphores.

you build synchronization scheme sockets, requires each node have socket each other node, means n^2 sockets possible race conditions, or central clearinghouse node, becomes single point of failure.

c linux multithreading filesystems multiprocessing

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -