Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question

migrated from Dec 13 '11 at 21:33

This question came from our site for professional and enthusiast programmers.

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
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
up vote 5 down vote accepted

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.

share|improve this answer
+1 for ZeroMQ . – Fred Foo Dec 13 '11 at 15:29
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) – Lirik 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
There's also the newer libdispatch, which is worth checking out. – Sedate Alien Dec 13 '11 at 22:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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