Process Environment. Pradipta De

Similar documents
Process Address Spaces and Binary Formats

This lecture is covered in Section 4.1 of the textbook.

ECE 598 Advanced Operating Systems Lecture 10

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 25

ECE 471 Embedded Systems Lecture 4

Applications of. Virtual Memory in. OS Design

Process Address Spaces and Binary Formats

Virtual Memory: Systems

PROCESS VIRTUAL MEMORY PART 2. CS124 Operating Systems Winter , Lecture 19

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization

Linking. Explain what ELF format is. Explain what an executable is and how it got that way. With huge thanks to Steve Chong for his notes from CS61.

Memory Management Day 2. SWE3015 Sung- hun Kim

ECE 498 Linux Assembly Language Lecture 1

COS 318: Operating Systems

Operating Systems CMPSC 473. Process Management January 29, Lecture 4 Instructor: Trent Jaeger

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

seven Virtual Memory Introduction

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

CSE 504: Compiler Design. Code Generation

CSE506: Operating Systems CSE 506: Operating Systems

Progress Report Toward a Thread-Parallel Geant4

ECE 471 Embedded Systems Lecture 5

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass.

Midterm. Median: 56, Mean: "midterm.data" using 1:2 1 / 37

Computer Systems Organization

VEOS high level design. Revision 2.1 NEC

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

CSE506: Operating Systems CSE 506: Operating Systems

Foundations of Computer Systems

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

Virtual Memory: Systems

Process Manager Overview

Compiler Drivers = GCC

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

Separate compilation. Topic 6: Runtime Environments p.1/21. CS 526 Topic 6: Runtime Environments The linkage convention

COMPILING OBJECTS AND OTHER LANGUAGE IMPLEMENTATION ISSUES. Credit: Mostly Bryant & O Hallaron

CSE 451: Operating Systems Winter Processes. Gary Kimura

Link 3. Symbols. Young W. Lim Mon. Young W. Lim Link 3. Symbols Mon 1 / 42

IA32/Linux Virtual Memory Architecture

Today s Big Adventure

Today s Big Adventure

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ...

CS5460/6460: Operating Systems. Lecture 21: Shared libraries. Anton Burtsev March, 2014

OPERATING SYSTEM. Chapter 4: Threads

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

CS 550 Operating Systems Spring Process I

Memory System Case Studies Oct. 13, 2008

A Simplistic Program Translation Scheme

www nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

Linux Memory Management

CS 3214 Computer Systems. Do not start the test until instructed to do so! printed

CSE 153 Design of Operating Systems Fall 2018

Pentium/Linux Memory System March 17, 2005

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

P6/Linux Memory System Nov 11, 2009"

Outline. Unresolved references

(Extract from the slides by Terrance E. Boult

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

Memory Addressing. Pradipta De

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers

Operating System Design and Implementation Memory Management Part III

Linking and Loading. ICS312 - Spring 2010 Machine-Level and Systems Programming. Henri Casanova

CSE506: Operating Systems CSE 506: Operating Systems

Memory Mapping. Sarah Diesburg COP5641

Compiler, Assembler, and Linker

Operating Systems 2 nd semester 2016/2017. Chapter 4: Threads

CSE506: Operating Systems CSE 506: Operating Systems

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Pointers in C. A Hands on Approach. Naveen Toppo. Hrishikesh Dewan

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Concurrency, Thread. Dongkun Shin, SKKU

Processes and Threads

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Assembly Language Programming Linkers

The Software Stack: From Assembly Language to Machine Code

Implementing Subroutines. Outline [1]

CSE 504: Compiler Design. Runtime Environments

Processes & Threads. Recap of the Last Class. Microkernel System Architecture. Layered Structure

M2 Instruction Set Architecture

Operating Systems. II. Processes

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

Memory Management. Fundamentally two related, but distinct, issues. Management of logical address space resource

Chapter 4: Threads. Chapter 4: Threads

CSE 306/506 Operating Systems Process Address Space. YoungMin Kwon

Chapter 4: Threads. Chapter 4: Threads

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

Introduction to pthreads

Basic Memory Management

Process Address Spaces and Binary Formats

ECE 598 Advanced Operating Systems Lecture 11

CNIT 127: Exploit Development. Ch 3: Shellcode. Updated

Exercise Session 7 Computer Architecture and Systems Programming

Chap 4, 5: Process. Dongkun Shin, SKKU

CS 537 Lecture 2 - Processes

Linux Fundamentals & Practice

Transcription:

Process Environment Pradipta De pradipta.de@sunykorea.ac.kr

Today s Topic Program to process How is a program loaded by the kernel How does kernel set up the process Outline Review of linking and loading Look at ELF files Process memory allocation CSE506: Process Environment 2

What is a process? A process is an instance of a program in execution Same program, multiple instances multiple processes Needs several data structures for managing resources (CPU time, mem, access to I/O ports), as well as, remember current state (initialized, running, suspended, etc.) Lightweight process A process sharing threads of execution Supported by POSIX pthread library

Process Descriptor In Linux, Ln: 1238 struct task_struct http://lxr.free-electrons.com/source/include/linux/sched.h Task_struct contains, Process state identifier, parent id, usage flags, and pointers to other structs We will focus on mm_struct

mm_struct: overview Task_struct *mm Mm_struct *mmap *mm_rb Linked List vm_area_struct vm_area_struct Red-black Tree vm_area_struct null

Executable program? Basics: compiler, linker, loader Files a.c and b.c Compiled to generate a.o and b.o Preprocessed gcc E *.c o *.i Compiled gcc S *.c Assembled gcc c test.o test.c Linker combines the *.o to generate executable Ld <options> a.o b.o o prog Shell invokes loader to load prog (code and data) into memory Execve acts as the loader function

Object files Relocatable: code and data can be combined with other relocatable object files Executable: can be directly loaded into memory and instructions can be executed Shared: special relocatable file, which can be loaded into memory dynamically

File type: Relocatable Entry point not set File type: Executable Entry point set

Relocatable File Executable file

ELF Sections Multiple sections in a ELF file.text : code.data: initialized data.bss: uninitialized data.stack: stack segment Several more not all relevant to us now Coming up.plt,.got

Stack address is assigned during loading. Stack grows downwards in memory

Library calls Static linking Dynamic linking Sections are merged to create a block of sections for each type (.text,.code, Linked at runtime

How functions are referenced Using Procedure Linkage Table.plt section has pointer to the function names Think jump table Address of the functions resolved at runtime

Process Address Space

Per process address space Each process sees a flat 32bit or 64bit address space Not absolutely true user space and kernel space Kernel mapped to high mem @0xF0100000 (3GB) Why VMA and LMA different in kernel image? Memory area contains, executable file's code, _text section_ initialized global variable, _data section_ zero page for uninitialized global variable, _bss section_ zero page for process's user-space stack additional text, data, bss section for each shared library, such as C library and dynamic linker, loaded into process address space any memory mapped file shared memory segments - any anonymous memory mappings Check memory layout of any program ldd /usr/bin/xterm Note: ld-linux-x86-64.so.2 always mapped

vm_area_struct Start and end address Memory regions are page aligned Protection flag (read, write, execute) Code (text) : no write, execute Data: write Why two representations for vm_area_struct list? Single linked list Good for processes with very few memory regions RB tree Efficient in terms of search, retrieval, insertion Tree traversal O(log n)

Sharing memory area On creating a child process (fork), Can copy each page of the parent process to the child process do we really need all the pages? Mark the pages Copy-on-Write (COW) Will make new page allocation on write

Putting It Together What is process address space? ELF Section headers loader maps it to process address space Shared libraries Address space data structures Shared address space lazy allocation CSE506: Process Environment 19