CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Memory Addressing / Kernel Modules.

Slides:



Advertisements
Similar presentations
Virtual Memory. Invented on Manchester atlas 1962 It embodied many pioneering features, which we now take for granted. These include system features such.
Advertisements

Memory Management Unit
Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
FEATURES OF 80386: Two versions of are commonly available: 1) 80386DX
16.317: Microprocessor System Design I
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Intel MP.
OS Memory Addressing.
CSC 322 Operating Systems Concepts Lecture - 18: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Operating Systems: Segments 1 Segmentation Hardware Support single user program system: – wish somehow to relocate address 0 to after operating system.
UQC152H3 Advanced OS Memory Management under Linux.
IA-32 Processor Architecture
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
Chapter 8.3: Memory Management
Memory Management (II)
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
CS2422 Assembly Language & System Programming September 22, 2005.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2012 Lecture 15: Protected mode intro.
Protected Mode. Protected Mode (1 of 2) 4 GB addressable RAM –( to FFFFFFFFh) Each program assigned a memory partition which is protected from.
Segmentation CS 537 – Introduction to Operating Systems.
UNIT 2 Memory Management Unit and Segment Description and Paging
Intel MP (32-bit microprocessor) Designed to overcome the limits of its predecessor while maintaining the software compatibility with the.
1/2002JNM1 With 20 bits, 1,048,576 different combinations are available. Each memory location is assigned a different combination. Each memory location.
Memory Addressing in Linux  Logical Address machine language instruction location  Linear address (virtual address) a single 32 but unsigned integer.
Microprocessor system architectures – IA32 segmentation Jakub Yaghob.
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
The Pentium Processor Chapter 3 S. Dandamudi.
Linux Virtual Memory for Intel Processor
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
CS 6560 Operating System Design Lecture 8: Memory Management.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Memory Addressing in Linux (Chap. 2, Understanding the Linux Kernel) J. H. Wang Oct. 20, 2008.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
80386DX.
Memory Addressing in Linux (Chap. 2 in Understanding the Linux Kernel) J. H. Wang Oct. 15, 2009.
1 i386 Memory Management Professor Ching-Chi Hsu 1998 年 4 月.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Processes.
EFLAG Register of The The only new flag bit is the AC alignment check, used to indicate that the microprocessor has accessed a word at an odd.
Segment Descriptor Segments are areas of memory defined by a programmer and can be a code, data or stack segment. In segments need not be all the.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
CSC 660: Advanced Operating Systems
1 Microprocessors CSE Protected Mode Memory Addressing Remember using real mode addressing we were previously able to address 1M Byte of memory.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
Microprocessor and Assembly Language Addressing Models
Information Security - 2. Descriptor Tables Descriptors are stored in three tables: – Global descriptor table (GDT) Maintains a list of most segments.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Synchronization.
COMP 3500 Introduction to Operating Systems Paging: Translation Look-aside Buffers (TLB) Dr. Xiao Qin Auburn University
Memory Management Paging (continued) Segmentation
Chapter 8: Main Memory Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
143A: Principles of Operating Systems Lecture 5: Address translation
Protection UQ: Explain the protection mechanism of X86 Intel family microprocessor(10 Marks)
x86 segmentation, page tables, and interrupts
System Segment Descriptor
Page Replacement Implementation Issues
Virtual Memory Partially Adapted from:
Operating Modes UQ: State and explain the operating modes of X86 family of processors. Show the mode transition diagram highlighting important features.(10.
Memory Management Paging (continued) Segmentation
CS 301 Fall 2002 Computer Organization
Microprocessor and Assembly Language Addressing Models
Page Replacement Implementation Issues
Introduction to the Intel x86’s support for “virtual” memory
Linux 운영체제 및 응용 Lecture Note 2 Memory Addressing 오상규 정보통신대학원.
Linux 운영체제 및 응용 Lecture Note 2 Memory Addressing 오상규 정보통신대학원.
Assembly Language for Intel-Based Computers, 5th Edition
Memory Management Paging (continued) Segmentation
CS444/544 Operating Systems II Virtual Memory
Presentation transcript:

CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Memory Addressing / Kernel Modules

CSC 660: Advanced Operating SystemsSlide #2 Topics 1.x86 Memory Addressing 2.Segmentation 3.Paging 4.Kernel Modules

CSC 660: Advanced Operating SystemsSlide #3 x86 Memory Address Types Logical Address –The addresses found in machine code are logical. –Consist of a segment + offset w/i that segment. Linear (Virtual) Address –Single 32-bit integer. –Translated by paging unit into a physical address. Physical Address –Used to address memory cells in memory chips.

CSC 660: Advanced Operating SystemsSlide #4 Segment Registers Six registers: cs, ss, ds, es, fs, gs –contain 16-bit segment selector fields –3 segment registers are special purpose (cs, ss, ds) cs: points to code segment –Also includes 2-bit Current Privilege Level (CPL) –CPL is the ring value (ring 0 is kernel, 3 is user) ss: points to stack segment ds: points to data segment

CSC 660: Advanced Operating SystemsSlide #5 Segment Descriptors Segment descriptor represents a segment –Base: 32-bit linear segment initial address –Limit: 20-bit segment length (usually in 4K pages, but in bytes if granularity flag cleared.) –System flag: 0 if kernel data, 1 otherwise. –Type: 4-bit type (code, data, task state, LDT) –DPL: Descriptor Privilege Level, segment can only be accessed if CPL <= DPL. Segment descripors stored in –GDT: Global Descriptor Table –LDT: Local Descriptor Table (one per process)

CSC 660: Advanced Operating SystemsSlide #6 Logical to Linear Address Translation Logical Address = 16 bit segment selector + 32 bit offset Segment Selector: 13-bit index into GDT or LDT Table Indicator (TI) flag (0=GDT) Requestor Privilege Level, which is the CPL when selector used. Translation: 1. Select GDT or LTD based on TI 2. Multiply index by 8-byte desc len. 3. Lookup base in segment desc. 4. Linear = segment base + offset

CSC 660: Advanced Operating SystemsSlide #7 Linux Segmentation Linux uses segmentation only where required by x86 architecture. –Uses GDT almost exclusively. –Processes can set up their own LDTs, which is useful for Windows compatibility (WINE.) Linux segments –Kernel Code Segment (all memory, DPL=0) –Kernel Data Segment (all memory, DPL=0, data perms) –User Code Segment (all memory, DPL=3) –User Data Segment (all memory, DPL=3, data perms) –Task State Segment (236 bytes, one/processor) –Default LDT shared by all processes –APM/PNP support segments

CSC 660: Advanced Operating SystemsSlide #8 Linux GDT

CSC 660: Advanced Operating SystemsSlide #9 Linear to Physical Translation Handled by paging unit. –Divides memory into 4KB pages. Linear address is divided into 3 fields –Directory: most significant 10 bits –Table: middle 10 bits –Offset: least significant 12 bits Page Directory –Every active process must have a Page Directory. –cr3 register points to address of in-use PD. –Page tables are allocated when needed.

CSC 660: Advanced Operating SystemsSlide #10 x86 Paging

CSC 660: Advanced Operating SystemsSlide #11 Page Table Entries Present Flag If 0, page not in memory, so paging unit stores linear addr in cr2 and generates exception 14 (Page Fault) on access. Offset Least significant 12 bits of address. Accessed Flag Set when paging unit accesses page. Dirty Flag Set when a write operation performed on page. Read/Write Flag Protection flag: is page read-only or read/write? User/Supervisor Flag Privilege level required to access page or page table. Page Size Flag If 1, page directory entries refer to large (4MB) pages.

CSC 660: Advanced Operating SystemsSlide #12 Physical Address Extension (PAE) Allows access to 2 36 = 64GB physical RAM. Splits memory into 2 24 pages. –Page table entries expanded to handle 24-bit addressing. Page Directory Pointer Table (PDPT) –New level of Page Table with 4 entries. Linear Addresses are still 32-bits long –cr3 register points to PDPT. –PDPT: most significant 2 bits –Directory: next 9 bits –Table: next 9 bits –Offset: least significant 12 bits

CSC 660: Advanced Operating SystemsSlide #13 What are Kernel Modules? Parcels of code that can be dynamically inserted or removed from kernel at run time.

CSC 660: Advanced Operating SystemsSlide #14 Why use Kernel Modules? Ease of maintenance Compile kernel once. Build, add, and remove modules afterwards. Ease of distribution Compile single kernel for all machines. Include drivers / options as modules. Vendors can distribute drivers as modules.

CSC 660: Advanced Operating SystemsSlide #15 What modules are loaded? > lsmod | head Module Size Used by vmnet vmmon proc_intf freq_table cpufreq_userspace cpufreq_ondemand cpufreq_powersave video sony_acpi > head -3 /proc/modules vmnet Live 0xf8c3a000 vmmon Live 0xf8c85000 proc_intf Live 0xf8c2c000

CSC 660: Advanced Operating SystemsSlide #16 Loading Kernel Modules modprobe name 1.Lookup name Resolve aliases using /etc/modprobe.conf 2.Check dependencies /lib/modules/version/modules.dep Created by depmod –a 3.Load prerequisite modules with insmod 4.Load named module.

CSC 660: Advanced Operating SystemsSlide #17 Module Licensing Specified with MOD_LICENSE() macro. If an unlicensed module loaded, kernel tainted: hellomod: module license ‘unspecified’ taints kernel Options found in linux/module.h GPL Dual BSD/GPL Proprietary

CSC 660: Advanced Operating SystemsSlide #18 Why Module Licensing? From linux/module.h : 1.So modinfo can tell users if kernel is free. 2.So community can ignore bug reports including proprietary modules. 3.So vendors can do likewise based on their own policies.

CSC 660: Advanced Operating SystemsSlide #19 Init and Cleanup Kernel modules must have two functions. init_module Alternatively declare with __init attribute. Return 0 on success or module will be unloaded. Ex: register interrupt handler, add system call. cleanup_module Alternatively declare with __exit attribute Undoes whatever init_module did so module can be unloaded safely.

CSC 660: Advanced Operating SystemsSlide #20 Includes All modules need For printk need Others depending on function.

CSC 660: Advanced Operating SystemsSlide #21 References 1.Daniel P. Bovet and Marco Cesati, Understanding the Linux Kernel, 3 rd edition, O’Reilly, Robert Love, Linux Kernel Development, 2 nd edition, Prentice-Hall, Kwan Lowe, Kernel Rebuild Guide, HOWTO.html, HOWTO.html 4.Claudia Rodriguez et al, The Linux Kernel Primer, Prentice-Hall, Peter Salzman et. al., Linux Kernel Module Programming Guide, version 2.6.1, Andrew S. Tanenbaum, Modern Operating Systems, 2 nd edition, Prentice-Hall, 2001.