LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 12-05-2005, 12:11 PM   #1
smurff
Member
 
Registered: Sep 2004
Location: England
Distribution: Mandriva 2005LE / Whitebox
Posts: 48

Rep: Reputation: 15
pthreads and coffee


Ok, my story is as follows:

I have created a server app for work that reads records within a database does some boring stuff and write files. After a lot of coffee and more sleepless nights than when I had my 2 children, it was in a "good" beta phase. Tested it with a few million records and it works fine. Ok a mem leak here and there BUT it did take a few days to run

So I have looked at the code and it looks like its time for pthreads. I got a book of amazon which has helped me learn the basics but what I am asking you guys is as follows:

1: Whats the best way of implementing a safe "write to log" function? From what I can see, as long as I mutex the function to write I should be ok. But doesnt that create bottleknecks?

2: Although I am on Linux, I am actually coding this on my XP laptop and then recompiling. Has anyone used the pthreads for win or did you guys have some clever code that does stuff lilke IFDEF WIN32 Createthread... ELSE pthread...

Thanks guys
Smurff
 
Old 12-05-2005, 12:23 PM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
1,yep mutex or a semaphore with a count of one. As for a bottle neck theres nothing you can do about that.
hmm thinking about this you only need it to write to a file. Im not 100% certain but think a file has a mutex.

2,Ive used the pthread win32 libray and its the best way of doing it as far as i was concerned.
http://sourceware.org/pthreads-win32/
 
Old 12-05-2005, 12:26 PM   #3
smurff
Member
 
Registered: Sep 2004
Location: England
Distribution: Mandriva 2005LE / Whitebox
Posts: 48

Original Poster
Rep: Reputation: 15
Cheers dmail, Did you find any issues with using the win32 version? Thanks again for replying
 
Old 12-05-2005, 12:28 PM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
the only issue(which is in the librarys readme) is which version to use depending on wether you want to catch errors(c++)
 
Old 12-05-2005, 12:35 PM   #5
smurff
Member
 
Registered: Sep 2004
Location: England
Distribution: Mandriva 2005LE / Whitebox
Posts: 48

Original Poster
Rep: Reputation: 15
Good man thanks dmail
 
  


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
Java - Not my cup coffee apparently Russb Linux - Software 3 07-16-2004 09:34 PM
Coffee Cup mikedelo Linux - Newbie 5 03-31-2004 04:08 PM
coffee cup html dukeinlondon Linux - Software 5 02-23-2004 06:06 PM
Got my LQ coffee cup BajaNick General 2 02-23-2004 12:41 AM
Making coffee with your Linux box isolationist Linux - General 10 07-29-2003 04:22 PM


All times are GMT -5. The time now is 07:30 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