What happens when you create a new thread?

Everywhere they say that this is an expensive operation. Why? What is happening at the moment? And why does it take long?
June 14th 19 at 19:04
2 answers
June 14th 19 at 19:06
OS allocates memory for structure describing the thread that allocates the thread's stack adds the stream to the scheduler.
All this takes time and CPU and memory, so each thread is not free. A lot or a little time/memory is, of course, is relative. Regarding the tasks that will solve the flow.
And it is possible more in detail? What kind of structure? - paula.Ste commented on June 14th 19 at 19:09
well here's the ETHREAD structure, which creates Windows to describe specific thread
https://www.nirsoft.net/kernel_struct/vista/ETHREA...
this structure is added to the list of threads of your process, the scheduler then resolves switches threads by saving and loading the last state of the registers - turner.Beahan commented on June 14th 19 at 19:12
,
What kind of structure?

What's the difference? In one implementation of Linux, in Windows the other, both doing about the same thing, but in different ways. If interested, buy a book on the organization of the Linux kernel and see the source code.
As far as I know in Linux with threads as it is not very good - they are, but they are more expensive than in drugih OS - different implementation. Perhaps the information is outdated.
The application programmer usually is not the case, how to implement threads. They often use cross-platform libraries that do all the differences hidden in your implementation and you see a generalized implementation of a threads library, which is the same in different OS. - Lucio commented on June 14th 19 at 19:15
June 14th 19 at 19:08
Nonsense.
Now most of the processors support Hyper-Threading technology: X cores = 2X threads. Why not use the power, forcing them to stand - I don't see the rational.
Reading for understanding.
You not about that. This refers to the threads inside the process, you can create them even with 1000 how many pool enough. And creating flow within the process is really time-consuming business, so parallelization is when a lot of tasks and they are time-consuming, to win time will not work, if you parallelize 2-3 tasks on the multiplication table, because the time for resource allocation under the streams will take longer than the tasks themselves. - paula.Ste commented on June 14th 19 at 19:11
well it all depends on the tasks themselves, so the threads are created up to the moment, while creating another will not lead to performance degradation of the other. This would mean that the entire computing capacity of the system. - turner.Beahan commented on June 14th 19 at 19:14

Find more questions by tags Programming