1 / 19

Linux kernel structure

Linux kernel structure. Kernel code structure How it boots itself All the system calls are available System is configured Process handling is available. The kernel code. Obtaining it Information at www.kernel.org ftp ftp.pr.kernel.org Usually it is in/usr/src – various directories

Download Presentation

Linux kernel structure

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. Linux kernel structure Kernel code structure How it boots itself All the system calls are available System is configured Process handling is available ICOM 5007 - Noack

  2. The kernel code • Obtaining it • Information at www.kernel.org • ftp ftp.pr.kernel.org • Usually it is in/usr/src – various directories • Most recent stable version is 2.4.19 • What it contains • The source code that compiles and links into a bootable system • The compressed version is vmlinuz • It contains all the openly available device drivers • Future drivers appear in future versions or can be compiled in the current version • Makefiles for automated configuration ICOM 5007 - Noack

  3. structure • Major directories • Arch – architecture-dependent • Documentation – read these • Drivers – all except network • Fs – the file system • Include – includes of multiple use • Init – from boot to running kernel • Ipc – IPC • Kernel – the kernel structures • Lib – libraries for the kernel • Mm – memory management • Net – the network code ICOM 5007 - Noack

  4. More structure • The auxiliary files • Makefile and rules • These explain quite a bit about kernel structure • Note – this makefile activates the others in each subdirectory • README • How to compile • Others • Casual reading – how Linux gets developed ICOM 5007 - Noack

  5. Linux is ported to these architectures ICOM 5007 - Noack

  6. View of the i386 arch area ICOM 5007 - Noack

  7. Contents of lib for the i386 • Comments • The .S are assembly language – GNU, not Microsoft • Note the individual makefile • General utilities, as you would expect ICOM 5007 - Noack

  8. The makefile for lib • Notes • The CONFIG shell variables come from the make config step • Rules.make is used • The .S.o: rule does assembly instead of compilation because of the $(AFLAGS) argument # # Makefile for i386-specific library files.. # .S.o: $(CC) $(AFLAGS) -c $< -o $*.o L_TARGET = lib.a obj-y = checksum.o old-checksum.o delay.o \ usercopy.o getuser.o \ memcpy.o strstr.o obj-$(CONFIG_X86_USE_3DNOW) += mmx.o obj-$(CONFIG_HAVE_DEC_LOCK) += dec_and_lock.o obj-$(CONFIG_DEBUG_IOVIRT) += iodebug.o include $(TOPDIR)/Rules.make ICOM 5007 - Noack

  9. A sample of GNU assembler /* unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) */ .text .align 4 .globl csum_partial pushl %esi pushl %ebx movl 20(%esp),%eax # Function arg: unsigned int sum movl 16(%esp),%ecx # Function arg: int len movl 12(%esp),%esi # Function arg: unsigned char *buff testl $2, %esi # Check alignment. jz 2f # Jump if alignment is ok. subl $2, %ecx # Alignment uses up two bytes. jae 1f # Jump if we had at least two bytes. addl $2, %ecx # ecx was < 2. Deal with it. jmp 4f ICOM 5007 - Noack

  10. Some recognizable parts of kernel • Notes • This is the i386-specific part of kernel • Note semaphore.c smp.c signal.c • Some of these files will show up in the arch-independent part also ICOM 5007 - Noack

  11. Tiny piece of kernel code from mm #if CONFIG_HIGHMEM pte_t *kmap_pte; pgprot_t kmap_prot; #define kmap_get_fixmap_pte(vaddr) \ pte_offset(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)) void __init kmap_init(void) { unsigned long kmap_vstart; /* cache the first kmap pte */ kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN); kmap_pte = kmap_get_fixmap_pte(kmap_vstart); kmap_prot = PAGE_KERNEL; } #endif /* CONFIG_HIGHMEM */ ICOM 5007 - Noack

  12. The contents of fsThis shows all the file systemssupported by Linux ICOM 5007 - Noack

  13. The non-architecture-dependentroutines of the kernel ICOM 5007 - Noack

  14. The driver repertoire in general ICOM 5007 - Noack

  15. The block device driversnote: paride contains the IDE drivers ICOM 5007 - Noack

  16. A few of the char drivers ICOM 5007 - Noack

  17. Comments - drivers • Block device drivers • All the common block devices – these include disks and anything else that is block-oriented • Character device drivers • These include the character-by-character devices – also some pseudo-devices • Note – these are architecture-independent ICOM 5007 - Noack

  18. Some things that aren’t in the kernel • Anything that isn’t in vmlinuz • Examples: • Init – it reads /etc/inittab and starts all those processes • Startup scripts – these are called up by init using inittab • Libraries and most network daemons • The kernel and the distribution are different • The distribution contains utilities and libraries for users • It contains the system installation utilities • Typical distributions are RedHat, Slackware, Suse • X-windows is part of the distribution or separately downloadable ICOM 5007 - Noack

  19. Some techniques for viewing the kernel • This is W2K and WXP – • Obviously the kernel won’t compile here, but it makes nice slides • Open with permits viewing makefiles, etc. • Documentation directory contains .txt files • Set the .txt association to word, not notepad • Viewing in Linux is a little easier • The usual gui lets you view the filesystem treewise • Clicking on individual .c, .h, .s, etc immediately displays the file in editor (emacs) • Learn to use grep and fgrep to find out where structures, etc. are defined • Learn to use du (disk usage) to get an idea of the size of the kernel ICOM 5007 - Noack

More Related