Looking through vacancies for the position of a C / C ++ programmer, I noticed that knowledge of the syntax, OOP and algorithms is not enough. In most cases, the so-called "multi-threaded programming" is added to the above. I found out that there are many technologies.

  • On the one hand, there is Qt, in which this topic is probably somehow overplayed.
  • On the other hand, there is a very popular OpenMP
  • Boost / Thread still exists, and the word boost itself is found in vacancies as often as “multi-threaded programming”

I have already seen many questions in the style of "What to read? Which sites will you advise?". I would also like to know which technologies are the most relevant today. Also, the selection criterion is complexity. MFC is also implemented in multithreading, but for this you need to study WinApi, then MFC, then you can only proceed directly to multithreading. Besides, it's not a fact that front-end skills will be useful to me.

I summarize all of the above: I would like to choose the current technology, the basics that really comprehend in a week of active and persistent study. Thank you in advance!

  • pthreads (but this is in * nix). - avp

1 answer 1

Probably, it is necessary to understand what threads are in general, how they are created, how they can be interrupted, how they end. Further, the most difficult is the synchronization mechanisms: all sorts of mutexes, semaphores, barriers, condition variables. To begin, disassemble and implement the "producer-consumer" pattern (producent-consumer). Then much will become clear.

It is probably better to start with low-level implementations, with the system API level. Different boost.Thread, C ++ 11 Thread, Qt :: Thread - OOP wrappers, convenient and more secure, but quite transparently reflecting low-level implementation principles.

What to read ... Usually in the books on the OS API, all this is described. On general issues in Tannenbaum in the book on the OS is a pretty good section. There is a book on C ++ 11 Thread, including in Russian.

  • 6
    It is possible that the issues of employers are not entirely about "multi-threaded programming." Perhaps they are trying to ask about competitive programming, and things are somewhat different. Multithreading is a logical thing (like "flies" in one stream, "cutlets" in another). Competitiveness - the organization of parallel computing in a multiprocessor / multicore environment. Acquired a special relevance with the proliferation of multi-core processors. - alexlz
  • one
    @mikillskegg, I think for the beginning it would be necessary to have something even simpler than the producent-consumer. For example, in parallel to calculate the sum of the elements of the array. @artyomdevyatov, the main thing here is practice. Take any tasks and think how to parallelize them. Try to write (and be sure to measure ) - In general, I re-read the question and thought about it (I cannot assess it myself) about the reality of mastering the basics of the topic in a week . I mean the practical basics, i.e. so that as a result you can start writing workable programs. Apparently too many pitfalls in general I see in this thread. - avp
  • one
    It is simpler to rebuild thinking into parallel algorithms than, for example, quantum ones. You will start earlier, you will finish earlier - renegator
  • @avp articles on this topic, they are a little scary. They say that everything is fine while the processor is one. If there are several, everything is much worse. Those. Over the years, running multithreaded applications are starting to fail. - alexlz
  • @alexlz, that's just the point. The most difficult thing in multithreading (exactly in it) is debugging. It is clear that when multiprocessing errors of real simultaneous access come out. Actually (for myself) about 25 years ago I formulated the principle of an ideal parallel programming environment - “one process - one processor and no shared memory”. I hope that in the end it will happen, and with the development of today's FPGAs into something new, processors (of the right kind) will be dynamically created for tasks. - avp