I've been a Java (and PHP) developer for most of my life, but will need to use C for my next project. I remember some basic stuff we did back in school with fork, pthread, semaphores, etc. but I'm not sure if that's still the "way to go" here, or if there have been any recent developments/improvements etc.

Google's results seem to be fairly dated. Or does that just mean that this is still the current "state of the art"?

Or will I have to use a (system-independent) libary like glib if I want higher-level abstractions, like synchronized queues? What other libraries are there? (The programm will only have to run on Linux though)

  • 2
    For the avoidance of doubt: you have to use C, and C++ is out of the question, correct? – NPE Dec 13 '11 at 15:16
  • 1
    Yes C not C++. (I don't want to drift into a language discussion, since that's the way to get your question closed due to 'subjectivity' before getting a proper answer.) – Dexter Dec 13 '11 at 18:50

Well, basically it's still the same. You still got pthreads (on Linux), forking is still used in some cases. Mutexes and semaphores are also there. Of course, there is CAS available but it's not like something really new.

What we have now is a few libraries for doing some multithreaded stuff a little differently. You can use libevent2 or libev for building event systems (though they are most useful in networking, for async reading and writing from sockets). And there is ZeroMQ which you may use to avoid direct communication of threads, it's actually pretty useful, just use their ipc transport.

As for data structures there are a few libs like glib or a lib from ZMQ guys.

Be warned though, C is still C and you must be as careful with it as ever.

  • It's funny how related some issues are. I was planning on using IRC for communication in order coordinate different machines. Thank you! – Dexter Dec 13 '11 at 15:53
  • @Dexter are you writing a bot net or something? (laughs nervously) – Kiril Dec 13 '11 at 16:48
  • No, but I must admit that I got the IRC idea after a hoster shut down a private server of mine saying that 'IRC services are forbidden on their systems' because people try to hack into them and use them for their botnets. – Dexter Dec 13 '11 at 18:54
  • 2
    There's also the newer libdispatch, which is worth checking out. – Sedate Alien Dec 13 '11 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.