Linux Kernel 88 - Macros
# Prerequisites
# Preface
# General
# container_of
It is defined in include/linux/kernel.h
as follows :
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
void *__mptr = (void *)(ptr); \
BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \
!__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
((type *)(__mptr - offsetof(type, member))); })
# Process, and Scheduler
# task_of
# others (should be move to different articles in the future)
# task_struct
Both nvcsw
and nivcsw
are context switch counters. The first one represents the number of voluntary context switches (Number of Voluntary Context Switches) while the second represents the number of involuntary context switches (Number of InVoluntary Context Switches).
- 01
- Reading Papers - Kernel Concurrency06-01
- 02
- Linux Kernel - Source Code Overview05-01
- 03
- Linux Kernel - Per-CPU Storage05-01