Review Saranya

Embed Size (px)

Citation preview

  • 8/6/2019 Review Saranya

    1/31

    PERFORMANCE REVIEW

    By

    G. Saranya

  • 8/6/2019 Review Saranya

    2/31

    Outline

    Linux Booting Process

    Compiling Linux Kernel

    Linux Device Driver Storage Concepts

    IPC Mechanisms

    Memory Management

  • 8/6/2019 Review Saranya

    3/31

    Linux Booting Process

  • 8/6/2019 Review Saranya

    4/31

    Compiling Linux Kernel

    Getthe Linuxlatest kernel code

    eg:linux-x.y.z.tar.bz

    To extracttar(.tar.bz) image

    #tar- xjvflinux-x.y.z.tar.bz - C /usr/src

    #cd /usr/src Conf igure kernel

    $make menuconfig

    Compile kernel

    Start compiling to create a compressed kernelimage,enter

    $make

  • 8/6/2019 Review Saranya

    5/31

    Compiling Linux Kernel

    Start compiling to kernel modules

    $make modules

    Install Kernel modules(become a rootuser,use su

    command).$su

    #make modules_install

    Install Kernel

    #make install

  • 8/6/2019 Review Saranya

    6/31

    Compiling Linux Kernel

    Create an initrd image

    type the following command atthe shell prompt

    #mkinitrd -o initrd.img-x.y.z x.y.z

    Modify Grub configuartion file -/boot/grub/menu.lst

    #vi /boot/grub/menu.lst

  • 8/6/2019 Review Saranya

    7/31

    Compiling Linux Kernel

    save and close the file.

    title ubuntu(x.y.z.fcl4.i686)

    root (hd0,0)

    kernel /boot/vmlinuz root=/dev/hdb1 r0initrd /boot/initrd.img-x.y.z

    savedefault

    boot

  • 8/6/2019 Review Saranya

    8/31

    Compiling Linux Kernel

    try outupdate-grub command to update the lines for each

    kernelin /boot/grub/menu.lst file.

    update-grub

    Reboot computer and update in to your kernel

    #reboot

  • 8/6/2019 Review Saranya

    9/31

    Device driver

    A device driveris a program that a computer's operating

    system uses to control a particular hardware device thatisattached to a computer.

  • 8/6/2019 Review Saranya

    10/31

    Kernel and User Space Communication

  • 8/6/2019 Review Saranya

    11/31

    Kernel and User Space Communication

  • 8/6/2019 Review Saranya

    12/31

    Module

    The modules can be dynamically linked to the running kernelby insmod cmd and can be unlinked by rmmod cmd.

  • 8/6/2019 Review Saranya

    13/31

    Device Driver Types

    Char Device

    Block Device

    Network Device

  • 8/6/2019 Review Saranya

    14/31

    Character Device

    Character device is one that can be accessed as a stream of

    bytes(like a file).

  • 8/6/2019 Review Saranya

    15/31

    Major and Minor Numbers

    Major numberidentifies the driver associated with the device

    Minor numberidentifies a particularinstance of a device.

  • 8/6/2019 Review Saranya

    16/31

    Sample Code

    static int eg_ioctl (structinode*,struct file *,unsigned

    int,unsigned long) { }

    static int eg_open (structinode*,struct file *) { }

    static int eg_release (structinode *,struct file *) { }

    struct file_operations={

    .read:eg_read,

    .write:eg_write,

    .open:eg_open,

    .release:eg_release,

    .ioctl:eg_ioctl,

    };

  • 8/6/2019 Review Saranya

    17/31

    Char Device Registration and Release

    function to register a char device driveris with

    register_chrdev(unsigned int major, const char name,struct

    file_operations *fops);

    function to remove your device(s) from the system is

    unregister_chrdev(unsigned int major, const char *name);

  • 8/6/2019 Review Saranya

    18/31

    Debugging Techniques

    Debugging by Printk

    Using /proc Filesystem

    gdb,kgdb

  • 8/6/2019 Review Saranya

    19/31

    Debugging by Printk

    To add your own debug message to the kernel, you can place a

    "printk()" in the kernel code.

  • 8/6/2019 Review Saranya

    20/31

    Debugging by Printk

    When using printk a loglevel gets defined.

    printk(KERN_WARNING "Help\n");. Valid loglevelsare:defined in the header

    KERN_EMERG,KERN_ALERT,KERN_CRIT,KERN_ERR, KERN_WARNING,KERN_NOTICE, KERN_INFO,KERN_DEBUG

    Changing the console_loglevel can be done by proc filesystem.

    # cat /proc/sys/kernel/printk

    7 4 1 7

    So the easiest way to change the loglevelis simply:

    #echo 8 > /proc/sys/kernel/printk

  • 8/6/2019 Review Saranya

    21/31

    Proc Filesystem

    proc f ilesystem is a virtual filesystem thatis used to export

    kernel related information to the user space.

  • 8/6/2019 Review Saranya

    22/31

    Proc Filesystem

    To create a virtual file in the /proc filesystem, use the

    create_proc_entry function. Struct proc_dir_entry

    create_proc_entry( const char *name, mode_t mode, struct

    proc_dir_entry *parent );

    To remove_proc_entry function void remove_proc_entry(

    const char *name, struct proc_dir_entry *parent );

  • 8/6/2019 Review Saranya

    23/31

    Proc Filesystem

    The Wr ite Callback function:

    You can write to a proc entry (from the userto the

    kernel) by using a write_proc function.

    int (*write_proc) ( struct file *filp, const

    char __user *buff, unsigned long len, void *data );

    The Read Callback function:

    You can read data from a proc entry (from the kernelto

    the user) by using the read_proc function.

    int (*read_proc) ( char *page, char **start,

    off_t off, int count, int *eof, void *data );

  • 8/6/2019 Review Saranya

    24/31

    Proc Filesystem

    Reading from /proc using cat command

    eg: #cat /proc/sys/net/ipv4/ip_forward

    Writing to /proc using echo cmd

    eg: #echo "1" > /proc/sys/net/ipv4/ip_forward

    #cat /proc/sys/net/ipv4/ip_forward

  • 8/6/2019 Review Saranya

    25/31

    Interrupt Handling

    Interrupt Handler

    Top and Bottom Halves Task lets and Workqueues

  • 8/6/2019 Review Saranya

    26/31

    Storage Concepts

    DAS

    NAS

    SAN RAID

  • 8/6/2019 Review Saranya

    27/31

    IPC Mechanisms

    Pipes

    Message Queues

    Shared Memory

    Synchronization Techniques:

    semaphores and mutexes spin locks

  • 8/6/2019 Review Saranya

    28/31

    Memory Management

    Virtual Memory

    Paging

    API's:

    vmalloc

    kmalloc get_free_pages

    memset

  • 8/6/2019 Review Saranya

    29/31

    Current Event

    implementing a code using msgqueues and threads

  • 8/6/2019 Review Saranya

    30/31

    Need to be Covered

    Netlink

    TCP/IP Socket-programming

  • 8/6/2019 Review Saranya

    31/31