Download presentation
Presentation is loading. Please wait.
1
Special Topics on Operating System
R. C. Chang
2
Tentative Topics Linux Internal Microkernels Window CE Internal
Inferno Other Embedded Operating Systems
3
Trends of Operating System
Server : UNIX/Linux, Windows/NT Desktop : Windows 98/NT, UNIX/Linux Embedded : WIN/CE, Inferno,VxWork, JINI,…
4
Operating System Structure
Monolithic Kernel UNIX, Windows/98, Linux First Generation Microkernel Mach, Chorus,… Second Generation Microkernel L4, Exokernel,...
5
Linux Internal Text Book: The Linux Kernel by David A. Rusling, (Please Download the book from Internet) Reference Books: Linux Kernel Internals (Second Edition) by M. Beck et al., Addison-Wesley, 1998
6
Hardware Basics A typical PC Motherboard
7
PC Hardware PC, SP, PS Memory Bus Controllers and Peripherals
D-Cache, I-Cache Cache Coherence Bus ISA, PCI Controllers and Peripherals IDE, SCSI, NIC,… Address Space
8
Software Basics What is an operating system? Memory management
Processes $ ps PID TTY STAT TIME COMMAND 158 pRe :00 -bash 174 pRe :00 sh /usr/X11R6/bin/startx 175 pRe :00 xinit /usr/X11R6/lib/X11/xinit/xinitrc -- 178 pRe 1 N 0:00 bowman 182 pRe 1 N 0:01 rxvt -geometry 120x35 -fg white -bg black 184 pRe 1 < 0:00 xclock -bg grey -geometry padding 0 185 pRe 1 < 0:00 xload -bg grey -geometry label xload 187 pp :26 /bin/bash 202 pRe 1 N 0:00 rxvt -geometry 120x35 -fg white -bg black 203 ppc :00 /bin/bash 1796 pRe 1 N 0:00 rxvt -geometry 120x35 -fg white -bg black 1797 v :00 /bin/bash 3056 pp6 3 < 0:02 emacs intro/introduction.tex 3270 pp :00 ps $
9
Device Drivers The Filesystems Controller Chips EXT2,CDROM,...
NCR810 SCSI The Filesystems EXT2,CDROM,...
10
Kernel Data Structures
Link Lists Hash Tables Caches Abstract Interfaces /proc/filessystems
11
Memory Management Virtual Memory large address space protection
memory mapping fair physical memory allocation shared virtual memory
12
An Abstract Model of VM
13
Demand Paging Load virtual pages that are currently bein used by the executing program Page fault handling Linux uses demand paging to load executable images into a processes virtual memory
14
Swapping If a process needs to bring a virtual page into physical memory and there are no free physical pages available… Clean or read-only pages --> Disacrd Dirty page --> swapping Linux uses a Least Recently Used page aging technique to choose pages
15
Physical and Virtual Addressing Modes
OS usually runs in physical address model Alpha AXP processor does not have a special physical addressing model. It divides up the memory space into several areas and designates two of them as physical address area KSEG (0xfffffc )
16
Access Control Page_Dirty, Page_ACCESSED ASM: Address Space Match
KRE: kernel mode can read URE: user mode can read PFN: Page Frame Number Page_Dirty, Page_ACCESSED V : Valid FOE: Fault on Execute FOW: Write FOR: Read
17
Caches Buffer Cache : block device drivers(hard disks)
Page Caches : Speed up access to images and data on disk. Swap Cache: only modified(dirty) pages are saved in the swap file. Hardware Caches : Data/Instruction, TLB
18
Linux Page Tables Each Platform that Linux runs on must provide
translation macro that allow the kernel to traverse the page tables for a particular processor
19
Page Allocation and Deallocation
Physical page : mem_map structure mem_map_t for each physical page(initialized at the boot time) Important fields count, age, man_nr (physical frame number) free-area vector is used to find free pages
20
Free_area data structure
Allocated groups of pages
21
Page Allocation/Deallocation
Buddy algorithm Pages are allocated in blocks which are powers of 2 in size The page deallocation code recombine pages into large blocks of free pages whenever it can
22
Memory Mapping Virtual memory is represented by an mm_structure data structure vm_area_structure
23
Demand Paging Page fault Search for vm_area_struct (AVL Tree)
If no (access illegal virtual address)--> SIGSEGV Check for type of access Decide the page in swap file or somewhere in disk if the page’ page table entry is invalid but not empty then it is in swap file nopage operation(by using page cache)
24
The Linux Page Cache
25
The Linux Page Cache Memory mapped files are read a page at a time and these pages are stored in the page cache Search through page_hash_table Linux --> single page read ahead
26
Swapping Out and Discarding Pages
Kernel Swap Daemon(kswapd) kernel thread keep enough free pages in the system started by init process and wait for kernel swap timer to periodcally expire if # of free pages > free_page_high do nothing otherwise kswapd try to reduce the number of physical pages being used by the system:
27
Swap out pages Reduce the size of the buffer and page caches
clock algorithm Swapping out System V shared memory pages update multiple page table entries Swapping out and discarding pages
28
The Swap Cache When swapping pages out, Linux avoids writing pages if it does not have to Swap cache --> a PTE for a swapped out page If a swap cache is non-zero, a page in swap file has not been modified --> no need to write the page to the swap file
29
Swapping Pages In Demand paging swapin operation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.