Skip to main content

The Non Maskable Interrupt


I would like to take some time to discuss a wonderful coding tools that is provided by a number of modern chips makers. I am (of course) talking about the Non Maskable Interrupt (NMI).
In general, there are two System Registers that are used to manage system interrupts – the Interrupt Mask Register and the Interrupt Cause Register. The Interrupt Mask Register allows the root user to disable/enable specific interrupts. This register contains a bit for each interrupt type. The Interrupt Cause Register indicates when the interrupts are ready for service. This register also contains a bit for each interrupt type.
So when an interrupt comes into the system, the appropriate bit is set in the Interrupt Cause Register. If the appropriate bit is set in the Interrupt Mask Register, then the interrupt is generated and serviced by the appropriate Exception Handler. Otherwise, the system is not interrupted and the interrupt is essentially ignored.
Non Maskable Interrupt Defined
By definition, the Non Maskable interrupt is an interrupt that cannot be disabled. An NMI is periodically (and regularly) generated by the CPU. This functionality provides two benefits:
The first benefit is to detect a hung or wedged system. That is, a system that does not seem to be doing anything. This is often times the result of a very tight coding loop. In this case, a counter is added to the system scheduler. This counter is incremented every time the scheduler completes its main processing loop. If this counter does not get incremented over long periods of time, then the system is hung in some specific task and normal system processing has been suspended. The NMI Exception Handler can easily detect this and generate a panic. Additional counters and flags can then be added through out the system to ensure that system processing is proceeding in a healthy fashion. The NMI Exception Handler then can periodically check these counters and flags and thus detect when system processing is in an abnormal state.
Measuring System Performance & Code Coverage
The second benefit is to help measure system performance and code coverage. The Non Maskable Interrupt Exception Handler uses a Code Array to achieve this purpose. The kernel code space is divided into buckets, where each bucket is an entry in the Code Array. The size of a bucket is configurable. Each bucket is used to keep track of code hits. Thus each bucket keeps track of the number of times a section of code has been entered. Thus for a a bucket size of B, let PC be the program counter when an NMI occurs. Then the specific bucket is identified by (PC / B).
So to measure system performance and code coverage for a given test:
1) Clear the Code Array.
2) Run the test.
3) Examine the Code Array.
If we order the buckets by the number of items descending, then we have a clear indication of the code priority and usage during the test. This can be used to detect anomalies and to shine a spot light on the code.
So go forth and make use of this wonderful tool.


Comments

Popular posts from this blog

Rethinking the way we build on the cloud: Layering the Cloud

To help, you can split your cloud architecture into three layers: Visible Volatile Persistant Visible This is the layer between the cloud and the rest of the world. It is mainly public DNS entries, load balancers, VPN connections etc. etc. These things are fairly static and consistent. If you have a website you will want the same A Name records pointing at your static IP. Things in the visible layer rarely change or if they do they are for very deliberate reasons. Volatile This is where the majority of your servers are. It’s called volatile because it tends to change a lot. The known state (how many servers, what versions of which software they run etc.) are changing frequently, perhaps even several times per hour. Even in a traditional data centre your servers are being upgraded, having security patches applied, new versions of software deployed, extra servers added etc. On the cloud this is even more volatile when you use patterns such as the Phoenix server and m...

Real-Time Talk: Windows 10 IoT Core Background Tasks and ASP.NET Core Web Apps

Display useful information from your Windows 10 IoT Core application in an ASP.NET Core web app, essential for integrating IoT data into a solution. Windows 10 IoT background task talk with a web application using WebSockets. Problems As my path to this solution has been troublesome, I am listing here the main problems I faced so my dear readers have a better idea of dead-end streets along the way: I was not able to make the ASP.NET Core web application run under a Windows 10 IoT background service. I found no information about when or if it will be supported in the near future. ASP.NET MVC and ASP.NET Core have different SignalR implementations. I was not able to make a SignalR client for .NET Core work with SignalR hosted on a web application. I was able to make things work by directly using a WebSocket. It’s not as nice a solution as I had in my mind, but it works until things get better. Making the Background Task and Web Application Talk I worked out sim...

Kubernetes Configuration Provider to load data from Secrets and Config Maps

Using Kubernetes Configuration Provider to load data from Secrets and Config Maps When running Apache Kafka on Kubernetes, you will sooner or later probably need to use Config Maps or Secrets. Either to store something in them, or load them into your Kafka configuration. That is true regardless of whether you use Strimzi to manage your Apache Kafka cluster or something else. Kubernetes has its own way of using Secrets and Config Maps from Pods. But they might not be always sufficient. That is why in Strimzi, we created Kubernetes Configuration Provider for Apache Kafka which we will introduce in this blog post. Usually, when you need to use data from a Config Map or Secret in your Pod, you will either mount it as volume or map it to an environment variable. Both methods are configured in the spec section or the Pod resource or in the spec.template.spec section when using higher level resources such as Deployments or StatefulSets. When mounted as a volume, the contents of the Secr...