Adding a System Call to Linux Kernel
-
Upload
dkgbond3931 -
Category
Documents
-
view
229 -
download
3
Transcript of Adding a System Call to Linux Kernel
Adding a System Callto the Linux Kernel
Submitted by:Dishant Sharma ~ Deepak Giri ~ Pramod Verma
Project – Operating Systems
In this project, we willincorporate a new system call
into the Linux kernel, thereby expanding the functionality
of the operating system.
•the system call interface provided by the Linux operating system, and
•how user programs communicate with the operating system kernel via the system call interface.
In this project, we will study:
•the system call interface provided by the Linux operating system, and
•how user programs communicate with the operating system kernel via the system call interface.
In this project, we will study:
•the system call interface provided by the Linux operating system, and
•how user programs communicate with the operating system kernel via the system call interface.
In this project, we will study:
•Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as CPU, disks, printers, and so on.
•Unix systems implement most interfaces between User Mode processes and hardware devices by means of system calls issued to the kernel.
System Calls??
•Operating systems offer processes running in User Mode a set of interfaces to interact with hardware devices such as CPU, disks, printers, and so on.
•Unix systems implement most interfaces between User Mode processes and hardware devices by means of system calls issued to the kernel.
System Calls??
•Putting an extra layer between the application and the hardware has several advantages:▫ It makes programming easier, freeing users from
studying low-level programming characteristics of hardware devices.
▫ It greatly increases system security, since the kernel can check the correctness of the request at the interface level before attempting to satisfy it.
▫These interfaces make programs more portable since they can be compiled and executed correctly on any kernel that offers the same set of interfaces.
System Calls??
•Putting an extra layer between the application and the hardware has several advantages:▫ It makes programming easier, freeing users from
studying low-level programming characteristics of hardware devices.
▫ It greatly increases system security, since the kernel can check the correctness of the request at the interface level before attempting to satisfy it.
▫These interfaces make programs more portable since they can be compiled and executed correctly on any kernel that offers the same set of interfaces.
System Calls??
•Putting an extra layer between the application and the hardware has several advantages:▫ It makes programming easier, freeing users from
studying low-level programming characteristics of hardware devices.
▫ It greatly increases system security, since the kernel can check the correctness of the request at the interface level before attempting to satisfy it.
▫These interfaces make programs more portable since they can be compiled and executed correctly on any kernel that offers the same set of interfaces.
System Calls??
•Putting an extra layer between the application and the hardware has several advantages:▫ It makes programming easier, freeing users from
studying low-level programming characteristics of hardware devices.
▫ It greatly increases system security, since the kernel can check the correctness of the request at the interface level before attempting to satisfy it.
▫These interfaces make programs more portable since they can be compiled and executed correctly on any kernel that offers the same set of interfaces.
System Calls??
•A User Mode procedure call is performed by passing arguments to the called procedure either on stack or through registers, saving the current state and the value of the program counter, and jumping to the beginning of the code corresponding to the called procedure (the process continues to have the same privileges as before).
•System calls appear as procedure calls to user programs, but result in a change of execution context and privileges.
•A User Mode procedure call is performed by passing arguments to the called procedure either on stack or through registers, saving the current state and the value of the program counter, and jumping to the beginning of the code corresponding to the called procedure (the process continues to have the same privileges as before).
•System calls appear as procedure calls to user programs, but result in a change of execution context and privileges.
System Call in Linux(Intel 386 architecture)
In Linux, a system call is accomplished by•storing the system call number into the
EAX register,•storing arguments to the system call in
other hardware registers, and•executing a trap instruction
•After the trap is executed, the system call number is used to index into a table of code pointers to obtain the starting address for the handler code implementing the system call.
•The process then jumps to this address and the privileges of the process are switched from user to kernel mode.
•With the expanded privileges, the process can now execute kernel code that might include privileged instructions that cannot be executing in user mode.
•The kernel code can then perform the requested services (such as interacting with I/O devices) that cannot be performed in user mode.
Building a New Kernel
•If the source code package has been previously installed on your machine, the corresponding files might be available under /usr/src/linux-2.x
•If the package has not been installed earlier, it can be downloaded from http://kernel.org/
Step 1 – Obtain the kernel source code
Step 2 – Configure, Compile & Install
• This will vary between the different kernel distributions, but some typical commands for building the kernel (after entering the directory where the kernel source code is stored) include:▫make xconfig▫make dep▫make bzImage
Step 3 – Add Boot option
•The Linux OS typically uses utilities such as lilo and grub to maintain a list of portable kernels, from which the user can choose during machine boot-up.
For systems supporting lilo
•Add an entry to lilo.conf, such as:image=/boot/bzImage.mykernellabel=mykernelroot=/dev/hda5read-only
(where /boot/bzImage.mykernel is the kernel image and mykernel is the lable associated with the new kernel)
The project further ahead…
•extending the Kernel source•adding a System Call code to the kernel•using the new System Call from a user
program
Questions!!
Questions!!
THANK YOU!
THANK YOU!