Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?

Slides:



Advertisements
Similar presentations
The ‘process’ abstraction
Advertisements

Introduction to Operating Systems CS-2301 B-term Introduction to Operating Systems CS-2301, System Programming for Non-majors (Slides include materials.
The ‘thread’ abstraction A look at the distinction between the idea of a ‘process’ and the concept of a ‘thread’
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
Linux Memory Management High-Level versus Low-Level.
“Virtual” Memory How does the OS kernel provide “private” and “shared” memory areas to multiple concurrent processes?
Introduction to Kernel
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Linux Memory Issues Introduction. Some Architecture History 8080 (late-1970s) 16-bit address (64-KB) 8086 (early-1980s) 20-bit address (1-MB) (mid-’80s)
The kernel’s task list Introduction to process descriptors and their related data-structures for Linux kernel version
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Memory Management Chapter 5.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
1 Last Class: Introduction Operating system = interface between user & architecture Importance of OS OS history: Change is only constant User-level Applications.
A device-driver for Video Memory Introduction to basic principles of the PC’s graphics display.
Access to High Memory Introduction to the kernel functions ‘kmap()’ and ‘kunmap()
The ‘mmap()’ method Adding the ‘mmap()’ capability to our ‘vram.c’ device-driver.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
Chapter 6 - Implementing Processes, Threads and Resources Kris Hansen Shelby Davis Jeffery Brass 3/7/05 & 3/9/05 Kris Hansen Shelby Davis Jeffery Brass.
1 OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Computer Organization
ITEC 325 Lecture 29 Memory(6). Review P2 assigned Exam 2 next Friday Demand paging –Page faults –TLB intro.
Protection and the Kernel: Mode, Space, and Context.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Laface Operating System Design Booting a PC to run a kernel from Low memory VGA display.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
1 CMSC421: Principles of Operating Systems Nilanjan Banerjee Principles of Operating Systems Assistant Professor, University of Maryland Baltimore County.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Windows Memory Architecture 井民全製作. A Process ’ s Virtual Address Space Every Process has its own private virtual address 32-bits processes  4 GB address.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Process Description and Control
1.4 Hardware Review. CPU  Fetch-decode-execute cycle 1. Fetch 2. Bump PC 3. Decode 4. Determine operand addr (if necessary) 5. Fetch operand from memory.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Introduction to Operating Systems and Concurrency.
4300 Lines Added 1800 Lines Removed 1500 Lines Modified PER DAY DURING SUSE Lab.
University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.
Processes and Virtual Memory
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Logical & Physical Address Nihal Güngör. Logical Address In simplest terms, an address generated by the CPU is known as a logical address. Logical addresses.
What is a Process ? A program in execution.
Linux Boot Process on the Raspberry Pi 2 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis,
OPERATING SYSTEM REVIEW. System Software The programs that control and maintain the operation of the computer and its devices The two parts of system.
Introduction to Operating Systems Concepts
Introduction to Kernel
Operating System Review
Process Management Process Concept Why only the global variables?
CSC 322 Operating Systems Concepts Lecture - 12: by
Mechanism: Address Translation
Process Realization In OS
Operating System Review
Virtual Memory: Systems
Pentium/Linux Memory System
Operating System Review
Today’s agenda Hardware architecture and runtime system
Memory Management Overview
Pentium III / Linux Memory System April 4, 2000
Operating System Chapter 7. Memory Management
Virtual Memory: Systems CSCI 380: Operating Systems
CS 105 “Tour of the Black Holes of Computing!”
Processes in Unix and Windows
CS 105 “Tour of the Black Holes of Computing!”
Processes David Ferry, Chris Gill, Brian Kocoloski
Buddy Allocation CS 161: Lecture 5 2/11/19.
Mechanism: Address Translation
Virtual Memory and Paging
Presentation transcript:

Linux Memory Management How does the Linux kernel keep track of the Virtual Memory Areas that each process uses?

Hardware/Firmware/Software The PC ‘s memory management system is a cooperative venture involving hardware, software, and firmware The hardware and firmware would be the same no matter which Operating System we choose to run (i.e., Linux or Windows) An operating system utilizes the hardware (in its own unique way) to provide multiple processes with protected memory-spaces

The Linux/x86 scheme Let’s focus on the particular approach that Linux takes in utilizing the Intel x86 CPU’s memory-addressing capabilities There are two conceptual levels (because “processor independence” is a goal Linux strives for): much of the Linux ‘mm’ code runs on almost any CPU, yet there’s some code is (unavoidably) specific to the x86

Source-code organization High-level ‘mm’ code is processor-independent (It’s in the ‘/usr/src/linux/mm’ subdirectory) Low-level ‘mm’ code is processor-specific (It’s in the ‘/usr/src/linux/arch/’ subdirectories) i386/mmppc/mmmips/mmalpha/mm...

Our machines have 1GB of RAM Main Memory (1 GB) Intel Pentium CPU 0x x3FFFFFFF system bus NICVGA FIFO (4 KB) VRAM (32 MB) some devices have RAM, too

Booting up At power-on, the CPU sees only 1-MB of the physical memory (including the ROMs) The OS initialization code must “activate” the processor’s “protected-mode” MMU so that all the ‘Extended Memory’ (including device-memory) will become addressable Finally the OS enables “virtual memory” to allow the illusion of a 4-GB address-space

Kernel memory-mapping Virtual Memory 0x xFFFFFFFF 4-GB Physical memory 0x x3FFFFFFF 1-GB 896-MB 0xC display memory device memory mappings

Application memory-mapping kernel space user space text data stack text data stack physical memory virtual memory mappings 3-GB

‘mm_struct’ Each application-process uses a different mapping of physical memory regions into the Pentium’s “virtual” address-space, so one process can’t access memory owned by another process (i.e., private regions) The OS switches these mapping when it suspends one process to resume another Each task’s mapping is in its ‘task_struct’

How Linux tracks mappings task_struct mm mm_struct pgd start, end, etc vm_area_struct start, end, etc vm_area_struct start, end, etc vm_area_struct start, end, etc vm_area_struct vma mapping-tables

What does ‘malloc()’ do? The standard C runtime environment lets a user program allocate additional memory void *malloc( unsigned long nbytes ); This memory is released after being used void free( void *vaddr ); Using suitable kernel modules we can see how the kernel keeps track of this memory

‘mm.c’ and ‘vma.c’ These modules create pseudo-files that allow us to view memory-management information associated with a user task We can read such pseudo-files before, and after, we perform a call to ‘malloc()’ Our ‘domalloc.cpp’ demo illistrates this We can compare the file-outputs to see what changes occurred in the kernel data

When a program ‘forks()’ We already know how new processes get created in the UNIX/Linux environment (i.e., via the ‘fork()’ function or system-call) A child-process gets constructed using the same code and data as its parent-process Yet each task’s memory-regions are kept ‘private’ (i.e., accessible to it alone) So how exactly is this feat achieved?

user space Similar memory-mappings kernel space user space text data stack parent-process kernel space text data stack child-process text data stack physical memory virtual memory

Another demo You could write a program, similar to our ‘domalloc.cpp’ demo, that would let a user compare the list of memory-regions which a parent-process owns and the list that its child-process has inherited

In-class exercise Write an application program that allows a user to compare BOTH the ‘mm_struct’ and the ‘vm_area_struct’ information that belong to a parent-process and to its child You can use our ‘mm.c’ and ‘vma.c’ Linux kernel modules, and you can imitate the programming ideas used in ‘domalloc.cpp’ TURN IN printouts of your code and output