C multi-threaded origin

In my copy of C, the programming language (aka: K & R) does not seem to mention multithreading. Is the book less complete than I imagined? Did multithreading appear after it was written? Am I thinking about it wrong?

Where does the concept of multithreading fit into world C?


Edit: I think my initial question is:

  • you can write something in C
  • multithreading exists
  • you cannot write multithreading in C <- logical contradiction

What explains this contradiction? Where is the origin of multithreading? If POSIX, then what is POSIX written, if not C? Assembly form not available for C?

+5
source share
6 answers

C is pretty low. Thread support in a typical C program comes from the OS, and not from the C runtime — if your environment does not support threads, then you have to implement them yourself, find a library that does this, or do without threads. This is in contrast to a language such as Java, where the runtime provides many services that are guaranteed to be available for Java programs, regardless of whether their underlying OS supports them as the Java platform demonstrates.

Now, having said that, I am sure that when the first edition of K & R was published, Unix did not support streams. Since C was first implemented as a system language for the Unix environment, it is not surprising that it does not have native thread support.

Unix- , POSIX, API C.

+14

. C , , . C . , , , . , , C , .

C. ( : http://www.cs.clemson.edu/~mark/multithreading.html)

. , :

#include "Windows.h"

int main()
{
   CreateThread(/*Google the function for details of the parameters.*/);   
   return 0;
}

sdk Windows. - sdk, . CreateThread, , , , .

, , , , - posix.

+4

, , C. POSIX Threads Unix/Linux .

+3

C ++ . , (PThreads, WinAPI CreateThread (..), MFC ..).

++ 0x , .

+2

( ) . , , C . , , . POSIX , ( , , , , RCU, ).

+1
source

This is mentioned in my copy (2nd edition) in the chapter Introduction (p. 2):

Similarly, C offers a simple, single-threaded control flow: tests, loops, groupings, and subprograms, but not multiprogramming, concurrent operations, synchronization, or coroutines.

+1
source

All Articles