• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Endless Loop on Hyperthreaded/Multi-core CPU? (1 Viewer)

drewgcn

postpantsism
Joined
Jun 23, 2004
Messages
337
Location
Oatley...land of oats.
Gender
Male
HSC
2006
An interesting question my friend posed the other day.

If you create an endless loop on a hyperthreaded or multi-cored CPU (basically anything with more than one virtual core or processing stream [nb: the latter term may have just been made up]), will the computer still crash?

My initial thought was yes, based on the fact that windows should lock up regardless, but then I don't have a full knowledge of how a multi-threaded/cored CPU should work.

Anyone know?
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,350
Gender
Male
HSC
2002
That would depend on whats done inside the loop....

The OS doesn't crash because its a loop doesn't end, it crashes because something is done repeatedly inside the loop that causes the OS to crash.

If its something like chewing up small amounts of memory, then evetually you will have no memory left and the OS might crash regardless of how many cores you have.
 

tama00

New Member
Joined
Mar 26, 2006
Messages
12
Gender
Male
HSC
2006
#include <stdio.h>
int main() {
while(0) { printf("endlessloop\n");}
}

now if u will compile and run that, amazingly your OS wont crash!
WHY?
Because your operating system is capable of mulit-tasking!! processes are so fast, it can do your endless loop and still also process other system and application tasks, but _not_ at the same time, just very quickly so it looks like its at the same time.

Increasing your "cores" only allows it to multitask a lil better by being able to do two tasks at the same time, so i guess depending on the OS itself will determine if two cores acually increases reponsiveness.. but generally i think it would..

So it _will_ _not_ crash either way.

But if it wasnt a mulitasking OS your system would lock into that loop thus crashing enless of cource you exit it the program. using two CPUS i guess wouldnt make any differnce because a single process would not be able to divide up the task onto the other CPU.. rendering it useless enless your programmed to use two CPUS.. but really i wouldnt know.. thats just my guess.
 
Last edited:

drewgcn

postpantsism
Joined
Jun 23, 2004
Messages
337
Location
Oatley...land of oats.
Gender
Male
HSC
2006
Ahhh i just tried an equivalent. I see.

I thought it must always lock up the system, probably due to the fact that the first endless loops i made were related to a program that was (continually) adding fields into a db being modified by vb6, which must be why the computer would crash each time (probably as sunny said, slowly chewing the memory).

Thanks.
 

pungemo

Member
Joined
Mar 19, 2006
Messages
132
Location
Where you least suspect me
Gender
Male
HSC
2006
If you create the program using an tool such as Visual Studio there is a higher chance that it will perform actions that you are not aware of and hence result in a crash. Also if it references to API features or GUI elements inside the loop it will chew up memory and eventually the OS will throw a hissy fit and kill itself. It is the RAM that causes the problem, not the CPU.
 

busterblues

04 Info Tech First in HSC
Joined
Mar 17, 2004
Messages
33
Location
Callaghan, Newcastle, NSW
Gender
Male
HSC
2004
Hyperthreaded and Multicore PCs shouldnt be causing any sort of problems.

I would suggest that it is your code. make sure you havent created an endless loop in your code.

If you are definately sure its not the code. I would suggest that it is the compiler and not your processor. But you would have to be using something pretty dam old for the processor to not handle your code. This is very very unlikely

Cheers,

Bryce
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top