SlideShare una empresa de Scribd logo
1 de 11
Linux Kernel Data Structure
Task list – It’s a circular doubly linked list. Each
entry contains a structure (task_struct).
Each structure contains detailed information about
corresponding process and a task list node. The
node contains previous and next pointer only).
Macros to Initialize / manipulate Task list:
 container_of(ptr, type, member) - Returns the
parent structure containing a list_Head (circular
doubly linked list node).
 LIST_HEAD_INIT - Initialize the task list node
embedded in the task_struct.
Linux Kernel Data Structure
Macros to Initialize / manipulate Task list:
 list_for_each_entry(pos, head, member) – Traverse given list
 list_for_each_entry_safe(pos, n, head, member) – safe
against entry removal while traversing the list
 list_for_each_entry_reverse(pos, head, member) – Traverse
given list backward
 list_for_each_entry_reverse_safe(pos, n, head, member) safe against entry removal while traversing the list backward
 list_for_each_entry_safe_continue (pos, n, head, member)
- safe against entry removal while continuing after current
point
pos: pointer type to use as a loop cursor.
n: pointer type to store next pointer.
head: the head for your list (struct list_head *head)
member: the name of the list_struct (struct list_head *list)
Linux Kernel Data Structure
Functions to Initialize/manipulate Task list:
 list_add(struct list_head *new, struct list_head
*head) - add a node to given list
 list_add_tail( struct list_head *new, struct
list_head *head) - add the new node to the list

immediately before the head node
 list_del(struct list_head *entry) – delete a node
from the list
 list_del_init(struct list_head *entry) – delete a
node from a linked list and reinitialize the
given list head
Linux Kernel Data Structure
Functions to Initialize/manipulate Task list:
 list_move(struct list_head *list, struct list_head *head) –
Remove the node from the list and add the node after head
node in the given list.
 list_move_tail list_move(struct list_head *list, struct
list_head *head) ) – Remove the node from the list and add
the node add the node before head node in the given list.
 list_empty(struct list_head *head) – verify if list is empty
 list_splice(struct list_head *list, struct list_head *head) –
Join two lists
 list_splice_init(struct list_head *list, struct list_head *head)
– Join two lists and initialize first list
Linux Kernel Data Structure
Kfifo - Generic Queue used by Linux kernel
Functions to Initialize/manipulate Queue:
 int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t
gfp_mask) – creates a queue and initializes with “size” bytes
 void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int
size)- creates a queue and initializes with “size” bytes from
the memory pointed by buffer
 static inline bool kfifo_initialized(struct kfifo *fifo) – verify if
queue is initialized
 unsigned int kfifo_in(struct kfifo *fifo, const void *from,
unsigned int len) – add data of size “len” from memory
pointed to by “from pointer” to queue
Linux Kernel Data Structure
Functions to Initialize/manipulate Queue:
 unsigned unsigned int kfifo_out(struct kfifo *fifo,
void *to, unsigned int len)– remove from queue
data of size “len” and copy to memory pointed by “to
pointer” from queue
 unsigned int kfifo_out_peek(struct kfifo *fifo, void
*to, unsigned int len, unsigned offset) – peek data
within the queue without removing it
 static inline void kfifo_reset(struct kfifo *fifo) –
remove entire contents of queue
 static inline void kfifo_reset_out(struct kfifo *fifo) –
does not remove entire contents of queue
Linux Kernel Data Structure
Functions to Initialize/manipulate Queue:
 int kfifo_is_empty(struct kfifo *fifo) – verify if queue
is empty
 int kfifo_is_full (struct kfifo *fifo) - verify if queue is
full
 static inline unsigned int kfifo_len(struct kfifo *fifo)
– returns queue size
 unsigned int kfifo_avail(struct kfifo *fifo) – returns
no of bytes available in the queue
 void kfifo_free(struct kfifo *fifo) – free memory
allocated to queue using kfifo_alloc()
Linux Kernel Data Structure
IDR – It is the map implementation of Linux . Struct idr
is used for mapping user-space UIDs to their
associated kernel data structure
Functions to Initialize/manipulate IDR:
void idr_init(struct idr *idp)- initialize Map (idr)
Allocating a new UID (create a new map entry) 2 steps:
1. int idr_pre_get(struct idr *idp, gfp_t gfp_mask) Resizes the backing tree
2. int idr_get_new(struct idr *idp, void *ptr, int *id)Uses the idr pointed at by idp to allocate a new UID and
associate it with the pointer ptr
Linux Kernel Data Structure
Functions to Initialize/manipulate Queue:
void *idr_find(struct idr *idp, int id)– look up a
UID
void idr_remove(struct idr *idp, int id) Remove a UID from an idr
void idr_remove_all(struct idr *idp) – remove
all entries from idr
void idr_destroy(struct idr *idp) - Destroy entire
idr
Linux Kernel Data Structure
Rbtree (red-black tree) – It is the Linux’s
implementation of (semi) Balanced Binary search tree.
It is useful for inserting and searching efficiently.
prio_tree (PST) - It is the Linux’s implementation of
radix priority search tree which is a mix of heap and
radix trees.
It is useful for storing intervals.
e.g. consider a vma as a closed interval of file pages
[offset_begin, offset_end], and store all vmas that map
a file in a PST.
Thank You
• Your suggestions and comments are always
welcome.
• Please send me your feedback at
a_s_sinha@yahoo.com

Más contenido relacionado

La actualidad más candente

Dynamic Routing IGRP
Dynamic Routing IGRPDynamic Routing IGRP
Dynamic Routing IGRP
Kishore Kumar
 

La actualidad más candente (20)

03 ospf
03 ospf 03 ospf
03 ospf
 
windows vs Linux
windows vs Linuxwindows vs Linux
windows vs Linux
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Le protocole stp
Le protocole stpLe protocole stp
Le protocole stp
 
Access control list acl - permissions in linux
Access control list acl  - permissions in linuxAccess control list acl  - permissions in linux
Access control list acl - permissions in linux
 
what is LINUX ? presentation.
what is LINUX ? presentation.what is LINUX ? presentation.
what is LINUX ? presentation.
 
Free CCNP switching workbook by networkershome pdf
Free CCNP switching workbook by networkershome pdfFree CCNP switching workbook by networkershome pdf
Free CCNP switching workbook by networkershome pdf
 
Dynamic Routing IGRP
Dynamic Routing IGRPDynamic Routing IGRP
Dynamic Routing IGRP
 
Server operating system
Server operating systemServer operating system
Server operating system
 
Mavenir network function virtualisation
Mavenir network function virtualisationMavenir network function virtualisation
Mavenir network function virtualisation
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Linux.ppt
Linux.ppt Linux.ppt
Linux.ppt
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Mcse notes
Mcse notesMcse notes
Mcse notes
 
Presentation on samba server
Presentation on samba serverPresentation on samba server
Presentation on samba server
 
Dhcp ppt
Dhcp pptDhcp ppt
Dhcp ppt
 
Differences of the Cisco Operating Systems
Differences of the Cisco Operating SystemsDifferences of the Cisco Operating Systems
Differences of the Cisco Operating Systems
 
Active Directory
Active DirectoryActive Directory
Active Directory
 
Ab initio beginner's course topic 1
Ab initio beginner's course   topic 1Ab initio beginner's course   topic 1
Ab initio beginner's course topic 1
 
DHCP & DNS
DHCP & DNSDHCP & DNS
DHCP & DNS
 

Destacado

Uma visão do mundo rails campus party 2011 - fabio akita
Uma visão do mundo rails   campus party 2011 - fabio akitaUma visão do mundo rails   campus party 2011 - fabio akita
Uma visão do mundo rails campus party 2011 - fabio akita
Campus Party Brasil
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 

Destacado (20)

Data Structures for Text Editors
Data Structures for Text EditorsData Structures for Text Editors
Data Structures for Text Editors
 
Capturando pacotes de rede no kernelspace
Capturando pacotes de rede no kernelspaceCapturando pacotes de rede no kernelspace
Capturando pacotes de rede no kernelspace
 
Linux下Poll和Epoll内核源码剖析
Linux下Poll和Epoll内核源码剖析Linux下Poll和Epoll内核源码剖析
Linux下Poll和Epoll内核源码剖析
 
Uma visão do mundo rails campus party 2011 - fabio akita
Uma visão do mundo rails   campus party 2011 - fabio akitaUma visão do mundo rails   campus party 2011 - fabio akita
Uma visão do mundo rails campus party 2011 - fabio akita
 
Open Source Systems Performance
Open Source Systems PerformanceOpen Source Systems Performance
Open Source Systems Performance
 
DevConf 2014 Kernel Networking Walkthrough
DevConf 2014   Kernel Networking WalkthroughDevConf 2014   Kernel Networking Walkthrough
DevConf 2014 Kernel Networking Walkthrough
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack introduction to linux kernel tcp/ip ptocotol stack
introduction to linux kernel tcp/ip ptocotol stack
 
Socket System Calls
Socket System CallsSocket System Calls
Socket System Calls
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 
Blazing Performance with Flame Graphs
Blazing Performance with Flame GraphsBlazing Performance with Flame Graphs
Blazing Performance with Flame Graphs
 
Unix system programming
Unix system programmingUnix system programming
Unix system programming
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016Broken Linux Performance Tools 2016
Broken Linux Performance Tools 2016
 

Similar a Data Structures used in Linux kernel

Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
rozakashif85
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdf
dhavalbl38
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
Niraj Agarwal
 
1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf
ivylinvaydak64229
 
Complete a C++ class implementation for a linked-list of sorted (asc.pdf
Complete a C++ class implementation for a linked-list of sorted (asc.pdfComplete a C++ class implementation for a linked-list of sorted (asc.pdf
Complete a C++ class implementation for a linked-list of sorted (asc.pdf
shahidqamar17
 

Similar a Data Structures used in Linux kernel (20)

Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdfWrite a Java Class to Implement a Generic Linked ListYour list mus.pdf
Write a Java Class to Implement a Generic Linked ListYour list mus.pdf
 
Basic data structures in python
Basic data structures in pythonBasic data structures in python
Basic data structures in python
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdf
 
Linux
LinuxLinux
Linux
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
UNIT 3a.pptx
UNIT 3a.pptxUNIT 3a.pptx
UNIT 3a.pptx
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf1) Create a function called reverselist that will take a simple list.pdf
1) Create a function called reverselist that will take a simple list.pdf
 
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
Linked List, Types of Linked LIst, Various Operations, Applications of Linked...
 
LinkedDoublyLists.ppt
LinkedDoublyLists.pptLinkedDoublyLists.ppt
LinkedDoublyLists.ppt
 
Sockets and Socket-Buffer
Sockets and Socket-BufferSockets and Socket-Buffer
Sockets and Socket-Buffer
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdf
 
Unit i(dsc++)
Unit i(dsc++)Unit i(dsc++)
Unit i(dsc++)
 
Adt of lists
Adt of listsAdt of lists
Adt of lists
 
DS Unit 2.ppt
DS Unit 2.pptDS Unit 2.ppt
DS Unit 2.ppt
 
Complete a C++ class implementation for a linked-list of sorted (asc.pdf
Complete a C++ class implementation for a linked-list of sorted (asc.pdfComplete a C++ class implementation for a linked-list of sorted (asc.pdf
Complete a C++ class implementation for a linked-list of sorted (asc.pdf
 
Funddamentals of data structures
Funddamentals of data structuresFunddamentals of data structures
Funddamentals of data structures
 
STACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUESTACK, LINKED LIST ,AND QUEUE
STACK, LINKED LIST ,AND QUEUE
 

Más de assinha

Más de assinha (10)

Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
Nwe Embodiment (Naba Kalebara) of Lord Jagannath of PURI - The Greatest and B...
 
SNMP AT a GLANCE
SNMP AT a GLANCESNMP AT a GLANCE
SNMP AT a GLANCE
 
Layer3protocols
Layer3protocolsLayer3protocols
Layer3protocols
 
Umts explained
Umts explainedUmts explained
Umts explained
 
Architectural patterns part 4
Architectural patterns part 4Architectural patterns part 4
Architectural patterns part 4
 
Architectural patterns part 3
Architectural patterns part 3Architectural patterns part 3
Architectural patterns part 3
 
Architectural Patterns - Interactive and Event Handling Patterns
Architectural Patterns  - Interactive and Event Handling PatternsArchitectural Patterns  - Interactive and Event Handling Patterns
Architectural Patterns - Interactive and Event Handling Patterns
 
Architectural patterns part 1
Architectural patterns part 1Architectural patterns part 1
Architectural patterns part 1
 
E nodeb handover procedure
E nodeb handover procedureE nodeb handover procedure
E nodeb handover procedure
 
Initial LTE call Setup Flow
Initial LTE call Setup FlowInitial LTE call Setup Flow
Initial LTE call Setup Flow
 

Último

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 

Último (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Data Structures used in Linux kernel

  • 1. Linux Kernel Data Structure Task list – It’s a circular doubly linked list. Each entry contains a structure (task_struct). Each structure contains detailed information about corresponding process and a task list node. The node contains previous and next pointer only). Macros to Initialize / manipulate Task list:  container_of(ptr, type, member) - Returns the parent structure containing a list_Head (circular doubly linked list node).  LIST_HEAD_INIT - Initialize the task list node embedded in the task_struct.
  • 2. Linux Kernel Data Structure Macros to Initialize / manipulate Task list:  list_for_each_entry(pos, head, member) – Traverse given list  list_for_each_entry_safe(pos, n, head, member) – safe against entry removal while traversing the list  list_for_each_entry_reverse(pos, head, member) – Traverse given list backward  list_for_each_entry_reverse_safe(pos, n, head, member) safe against entry removal while traversing the list backward  list_for_each_entry_safe_continue (pos, n, head, member) - safe against entry removal while continuing after current point pos: pointer type to use as a loop cursor. n: pointer type to store next pointer. head: the head for your list (struct list_head *head) member: the name of the list_struct (struct list_head *list)
  • 3. Linux Kernel Data Structure Functions to Initialize/manipulate Task list:  list_add(struct list_head *new, struct list_head *head) - add a node to given list  list_add_tail( struct list_head *new, struct list_head *head) - add the new node to the list immediately before the head node  list_del(struct list_head *entry) – delete a node from the list  list_del_init(struct list_head *entry) – delete a node from a linked list and reinitialize the given list head
  • 4. Linux Kernel Data Structure Functions to Initialize/manipulate Task list:  list_move(struct list_head *list, struct list_head *head) – Remove the node from the list and add the node after head node in the given list.  list_move_tail list_move(struct list_head *list, struct list_head *head) ) – Remove the node from the list and add the node add the node before head node in the given list.  list_empty(struct list_head *head) – verify if list is empty  list_splice(struct list_head *list, struct list_head *head) – Join two lists  list_splice_init(struct list_head *list, struct list_head *head) – Join two lists and initialize first list
  • 5. Linux Kernel Data Structure Kfifo - Generic Queue used by Linux kernel Functions to Initialize/manipulate Queue:  int kfifo_alloc(struct kfifo *fifo, unsigned int size, gfp_t gfp_mask) – creates a queue and initializes with “size” bytes  void kfifo_init(struct kfifo *fifo, void *buffer, unsigned int size)- creates a queue and initializes with “size” bytes from the memory pointed by buffer  static inline bool kfifo_initialized(struct kfifo *fifo) – verify if queue is initialized  unsigned int kfifo_in(struct kfifo *fifo, const void *from, unsigned int len) – add data of size “len” from memory pointed to by “from pointer” to queue
  • 6. Linux Kernel Data Structure Functions to Initialize/manipulate Queue:  unsigned unsigned int kfifo_out(struct kfifo *fifo, void *to, unsigned int len)– remove from queue data of size “len” and copy to memory pointed by “to pointer” from queue  unsigned int kfifo_out_peek(struct kfifo *fifo, void *to, unsigned int len, unsigned offset) – peek data within the queue without removing it  static inline void kfifo_reset(struct kfifo *fifo) – remove entire contents of queue  static inline void kfifo_reset_out(struct kfifo *fifo) – does not remove entire contents of queue
  • 7. Linux Kernel Data Structure Functions to Initialize/manipulate Queue:  int kfifo_is_empty(struct kfifo *fifo) – verify if queue is empty  int kfifo_is_full (struct kfifo *fifo) - verify if queue is full  static inline unsigned int kfifo_len(struct kfifo *fifo) – returns queue size  unsigned int kfifo_avail(struct kfifo *fifo) – returns no of bytes available in the queue  void kfifo_free(struct kfifo *fifo) – free memory allocated to queue using kfifo_alloc()
  • 8. Linux Kernel Data Structure IDR – It is the map implementation of Linux . Struct idr is used for mapping user-space UIDs to their associated kernel data structure Functions to Initialize/manipulate IDR: void idr_init(struct idr *idp)- initialize Map (idr) Allocating a new UID (create a new map entry) 2 steps: 1. int idr_pre_get(struct idr *idp, gfp_t gfp_mask) Resizes the backing tree 2. int idr_get_new(struct idr *idp, void *ptr, int *id)Uses the idr pointed at by idp to allocate a new UID and associate it with the pointer ptr
  • 9. Linux Kernel Data Structure Functions to Initialize/manipulate Queue: void *idr_find(struct idr *idp, int id)– look up a UID void idr_remove(struct idr *idp, int id) Remove a UID from an idr void idr_remove_all(struct idr *idp) – remove all entries from idr void idr_destroy(struct idr *idp) - Destroy entire idr
  • 10. Linux Kernel Data Structure Rbtree (red-black tree) – It is the Linux’s implementation of (semi) Balanced Binary search tree. It is useful for inserting and searching efficiently. prio_tree (PST) - It is the Linux’s implementation of radix priority search tree which is a mix of heap and radix trees. It is useful for storing intervals. e.g. consider a vma as a closed interval of file pages [offset_begin, offset_end], and store all vmas that map a file in a PST.
  • 11. Thank You • Your suggestions and comments are always welcome. • Please send me your feedback at a_s_sinha@yahoo.com