When an interrupt occurs, what happens to instructions in the pipeline?

First, terminology: Usually, at Intel at least, an interrupt is something that comes from the outside world. Usually it is not synchronized with instructions executing on the processor, i.e. it is an asynchronous external interrupt. In Intel terminology an exception is something caused by instructions executing on the processor. E.g. a page fault, or an … Read more

In an operating system, what is the difference between a system call and an interrupt?

Short Answer: They are different things. A system call is call by software running on the OS to services provided by the OS. An interrupt is usually external hardware component notifying the CPU/Microprocessor about an event that needs handling in software (usually a driver). I say usually external, because some interrupts can be raised by … Read more

How to run one last function before getting killed in Python?

import time try: time.sleep(10) finally: print “clean up” clean up Traceback (most recent call last): File “<stdin>”, line 2, in <module> KeyboardInterrupt If you need to catch other OS level interrupts, look at the signal module: http://docs.python.org/library/signal.html Signal Example from signal import * import sys, time def clean(*args): print “clean me” sys.exit(0) for sig in … Read more

Intel x86 vs x64 system call

General part EDIT: Linux irrelevant parts removed While not totally wrong, narrowing down to int 0x80 and syscall oversimplifies the question as with sysenter there is at least a 3rd option. Using 0x80 and eax for syscall number, ebx, ecx, edx, esi, edi, and ebp to pass parameters is just one of many possible other … Read more

Is Thread.interrupt() evil?

Short version: Is it a known best practice never to use Thread.interrupt()? No. Can you provide evidence why it is broken / buggie, and should not be used for writing robust multithreaded code? The opposite is true: it is critical for multithreaded code. See Listing 7.7 in Java Concurrency in Practice for an example. Longer … Read more

Stopping C++ 11 std::threads waiting on a std::condition_variable

No, there’s nothing wrong with your design, and it’s the normal approach taken for this sort of problem. It’s perfectly valid for you to have multiple conditions (eg anything on queue or program stopping) attached to a condition variable. The key thing is that the bits in the condition are checked for when the wait … Read more

What happens when an ISR is running and another interrupt happens?

Normally, an interrupt service routine proceeds until it is complete without being interrupted itself in most of the systems. However, If we have a larger system, where several devices may interrupt the microprocessor, a priority problem may arise. If you set the interrupt enable flag within the current interrupt as well, then you can allow … Read more

How do system calls work?

Your understanding is pretty close; the trick is that most compilers will never write system calls, because the functions that programs call (e.g. getpid(2), chdir(2), etc.) are actually provided by the standard C library. The standard C library contains the code for the system call, whether it is called via INT 0x80 or SYSENTER. It’d … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)