1 / 30

What Is T he Linux Kernel ? A newbie’s guide to the Kernel

What Is T he Linux Kernel ? A newbie’s guide to the Kernel. Balaji V ijalabv@yahoo.com. Evolution of Operating Systems. Before Multiprogramming “Jobs”, “Offline” Multiprogramming Spooling Timesharing CTSS MULTICS. Minix. Unix becomes proprietary  Tanenbaum writes from scratch

jorryn
Download Presentation

What Is T he Linux Kernel ? A newbie’s guide to the Kernel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Is The Linux Kernel ?A newbie’s guide to the Kernel Balaji V ijalabv@yahoo.com

  2. Evolution of Operating Systems • Before Multiprogramming • “Jobs”, “Offline” • Multiprogramming • Spooling • Timesharing • CTSS • MULTICS

  3. Minix • Unix becomes proprietary  • Tanenbaum writes from scratch • Unix-like from outside • Readable & teachable • USENET group gets popular • New suggestions, ideas and code offered • Finally, Linux is born 

  4. Architecture

  5. Flames on the USENET

  6. User Mode Vs Kernel Mode • System call Kernel works on behalfof process

  7. Naming Conventions • Words separated by ‘_’ • Wait_queue • Pointer “ptr”, p_ • p_cptr

  8. Process • What is a process ? • Multiprocessing Operating System • task_struct • State – Running, waiting, Zombie, stopped • Scheduling Information • Pid • Links parent, sibling

  9. Process (contd) • … • Identifiers – uid, gid, effective, FS, saved • Timers – time since start, alarm • Filesystem – VFS inode pointer • root directory, alternate root, pwd • Virtual Memory • Processor Specific contexts • sig

  10. {Process} • Hash Table – pidhash[] • extern struct task_struct *pidhash[PIDHASH_SZ]; • find_task_pid() • pidhash_next(), pidhash_prev() • hash_pid() unhash_pid() • Circular Doubly Linked List • Task • Pointers current, running • Lock - tasklist_lock

  11. Scheduling • Preemption • Policy • tq_struct • Priority • rt_priority • States

  12. format next next next count count count load_bin() load_bin() load_bin() coredump() coredump() coredump() Process Image • Extendible Link Format (ELF) • Program Code • Program Data • Stack • Header Table • #!/usr/bin/wish • Shared Libraries

  13. ELF

  14. Process Creation • init & init_task • fork(),clone()

  15. System Calls in i386 • 2 classes of Interrupts • Exceptions • Interrupts • Vector • HIGHEST Faults except debug faults . Trap instructions INTO, INT n, INT 3 . Debug traps for this instruction . Debug traps for next instruction . NMI interrupt • LOWEST INTR interrupt

  16. How Linux Uses Interrupts and Exceptions • int 0x80 • syscallX() • Setup the Stack frame & _system_call() • _syscall1(int,setuid,uid_t,uid);_setuid: subl $4,%exp pushl %ebx . . . int $0x80 . . ret

  17. ..contd • _system_call() • _ret_from_system_call() • Scheduler ? • Error ?

  18. 31 bh_active 0 . . . . . . . . . 31 bh_mask 0 Bottom Half Handlers • Why ? 0 1 31

  19. How to Add your System Call

  20. Inter Process Communication • Why ? • Signals • Kill –l • SIGSTOP, SIGKILL • Core dump ! • Why only 32 signals ?

  21. The File System • Types • Uniform Interface • inode • Directory • Links • The Minix Filesystem • Max size - 64MB • Limited Directory Entries • Maximal File name was 14 chars • Virtual Filesystem

  22. Extended File System • EXT • File size 2GB, 255 characters File name • Drawbacks • No separate access, date modification • Fragmented • Xia Filesystem • 3 Time stamps • Large Partitions

  23. Virtual File System • Indirection Layer • Structure • Kernel Table • inode Descriptor • Open file Descriptor

  24. The Second Extended File System • Motivation • Fix bugs and provide Advanced Semantics • Robust • New Features

  25. VFS at work • Attaching File system int init_ext2_fs(void) { return register_filesystem(&ext2_fs_type); } static struct file_system_type ext2_fs_type = { ext2_read_super, "ext2", 1, NULL }; static struct file_system_type sysv_fs_type[3] = { {sysv_read_super, "xenix", 1, NULL}, {sysv_read_super, "sysv", 1, NULL}, {sysv_read_super, "coherent", 1, NULL} }; • Connect • ext2_read_super() • super_block, super_operations

  26. VFS at work .. contd struct super_operations { void (*read_inode) (struct inode *); int (*notify_change)(struct inode*,struct iattr*); void (*write_inode) (struct inode *); ... void (*statfs)(struct super_block*, struct statfs*,int); int (*remount_fs) (struct super_block *, int *, char *); }; static struct super_operations ext2_sops = { ext2_read_inode, NULL, ... ext2_remount };

  27. VFS at work ..contd • Accessing a File • namei() • Access the inode • Inode Operations • struct inode_operations • struct file_operations

  28. Modules • Why ? • Commands insmod rmmod • Kernel rights • References to Kernel Symbol table • Module Stacking

  29. Module Loading • 2 ways to load • insmod • Demand loading • Relocatable - /lib/modules/version • Exported Symbols • Module init and cleanup list • References

  30. next next ref ref symtab symtab “vfat” “fat” *cleanup() *cleanup() size size n_sym n_sym n_refs n_refs symbols symbols refs refs Module Data Structure module_list

More Related