Presentation is loading. Please wait.

Presentation is loading. Please wait.

User-Space-to-Kernel Interface

Similar presentations


Presentation on theme: "User-Space-to-Kernel Interface"— Presentation transcript:

1 User-Space-to-Kernel Interface
Chapter 3 Presenter: Mojtaba Malekpour Professor: Dr. Seyed Vahid Azhari

2 Introduction Application User Mode Implementation Abstraction Detail
Kernel Hardware

3 A Question How a user application use kernel info? Example:
How can find number of CPU clock in a C++ application? How can access ARP table in a application?

4 Mechanisms Kernel Interfaces Socket Based Ioctl Kernel System Calls
Sending Signals Upcall Mmap

5 Kernel Interfaces Kernel Interfaces Procfs Sysfs Sysctl Configfs
Debugfs

6 Procfs Procfs Located in /proc
Originally designed to export all kind of process information Current status of the process All open file descriptors to the user space

7 Procfs and other purposes
Provide information about the running system CPU information Interrupts information Available memory Version of kernel Information about "idle devices“ "scsi devices“ "tty's". Networking information Arp table Network statistics Lists of used sockets

8 Practical! Example: ls proc/ cat /proc/version cat cpuinfo
cat filesystem cat /proc/looks cat /proc/net/dev cat /proc/net/arp cat /proc/net/route cat /proc/net/tcp

9 Practical! Example: Exe Read.c

10 Sysfs Represent the device model Contains information about
Devices Drivers Buses Use for device Heavily structured A lot of links between the individual directories

11 Sysfs kernel 2.6.23 it contains the following 9 top-level directories
sys/block/ all known block devices such as hda/ ram/ sda/ sys/bus/ all registered buses device/ for all devices attached to that bus driver/ for all drivers assigned with that bus. sys/class/ each device type have a subdirectory: for example /printer or /sound sys/device/ all devices known by the kernel, connected by the bus sys/firmware/ files in this directory handle the firmware of some hardware sys/fs/ files to control a file system sys/kernel/ holds directories (mount points) for other filesystems sys/module/ each kernel module loaded is represented with a directory. sys/power/ files to handle the power state of some hardware

12 Practical Example: cat sys/ cat sys/class/ieee80211/phy0/macaddress
cat sys/class/net/wlan0/phy80211/macaddress cat sys/class/power_supply/BAT1/energy_now cat class/block/sda1/size

13 Configfs The configfs is some what the counterpart of the sysfs
Full control by user Difference between configfs and sysfs Configfs all objects are created from user space with a call to mkdir The kernel responds with creating the attributes (files) Can be read and written by the user Use rmdir to deleted life cycle of a configfs object is fully controlled by user space

14 Debugfs To use RAM based file system
Especially designed for debugging purposes Obtain some debugging information from their kernel code Provide set or get a single value Developer is also allowed to write its own read/write functions

15 Sysctl Designed to configure kernel parameters at run time
Heavily used by the Linux networking subsystem It can be used to configure some core kernel parameters Represented as files in /proc/sys/* The values can be accessed by cat echo: set: only persists as long as the kernel is runningbut gets lost as soon as the machine is rebooted sysctl

16 Sysctl Example cat /proc/sys/net/ipv4/ip_default_ttl
cat /proc/sys/net/ipv4/ipfrag_high_thresh

17 add a new file How can add a new file in /proc Exe jif.c
Show number of clock cat /prog/jif

18 Ioctl Documentation/ioctl-number.txt
ifconfig command uses ioctl to communicate with the kernel #include <sys/ioctl.h> int ioctl(int d, int request, ...);

19 Practical Exe iotcl.c Turn on and off capslook

20 Netlink Sockets Especially designed for the communication between the kernel space and the user space Full-duplex communication link between the Linux kernel and user space

21 Tanks for your attention


Download ppt "User-Space-to-Kernel Interface"

Similar presentations


Ads by Google