In my copy of C Programming Language (aka: K&R), there seems no mention of multithreading. Is the book less complete than I imagined? Did multithreading emerge after it was written? Am I thinking about this the wrong way?
Where does the concept of multithreading fit into the C world?
Edit: I think my original question have been:
What accounts for this contradiction? Where's the origin of multithreading? If POSIX, then what is POSIX written in if not C? A form of assembly that is inaccessible to C?
C is a pretty low level language. Support for threads in a typical C program comes from the OS, not from the C runtime - if your environment doesn't support threads, then you'll have to implement them yourself, find a library that does it, or do without threads. This is in contrast to a language like Java, where the runtime environment provides many services that are guaranteed to be available to Java programs whether or not the underlying OS supports them in the manner that the Java platform exposes.
Now, having said that, I'm pretty sure that when the first edition of K&R was published, Unix did not support threads. Since C was first implemented as a systems language for the Unix environment, it's not surprising that it has no native thread support.
If you're writing code for a Unix like environment, look for POSIX threads if you need a well supported API for implementing multithreaded programs in C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With