IceWalkers.com - Linux Software downloads and news
Name : Password :
Linux SoftwareLinux RPMLinux HowtosLink UsAboutAdvertise

KernelAnalysis-HOWTO

Search Howtos :Match :
Next Previous Contents

14. Static variables

14.1 Overview

Linux is written in ''C'' language, and as every application has:

  1. Local variables
  2. Module variables (inside the source file and relative only to that module)
  3. Global/Static variables present in only 1 copy (the same for all modules)

When a Static variable is modified by a module, all other modules will see the new value.

Static variables under Linux are very important, cause they are the only kind to add new support to kernel: they typically are pointers to the head of a list of registered elements, which can be:

  • added
  • deleted
  • maybe modified

                           _______      _______      _______
Global variable  -------> |Item(1)| -> |Item(2)| -> |Item(3)|  ..
                          |_______|    |_______|    |_______|

14.2 Main variables

Current

                           ________________
Current ----------------> | Actual process |
                          |________________|

Current points to ''task_struct'' structure, which contains all data about a process like:

  • pid, name, state, counter, policy of scheduling
  • pointers to many data structures like: files, vfs, other processes, signals...

Current is not a real variable, it is

static inline struct task_struct * get_current(void) { 
   struct task_struct *current; 
   __asm__("andl %%esp,%0; ":"=r" (current) : "0" (~8191UL)); 
   return current; 
}
#define current get_current()

Above lines just takes value of ''esp'' register (stack pointer) and get it available like a variable, from which we can point to our task_struct structure.

From ''current'' element we can access directly to any other process (ready, stopped or in any other state) kernel data structure, for example changing STATE (like a I/O driver does), PID, presence in ready list or blocked list, etc.

Registered filesystems

                       ______      _______      ______
file_systems  ------> | ext2 | -> | msdos | -> | ntfs |
 [fs/super.c]         |______|    |_______|    |______|

When you use command like ''modprobe some_fs'' you will add a new entry to file systems list, while removing it (by using ''rmmod'') will delete it.

Mounted filesystems

                        ______      _______      ______
mount_hash_table  ---->|   /  | -> | /usr  | -> | /var |
[fs/namespace.c]       |______|    |_______|    |______|

When you use ''mount'' command to add a fs, the new entry will be inserted in the list, while an ''umount'' command will delete the entry.

Registered Network Packet Type

                        ______      _______      ______ 
     ptype_all  ------>|  ip  | -> |  x25  | -> | ipv6 |
[net/core/dev.c]       |______|    |_______|    |______|

For example, if you add support for IPv6 (loading relative module) a new entry will be added in the list.

Registered Network Internet Protocol

                          ______      _______      _______ 
inet_protocol_base ----->| icmp | -> |  tcp  | -> |  udp  |
[net/ipv4/protocol.c]    |______|    |_______|    |_______|

Also others packet type have many internal protocols in each list (like IPv6).

                          ______      _______      _______ 
inet6_protos ----------->|icmpv6| -> | tcpv6 | -> | udpv6 |
[net/ipv6/protocol.c]    |______|    |_______|    |_______|

Registered Network Device

                          ______      _______      _______ 
dev_base --------------->|  lo  | -> |  eth0 | -> |  ppp0 |
[drivers/core/Space.c]   |______|    |_______|    |_______|

Registered Char Device

                          ______      _______      ________ 
chrdevs ---------------->|  lp  | -> | keyb  | -> | serial |
[fs/devices.c]           |______|    |_______|    |________|

''chrdevs'' is not a pointer to a real list, but it is a standard vector.

Registered Block Device

                          ______      ______      ________ 
bdev_hashtable --------->|  fd  | -> |  hd  | -> |  scsi  |
[fs/block_dev.c]         |______|    |______|    |________|

''bdev_hashtable'' is an hash vector.


Next Previous Contents
Search Howtos :Match :
Transmission 1.41 beta 2
Lightweight, yet powerful BitTorrent client
X-Moto 0.5.0
2D motocross platform game
Gdm 2.25.1
Reimplementation of the well known xdm program.
Linux Kernel 2.6 2.6.28-rc7
Linux Kernel
Linux Kernel 2.4 2.4.37
Linux Kernel
RIP 7.3
Small linux system for the purpose of system booting or repairing
GEdit 2.25.1
Small but powerful text editor
VLC media player 0.9.7
Cross-platform media player and streaming server
GNOME 2.25.2
GNOME desktop environment
WebGUI 7.6.5
A fully featured content management system.
Free IT Magazines, White Papers, eBooks, and more !
Dr. Dobb's Journal

Dr. Dobb's Journal enables programmers to write the most efficient and sophisticated programs and help in daily programming quandaries.

The 7 Things that IT Security Professionals MUST KNOW!

Gain key insight into security problem and find the safest means to protect your technological assets.

Database Trends and Applications

Provides timely coverage of the technology, intelligence and insight needed to plan, implement and manage information-rich projects.

Linux Software Map
Find Linux RPM
Best Rated Linux Software
Most Rated Linux Software
Linux Distributions
Linux Howtos
Quick Survey

Please take our survey and help us improve our website to serve you better.

Thank you.
Linux Software
Linux / IT Resources
Site Resources
Google
Privacy Policy
Contact Us
Submit Software
Advertising info