Mechanism of Determining Page Faults Instantaneously Via Device Driver Based Approach in Linux

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 13

Mechanism of Determining Page faults Instantaneously via Device Driver based approach in Linux

presented by:

MAHESH MADAN MD Roll no:37 S7,ECE

INTRODUCTION
Basic operating system concepts. Introduction to linux module programming. Compile and install linux module. Determining Page faults using a linux module

Some important concepts in an operating system:


Program 1 loading Process 1 Code space data space stack heap RAM

Simple single process system

Code space= instructions Data space = global data variables Stack= function's local variables Heap= dynamic variables

CPU

Dynamic data area

Each program with 2^32=4GB instructions

Process 1

cpu

Program 1

Code space data space stack heap

Program 2

loading

Process 2 Code space data space stack heap

Program 100

Let us take machine with 32 bit architecture It is work in multiprocess environment, here We taken 100 process

Process 100

Code space data space stack heap


Virtual memory with 100*4GB (virtual RAM)

Paging and page fault


How we can have 1GB RAM(physical) instead of 100*4GB RAM?
Process 1 Code space data space stack heap Process 2 Code space data space stack heap Paging unit inside CPU(TLB) Physical RAM(1GB) Kernel Space (code + data) Process 1 (some part) Kernel space

Process 2 (some part)


Process 50 (some part)

User space

Process 100 Code space data space stack heap HDD

Paging process:
Entry 1 Inside CPU (TLB) protection Entry 2 Entry 3 Entry 4 Entry 5 Entry 2^10 RAM

Present/absent

Bit 1

Bit 2

Page table entry add 10bit

Page frame number 20 bit

Major fault: process exist, but no page table entry. Minor fault: table entry exist but not in TLB/ protection case

What is structure of an operating system?

Device driver interface

Operating system(kernel) is a software that manage different process and different devices. Here process get services from kernel via system calls and to manage devices(all hardware parts) we need device drivers.

A process = program code in a memory (RAM) + process management data Structure( can be called as task structure) Here only kernel can access the task structure. Using this data structure kernel will schedule each process, manage all hardware services to each process, manage all system calls, etc.

In linux all I/0 devices are accessed via Virtual File System(VFS).

Character device driver MOV P0,#45H VFS Block device driver

Keyboard, Printer, etc

HDD, NIC, etc

Character devices are slow devices(by each bytes). Block devices are very high speed devices(block of 512 bytes)

In Linux we have below task structure definition, which is circular-doubly Linked list. struct task_struct { volatile Long state; int pid, pgrp; // using pid kernel will identify each process// int min_flt, maj_flt; struct file * fd[]; struct task_struct *next_task; //used for implementing doubly struct task_struct *prev_task; linked list// next_task (struct task_struct *); prev_task(struct task_struct *); ---------------}; Kernel and modules Kernel=base kernel + modules; Linux uses monolithical kernel architecture (modules can be added), modules can dynamically added and removed. Modules can be for software purposes and device driver purpose.

Let us write a linux module


Hello world program
#include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_INFO */ MODULE_LICENSE("GPL"); MODULE_AUTHOR(Sankar"); int init_module(void) { printk(KERN_INFO "Hello world .\n"); /* * A non 0 return means init_module failed; module can't be loaded. */ return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world.\n"); }

Page fault program:


What does program do? It capture PID, number of major and minor page faults of all process by travel via task data structure. Then put this data in a file inside /proc directory (after creating the file ).

Steps in compiling and Installing a module: 1)Create a makefile for kernel build system. Then place it in our module source directory 2)Execute make command and build the driver module(get *.ko file). 3)Insert it with base kernel by executing insmod command. 4)See program out put. 5)Remove our module by executing rmmod command.

CONCLUSION
We have studied memory management and process management in an operating system. with emphasis on linux process management. We can now write a linux driver module, compile and install it. We have captured number of page fault(both minor and major) of all process in linux based system. The observation done here is that higher the number of processes running in user space, the higher the probability of occurrence of page faults

References
Robert Love, Linux Kernel Development hardwar (says more about kernel data structures) Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman. Linux Device Drivers Bovet, Daniel P. and Cesate, Marco. Understanding the Linux Kernel. (more about hardware aspects of linux kernel)

You might also like