LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 10-01-2008, 01:04 PM   #1
linuxsavar
Member
 
Registered: May 2007
Distribution: slackware
Posts: 34

Rep: Reputation: 15
manipulating one file resource with multiple threads


hi all
I need to write in one file resource with multiple threads because each section of this file belong to one thread (assume it is multithread download manager)
now i don`t know is that possible writing simultaneously on this file without using mutex
 
Old 10-01-2008, 04:25 PM   #2
froguy
LQ Newbie
 
Registered: Sep 2003
Location: Ottawa, Canada
Distribution: Ubuntu
Posts: 17

Rep: Reputation: 0
In this scenario, without knowing anything else about the problem, I would set up one thread as the 'File Writer' thread and a shared buffer (or a threaded object... not sure what kind of programming environment you're in).

Assuming you're in a C environment and using a shared buffer, protect it with a semaphore. Every time you write to it, post to the semaphore. Have the file writer thread pending on the semaphore and then empty the buffer into the appropriate section of the file.

Hope this helps, Cheers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
awk manipulating the shadow file append LK bazzano Programming 1 10-02-2008 10:52 AM
Manipulating Text File with awk or sed kushalkoolwal Programming 2 09-10-2008 08:35 PM
Manipulating Fields Of Flat File Prasun1 General 10 09-29-2005 12:42 PM
Multiple threads vs Multiple processes deveraux83 Programming 1 05-11-2005 11:22 AM
Multiple Threads excel28 Programming 5 01-06-2004 09:46 PM


All times are GMT -5. The time now is 09:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration