What happens when the while(true) loop is used and no break is written inside the loop and there are some statements inside the loop? I understand that the loop will go into unending loop. But what I really want to understand is in terms of OS and SDK? Do any of them handle such a loop or system will just crash after certain time. And if they handle this, how exactly its implemented?
Depends what is in the loop. Anything that allocates memory or other resources will eventually run out of resources. What happens depends on the resource and how robust the code is (i.e. does it assume it allocated all the memory it asked for, or does it do a NULL check?)
If nothing inside the loop uses resources, there is no reason the loop will ever stop unless the user or OS kills the process.
// This will eventually crash.
while(true) {
p = malloc(100);
*p = 0;
}
// this will go on forever.
while(true) {
looping = true;
}