L
L
Lastchance2017-02-02 02:12:03
Programming
Lastchance, 2017-02-02 02:12:03

Will a single core computer hang during while(1) {}?

1) Let's say there is such a program in c ++

int main()
{
while(1) {};
}

Imagine that we have a single-core computer and an operating system that supports multi-threading. Is it true that this program will lead to a complete freeze of the computer (Other threads will not be able to execute, because the kernel will not be able to interrupt the thread, since this program does not have a kernel system call, and therefore there is no one to interrupt the thread.)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stalker_RED, 2017-02-02
@Lastchance

Depends on the operating system and hardware.
If we are talking about windows, then starting from wine 9x, the operating system periodically receives control even if there are hung processes.

P
Peter, 2017-02-02
@petermzg

With preemptive multitasking, after a certain time, an interrupt will be generated from which the OS will switch this thread to another. There will be no hangup. (Windows, Linux, etc.)
With cooperative multitasking, until a thread reports that it has completed a task, there will be no switching to another one. Hang up.

M
maaGames, 2017-02-02
@maaGames

If the process is set to REALTIME, then "true". In the general case, no.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question