Linux kernen Version 2.4.20, 2.5.59 11 arch. DIKU Intel, SMP.. NEL, Kernel, 2003.2.5-1 -
Linux processer Processer User mode/kernel mode. Kernel threads Processer/tråde. fork(), clone(), shmem etc. Parent child. NEL, Kernel, 2003.2.5-2 -
Synkronisering Reentrant kerne Reentrante funktioner. Låse Afbrydelser (også i kerne mode) Preemptable kerne. Lukke for afbrydelser. Semaforer Spin locks Deadlocks SMP Hyperthreading, NUMA Zones. NEL, Kernel, 2003.2.5-3 -
Hardware. NEL, Kernel, 2003.2.5-4 -
Oversigt over kernen. NEL, Kernel, 2003.2.5-5 -
Hvorfor virtuelt lager Flere samtidige processer Kan køre programmer kun delvist i RAM. Processer deler fysisk lager Processer kan dele lagerbillede (pgm, lib mm.) Programmer er relokerbare (i fysisk lager) Programmører kan skrive maskinuafhængig kode). NEL, Kernel, 2003.2.5-6 -
Memory Management Demand Paging Swapping Physical and Virtual Addressing Modes Kmalloc On alpha: different areas.. NEL, Kernel, 2003.2.5-7 -
Memory Management 2. NEL, Kernel, 2003.2.5-8 -
Memory Management 3 Large Address Spaces The operating system makes the system appear as if it has a larger amount of memory than it actually has. Protection Each process in the system has its own virtual address space. Areas of memory protected against writing. Memory Mapping In memory mapping, the contents of a file are linked directly into the virtual address space of a process. Fair Physical Memory Allocation The memory management subsystem allows each running process in the system a fair share of the physical memory of the system, Shared Virtual Memory For e.g. text segments, dynamic libraries, IPC.. NEL, Kernel, 2003.2.5-9 -
Data strukturer Task List Scheduleren vedligeholder en blok data for hver aktive process. Disse blokke gemmes i lænket liste. current er den kørende process Memory Map Memory manageren gemmer et map fra virtuelle til fysiske adresser I-nodes Det virtulelle filsystem bruger indexnoder (i-noder) til at repræsentere filer i et logisk filsystem (dentry). Kan deles mellem processer. Hvordan datastrukturerne hænger sammen Alle datastrukturer kan nås fra process schedulerens task list.. NEL, Kernel, 2003.2.5-10 -
Caches Buffer Cache The buffer cache contains data buffers that are used by the block device drivers. Page Cache Used to cache the logical contents of a file a page at a time. Swap Cache Only modified (or dirty ) pages are saved in the swap file. Hardware Caches TLB: Translation Look-aside Buffers.. NEL, Kernel, 2003.2.5-11 -
Linux Page Tables VIRTUAL ADDRESS Level 1 Level 2 Level 3 Byte within page Level 1 Level 2 Level 3 Page Table Page Table Page Table Physical Page PFN PFN PFN PGD. NEL, Kernel, 2003.2.5-12 -
Page Allocation Buddy free_area PHYSICAL MEMORY 5 56 mem_map_t mem_map_t 4 mem_map_t 0 4 3 2 1 0 map map map map 8 7 6 5 4 3 2 1 Free PFN 0 PFN. NEL, Kernel, 2003.2.5-13 -
Buddy system simple, efficient /* * Buddy system. Hairy. You really aren t * expected to understand this * * Hint: -mask = 1+~mask */ Ingo, nov 2001: in the past couple of years the buddy allocator has started to show limitations that are hurting performance and flexibility.. NEL, Kernel, 2003.2.5-14 -
Slab allocating slab.c: The memory is organized in caches, one cache for each object type. (e.g. inode cache, dentry cache, buffer head, vm area struct) Each cache consists out of many slabs (they are small (usually one page long) and always contiguous), and each slab contains multiple initialized objects.. NEL, Kernel, 2003.2.5-15 -
Zoned Buddy allocator ZONE DMA < 16 MB ISA DMA capable memory ZONE NORMAL 16-896 MB direct mapped by the kernel ZONE HIGHMEM > 896 MB only page cache and user processes. NEL, Kernel, 2003.2.5-16 -
Areas of VM Processes Virtual Memory Virtual Area vm_area_struct vm_end vm_start vm_flags vm_inode vm_ops vm_next Virtual Memory Operations open() close() unmap() protect() sync() advise() nopage() wppage() swapout() swapin(). NEL, Kernel, 2003.2.5-17 -
Processes and Files task_struct fs_struct count umask *root 0x022 inode fs *pwd files inode files_struct count close_on_exec open_fs fd[0] fd[1] fd[255] file f_mode f_pos f_flags f_count f_owner f_inode f_op f_version inode file operation routines. NEL, Kernel, 2003.2.5-18 -
Processes and Files Processes Virtual Memory task_struct mm_struct vm_area_struct mm count pgd vm_end vm_start vm_flags Data vm_inode vm_ops 0x8059BB8 mmap mmap_avl vm_next mmap_sem vm_area_struct Code vm_end vm_start vm_flags 0x8048000 vm_inode vm_ops vm_next 0x0000000 What happens when a process allocates memory? What happens when a process access memory?. NEL, Kernel, 2003.2.5-19 -
ELF ELF Executable Image e_ident e_entry e_phoff e_phentsize e_phnum E L F 0x8048090 52 32 2 Physical Header Physical Header p_type p_offset p_vaddr p_filesz p_memsz p_flags p_type p_offset p_vaddr p_filesz p_memsz p_flags PT_LOAD 0 0x8048000 68532 68532 PF_R, PF_X PT_LOAD 68536 0x8059BB8 2200 4248 PF_R, PF_W Code Data. NEL, Kernel, 2003.2.5-20 -
Booting POST LILO (fx) Kerne init Sys V init.. NEL, Kernel, 2003.2.5-21 -
Obligatoriske opgaver Exercise 1 /proc filsystem. NEL, Kernel, 2003.2.5-22 -
Projects 1. linuxbios 2. kernel memory allocation 3. I/O scheduler, non elevator 4. Block Layer redesign 5. User level filesystems.. NEL, Kernel, 2003.2.5-23 -