Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

exceptions vs interrupts in RiscV?

I read that exceptions are raised by instructions and interrupts are raised by external events.

But I couldn't understand few things:

  1. In which type we stop immediately and in which we let the current line of code finish?

  2. In both cases and after doing 1 we run the next program, is that right?

question from:https://stackoverflow.com/questions/65907797/exceptions-vs-interrupts-in-riscv

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The terminology is used differently by different authors.

The hardware exception mechanism is used by both software caused exceptions, and by external interrupts.

In which type we stop immediately and in which we let the current line of code finish?

The processor can do what its designers want up to a point.

If there is an external interrupt, the processor may choose to finish some of the work in progress before taking the interrupt.

If there is a software caused interrupt, the processor simply cannot execute that instruction (or any instructions after) and must abort its execution, and take the exception without completing the offending instruction.

In both cases and after doing 1 we run the next program, is that right?

In the case of external interrupt, the most efficient is to resume the program that was interrupted, as the caches and page tables are hot for that process.? However, an external interrupt may change the runnable status of another higher priority process, or may end the timeslice of the interrupted process, indicating another process should now get CPU time instead of the one interrupted.

In the case of a software caused exception, it is could be a non-resumable situation (null pointer dereference), in which case, yes another process get the CPU after.? It could be a resumable situation, like I/O request or page fault.? If servicing the situation requires interfacing with peripherals, that may block the interrupted process, so another process would get some CPU time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...