hardware-traps

What are traps?

怎甘沉沦 提交于 2019-12-04 16:26:22
问题 There are many different types of traps listed in processor datasheets, e.g. BusFault, MemManage Fault, Usage Fault and Address Error. What is their purpose? How can they be utilized in fault handling? 回答1: Traps are essentially subroutine calls that are forced by the processor when it detects something unusual in your stream of instructions. (Some processors make them into interrupts, but that's mostly just pushing more context onto the stack; this gets more interesting if the trap includes

What are traps?

谁都会走 提交于 2019-12-03 10:30:30
There are many different types of traps listed in processor datasheets, e.g. BusFault, MemManage Fault, Usage Fault and Address Error. What is their purpose? How can they be utilized in fault handling? Traps are essentially subroutine calls that are forced by the processor when it detects something unusual in your stream of instructions. (Some processors make them into interrupts, but that's mostly just pushing more context onto the stack; this gets more interesting if the trap includes a switch between user and system address spaces). This is useful for handling conditions that occur rarely

How does a hardware trap in a three-past-the-end pointer happen even if the pointer is never dereferenced?

会有一股神秘感。 提交于 2019-11-30 04:02:28
问题 In his November 1, 2005 C++ column, Herb Sutter writes ... int A[17]; int* endA = A + 17; for( int* ptr = A; ptr < endA; ptr += 5 ) { // ... } [O]n some CPU architectures, including current ones, the aforementioned code can cause a hardware trap to occur at the point where the three-past-the-end pointer is created, whether that pointer is ever dereferenced or not. How does a CPU trap on a bitpattern? What about ... int A[17]; // (i) hardware will trap this ? int *pUgly = A + 18; // (ii)