Answer the question
In order to leave comments, you need to log in
What are threads at the OS level? Is there only 1 thread in a 1-core processor?
Threads are OS emulation. As far as I understand the processor does not know about them.
A couple of questions about threads.
How do they use Cash? They interfere with each other.
Are there implementations of Thread Emulation or Async on github? Maybe it's Unix code? But I don't know how to search there and where.
Why is it possible to get a gain in computational speed with the help of thread deparallization? It's each thread that will constantly load its snapshots into the registers, save, load. There will be more cache misses.
How many instructions are executed at a time 1, 10, 100? Before interruption? What does it depend on.
And For example, such commands are executed as an example of an instruction to read a line from stdin, why the whole OS does not stall. Like what happens at this moment of waiting, Or that the OS switches all 1000 threads there every 0.0001 seconds?
And this issue is solved with the help of asynchrony and callback. Then why isn't the entire OS asynchronous on a single thread like Node JS?
Answer the question
In order to leave comments, you need to log in
Threads are switched in quantums of about 28 milliseconds or so.
Yes, if you run a lot of threads, the cache will be flushed. And you thought you were in a fairy tale? Good HPC programs don't run more threads than cores.
Why is it possible to get a gain in computational speed with the help of thread deparallization?
Then why isn't the entire OS asynchronous on a single thread like Node JS?
In a multitasking system, each process has a bunch of stuff - its own memory area, its own parent, permissions, open file descriptors, and so on. Switching from process to process is quite a heavy task.
A thread or thread is, roughly speaking, the ability to run several "lightweight" processes in parallel that use the same set of descriptors, the same process ID and can use the same memory area.
Therefore, it will be faster and cheaper to calculate something in threads than in two processes.
How many instructions are executed at a time 1, 10, 100? Before interruption? What does it depend on.
And For example, such commands are executed as an example of an instruction to read a line from stdin, why the whole OS does not stall. Like what happens at this moment of waiting, Or that the OS switches all 1000 threads there every 0.0001 seconds?
In a multi-core processor and in a system with two or four stones, the instruction thread will be one or you will lose control.
Are there implementations of Thread Emulation or Async on github? Maybe it's Unix code? But I don't know how to search there and where.
article
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question