Questions tagged [interrupt]

Use for questions related to interrupt signals and interrupt handling.

In computing, an interrupt is an asynchronous signal indicating the need for attention or a synchronous event in software indicating the need for a change in execution.

A hardware interrupt happens in response to some hardware event (say mouse movement) and causes the processor to save its state of execution and begin execution of an interrupt handler. At the same time, the possibility for this interrupt is disabled (to prevent it happening repeatedly) and must be re-enabled by software after the current interrupt has been serviced.

Interrupts are usually identified by number, and normally there is a system table somewhere in the OS that maps this number to the address of function that must service the interrupt.

Software interrupts as seen by the programmer do not differ much from the usual function calls. However they are usually implemented as specific instructions in the instruction set so may require less code to be called. Software interrupts are processed in a very similar way to the way hardware interrupts are processed, often using similar context switching and a shared interrupt table for both.

3261 questions
28
votes
7 answers

What is the difference between a static global and a static volatile variable?

I have used a static global variable and a static volatile variable in file scope, both are updated by an ISR and a main loop and main loop checks the value of the variable. here during optimization neither the global variable nor the volatile…
Manoj Doubts
  • 13,579
  • 15
  • 42
  • 45
27
votes
3 answers

Do interrupts interrupt other interrupts on Arduino?

I have an Arduino Uno (awesome little device!). It has two interrupts; let's call them 0 and 1. I attach a handler to interrupt 0 and a different one to interrupt 1, using attachInterrupt() :…
Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
27
votes
5 answers

How are interrupts handled on SMP?

How are interrupts handled on SMP (Symmeteric multiprocessor/multicore) machines? Is there only one memory management unit or more? Say two threads, A and B running on different cores touch a memory page (at the same time) which is not there in the…
pythonic
  • 20,589
  • 43
  • 136
  • 219
26
votes
3 answers

What does Future.cancel() do if not interrupting?

From java docs on Future.cancel() boolean cancel(boolean mayInterruptIfRunning) Attempts to cancel execution of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some…
Tom
  • 1,203
  • 4
  • 21
  • 36
26
votes
3 answers

Methods that Clear the Thread.interrupt() flag

I have recently inherited a large Java Application that has almost no Thread safety in it. What I'm currently working on is getting all of the Threads to correctly handle being interrupted instead of using the very bad Thread.stop(). Part of the…
OverflowingStack
  • 363
  • 1
  • 4
  • 5
23
votes
4 answers

Interrupt masking: why?

I was reading up on interrupts. It is possible to suspend non-critical interrupts via a special interrupt mask. This is called interrupt masking. What i dont know is when/why you might want to or need to temporarily suspend interrupts? Possibly…
user249375
23
votes
3 answers

How to send an interrupt signal

I'm trying to implement a function that would call an interrupt signal in Go. I know how to intercept interrupt signals from the console, by using signal.Notify(interruptChannel, os.Interrupt), however, I can't find a way to actually send the…
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
23
votes
6 answers

Does the finally block execute if the thread running the function is interrupted?

If I have a function with a try/finally section, and the thread running it is interrupted while in the try block, will the finally block execute before the interruption actually occurs?
user940016
  • 2,878
  • 7
  • 35
  • 56
23
votes
3 answers

What are the differences between calling System.exit(0) and Thread.currentThread().interrupt() in the main thread of a Java program?

Both cause a program to stop executing. It's clear that there must be some differences in how this happens, though. What are they?
brandones
  • 1,847
  • 2
  • 18
  • 36
22
votes
11 answers

Interrupts and exceptions

I've seen several question on here about exceptions, and some of them hint at interrupts as exceptions, but none make the connection clear. What is an interrupt? What is an exception? (please explain what exceptions are for each language you know,…
Adam Davis
  • 91,931
  • 60
  • 264
  • 330
21
votes
3 answers

What does "int 21h" mean in Assembly?

I'm new to learning assembly language, and I'm wondering what the command int 21h means. For example: mov ah,01h int 21h Which should read a key from the user.
BOSS
  • 1,828
  • 11
  • 34
  • 60
21
votes
2 answers

How do interrupts in multicore/multicpu machines work?

I recently started diving into low level OS programming. I am (very slowly) currently working through two older books, XINU and Build Your Own 32 Bit OS, as well as some resources suggested by the fine SO folks in my previous question, How to get…
Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78
21
votes
5 answers

prevent linux thread from being interrupted by scheduler

How do you tell the thread scheduler in linux to not interrupt your thread for any reason? I am programming in user mode. Does simply locking a mutex acomplish this? I want to prevent other threads in my process from being scheduled when a…
johnnycrash
  • 5,184
  • 5
  • 34
  • 58
20
votes
3 answers

Do I need to synchronize a call to the interrupt method?

Consulting the JavaDocs and the source code of the Thread.interrupt() method in Java SE 7 I found this: public void interrupt() { if (this != Thread.currentThread()) checkAccess(); synchronized (blockerLock) { Interruptible…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
20
votes
3 answers

iOS AVAudioSession interruption notification not working as expected

I want to know when my AVAudioRecorder is inaccessible (e.g when music starts playing). As audioRecorderEndInterruption will be deprecated with iOS 9 I am focusing on AVAudioSession's interruption notification (but neither is working as…