53

A hardware interrupt is not really part of CPU multitasking, but may drive it. Hardware interrupts are issued by hardware devices like disk, network cards, keyboards, clocks, etc. Each device or set of devices will have its own IRQ (Interrupt ReQuest) line. Based on the IRQ the CPU will dispatch the request to the appropriate hardware driver. (Hardware ...


18

Ctrl+C sends SIGINT. The conventional action for SIGINT is to return to a program's toplevel loop, cancelling the current command and entering a mode where the program waits for the next command. Only non-interactive programs are supposed to die from SIGINT. So it's natural that Ctrl+C doesn't kill ed, but causes it to return to its toplevel loop. Ctrl+C ...


17

The Unix V7 ed(1) source code is a primitive 1,762-line C program with just a few comments, one of which is this highly-enlightening header comment: /* * Editor */ Given that the source code itself does not provide any rationale, you're only going to get it from the program's author. ed was originally written by Ken Thompson in PDP-11 assembly, but you'...


14

This is covered in chapter 10 of Linux Device Drivers, 3rd edition, by Corbet et al. It is available for free online, or you may toss some shekels O'Reilly's way for dead tree or ebook forms. The part relevant to your question begins on page 278 in the first link. For what it's worth, here is my attempt to paraphrase those three pages, plus other bits I've ...


12

All modern operating systems support multitasking. This means that the system is able to execute multiple processes at the same time; either in pseudo-parallel (when only one CPU is available) or nowadays with multi-core CPUs being common in parallel (one task/core). Let's take the simpler case of only one CPU being available. This means that if you ...


12

In simple terms, you can think of make as having a (possibly large) number of steps, where each step takes a number of files as input and creates one file as output. A step might be "compile file.c to file.o" or "use ld to link main.o and file.o into program". If you interrupt make with CtrlC, then the currently executing step will be terminated which will (...


11

Linux provides two mechanism for monitoring file system events; dnotify and inotify. The older of the two, dnotify, was introduced in kernel version 2.4.0. It allows applications to register to receive notifications on changes in a directory via the fcntl() interface. The notifications themselves are delivered via signals. The dnotify mechanism is limited ...


9

A page fault occurs when a memory access fails because the MMU lookup for the virtual address ended in an invalid descriptor or in a descriptor indicating a lack of permissions (e.g. write attempt to a read-only page). When a page fault occurs, the processor performs a few actions; the details are specific to each processor architectures but the gist is the ...


8

System calls, messaging passing (as described in the Wikipedia article), and interrupts are all things that cause a context switch or a switch from user to kernel mode. As you likely know: kernel mode: programs have a flat or real view of memory, and programs can read/write freely to all memory and all hardware devices directly without restriction. user ...


8

Ctrl+C causes a SIGINT to be sent to the process running. This signal can be caught by the process. In the make source code you can find a trap for this signal in commands.c: /* If we got a signal that means the user wanted to kill make, remove pending targets. */ if (sig == SIGTERM || sig == SIGINT ... remove childrens ... /* Delete any ...


7

ed, like other interactive programs, use Ctrl+C to interrupt tasks of the program itself. This is very similar to the normal case, where it interrupts a task running in the shell - a command. From the user perspective, both variants are very similar. The handling of the signal is different: in the usual case, the signal SIGINT is sent to the foreground ...


7

Check /proc/interrupts to find if one of or more interrupts occur excessively. Hint: Several thousand interrupts per second are no cause for alarm. Excessive interrupts (aka interrupt storms) can have multiple reasons, one of them even being hardware issues (noisy interrupt line). To further answer your question we need to know what OS on what hardware you ...


6

First of all participants involved in interrupt handling are peripheral hardware devices, interrupt controller, CPU, operating system kernel and drivers. Peripheral hardware devices are responsible for interrupt generation. They assert interrupt request lines when they want attention from operating system kernel. These signals are multiplexed by interrupt ...


5

System calls can be interrupted through the use of signals, such as SIGINT (generated by CTRL+C), SIGHUP, etc. You can only interrupt them by interacting with the system calls through a PID, however when using Unix signals and the kill command. rt_patch & system calls @Alan asked the following follow-up question: Is the possibility to interrupt ...


5

Interrupts are handled by the operating system, threads (or processes, for that matter) aren't even aware of them. In the scenario you paint: Your thread issues a read() system call; the kernel gets the request, realizes that the thread won't do anything until data arrives (blocking call), so the thread is blocked. Kernel allocates space for buffers (if ...


5

Message passing is a higher level concept of one process sending a message to another. It is implemented by a system ( kernel ) call, asking the kernel to pass the message to the other process. System calls ask the kernel to perform various services for the process. They are implemented by a software interrupt / system trap, which causes the cpu to save ...


5

Ctrl+C (control character intr): It will send SIGINT signal to a process and usually application gets abort but the application can handle this signal. For example you can handle a signal with signal() function in C Language. Ctrl+Z (control character susp): It will send SIGTSTP signal to a process to put it in background and like SIGINT it can be handle. ...


5

What shell is used is a concern as different shells handle job control differently (and job control is complicated; job.c in bash presently weighs in at 3,300 lines of C according to cloc). pdksh 5.2.14 versus bash 3.2 on Mac OS X 10.11 for instance show: $ cat code pkill yes yes >/dev/null & pid=$! echo $pid sleep 2 kill -INT $pid sleep 2 pgrep yes $...


5

"The kernel is not a process." This is pure terminology. (Terminology is important.) The kernel is not a process because by definition processes exist in userland. But the kernel does have threads. "If a program hits some exception handler that requires long-running synchronous processing before it can start running again (e.g. hits a page fault that ...


5

It's a good thing you put or in the title, since the answer is yes. Namely, exact answer depends on the exact interrupt you're asking about. Let's use an SPI port and DMA as an example. The SPI is a bidirectional serial interface. It's common, for example, for DMA interrupts to mark so-called water levels. You'll have an interrupt when the DMA buffer is ...


4

dstat can also be used for that. dstat -tif 60 To list all the interrupts (those with more than 10 in /proc/stat) dstat -tf --int24 60 Same but using /proc/interrupts, so include things like LOC, PMI, RES... You can also select the list of those you want: $ dstat -t --int24 -I23,LOC,RES 5 ----system---- ----interrupts--- time | 23 LOC RES ...


4

When a driver requests a shared IRQ, it passes a pointer to the kernel to a reference to a device specific structure within the driver's memory space. According to LDD3: Whenever two or more drivers are sharing an interrupt line and the hardware interrupts the processor on that line, the kernel invokes every handler registered for that interrupt, passing ...


4

ctrl+c doesn't ever kill a program, That's just not what it does. There are a set of signals that the POSIX standard define, these are used to control a running program. First the signals described in the original POSIX.1-1990 standard. Signal Value Action Comment ────────────────────────────────────────────────────────────────────── ...


4

Normally, the NIC will only interrupt the CPU if it needs to send the received packet to the system. In non-promiscuous mode, this would only be for packets addressed to its MAC address, the broadcast address ff:ff:ff:ff:ff:ff, or a multicast address to which it has been subscribed. It also does validation before sending the packet to the CPU: the normal ...


4

Great classic question about managing jobs and signals with good examples! I've developed a stripped down test script to focus on the mechanics of the signal handling. To accomplish this, after starting the children (loop.sh) in the background, call wait, and upon receipt of the INT signal, kill the process group whose PGID equals your PID. For the script ...


4

This is highly platform-specific. Unless you bind to a certain platform (even difference between x86-32 and x86-64 is principal), one can't answer this. But, if to limit it to x86, according to your last comment, I could suggest some information. There are two main styles of service request ("syscall") from user land to kernel land: interrupt-styled and ...


4

Have you tried dstat ? in case of my enp025 Ethernet interface for example : dstat -i -N enp0s25 ----interrupts--- 33 34 35 5 0 0 6 0 0 8 0 26 9 0 0 7 0 0 10 0 0 for doing more stuff , read the man page: DSTAT(1) ...


4

The keypress generates an interrupt, just like you figured out. The interrupt is processed by an interrupt handler; which handler depends on the type of hardware, e.g. USB keyboard or PS/2 keyboard. The interrupt handler reads the key code from the hardware and buffers it. From the buffer the character is picked up by the tty driver, which, in the case of ...


4

count gives the total number of times the IRQ fired, modulo 100,000; spurious gives the number of unhandled events in recent memory; and last_unhandled stores the jiffies at which the last unhandled event occurred (displayed in milliseconds since the kernel booted). The purpose of these is to track spurious interrupts and allow them to be taken into account ...


4

You are correct: they relate to the IO-APIC system. ERR is documented in the kernel documentation in Documentation/filesystems/proc (lines 677-680): ERR is incremented in the case of errors in the IO-APIC bus (the bus that connects the CPUs in a SMP system. This means that an error has been detected, the IO-APIC automatically retry the transmission, ...


Only top voted, non community-wiki answers of a minimum length are eligible