Could this code damage my processor?

前端 未结 7 695
有刺的猬
有刺的猬 2021-02-05 18:50

A friend sent me that code and alleges that it could damage the processor. Is that true?

void damage_processor() {
    while (true) {
        // Assembly code th         


        
7条回答
  •  执念已碎
    2021-02-05 19:46

    Sorry, the code doesn't run on an ARM processor.

    In many processors, instructions that set the status word or affect the processor are restricted to "supervisor" mode. Good operating systems run User code in a "protected" mode that does not have the same capabilities as "supervisor" mode. Executing privileged instructions on modern processors in User mode generates exceptions.

    You and your friend could always look up the instructions in an assembly language reference manual and verify the operation.

提交回复
热议问题