Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

atomic context and process context/interrupt context

in Linux Device Driver3 and Understanding the Linux Kernel. Some buzzword appear many times without definition

process context: referenced in both books, but no definitions

interrupt context: Understanding the Linux Kernel gives definition

atomic context: only appear in LDD3 and without definition. "it specifies that the kernel is currently executing either an interrupt handler or a deferrable function"

when reading tutorial, these three buzzword are referenced by many things. So I think the most important thing is to try figure out the exact definition, then I can understand those references.

I also did some search online, no very clear sources.Could any one gives good definition and the source of that definition? Thanks so much

like image 661
nathan Avatar asked Apr 30 '26 11:04

nathan


2 Answers

This article gives an excellent explanation. Let me summarize it here:

  1. Process Context - Regular processes and syscall invocations execute in this context and it can be interrupted by IRQs
  2. Atomic Context - IRQs are generally executed in this context and they don't belong to any specific process, but rather are invoked by some device(ignore exceptions for simplicity). Once the interrupt context sleeps or gives up the CPU, it cannot be awakened. So it is also called atomic context.

A basic principle of the kernel is that in an interrupt or atomic context, the kernel cannot access user space, and the kernel cannot sleep.

Quoting from the book Linux Kernel Programming by Kaiwan N Billimoria: enter image description here

like image 141
livinston Avatar answered May 03 '26 02:05

livinston


Process context is the values of the registers. When a context switch occurs, one process is put off, the content of the registers is saved, so that when the proccess runs again, you can continue running from the same spot. Stack pointer, instruction pointer and so on.

like image 30
Tony Tannous Avatar answered May 03 '26 03:05

Tony Tannous