c - File locking between threads and processes -



c - File locking between threads and processes -

i have programme spawns multiple processes or threads, each of writes line on file, don't want line mixed up, need exclusive access file.

more specifically, in first case, have process f spawns several kid processes (c1, c2, c3, c4, ...), , want block access f, c2, c3, c4, ... when c1 writing.

in sec case, have same process f spawns several threads (t1, t2, t3, t4, ...) and, again, want block access f, t2, t3, t4, ... when t1 writing.

i'm guessing function flock() takes care of first part, threads case? , windows platform?

you can utilize locking mechanism want. between threads, mutex simplest. access file protected mutex, no 2 threads seek write file @ same time.

for processes, can utilize process-shared mutex. on windows, can utilize named mutex.

c windows multithreading unix locking

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -