lecture08

lecture08 - CS140 - Winter 2008 Today's Big Adventure CS...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS140 - Winter 2008 1 CS 140: Operating Systems Lecture 8: Linking Mendel Rosenblum Today’s Big Adventure ± Linking how to name and refer to things that don’t exist yet how to merge separate name spaces into a cohesive whole ± Readings man a.out & elf on a Solaris machine. run “nm” or “objdump” on a few .o and a.out files. f.c gcc f.s as c.c gcc c.s as f.o c.o ld a.out Linking as our first naming system ± Naming = very deep theme that comes up everywhere Naming system: maps names to values ± Examples: Linking: Where is printf? How to refer to it? How to deal with synonyms? What if it doesn’t exist Virtual memory address (name) resolved to physical address (value) using page table file systems: translating file and directory names to disk locations, organizing names so you can navigate, … mit.edu resolved to 18.26.0.1 using DNS table street names: translating (elk, pine, …) vs (1st, 2nd, …) to actual location your name resolved to grade (value) using spreadsheet Perspectives on information in memory ± Programming language view: instructions: specify operations to perform variables: operands that can change over time constants: operands that never change ± Changeability view (for sharing): read only: code, constants (1 copy for all processes) read and write: variables (each process gets own copy) ± Addresses versus data addresses used to locate something: if you move it, must update address examples: linkers, garbage collectors, changing apartment ± Binding time: when is a value determined/computed? Early to late: compile time, link time, load time, runtime add r1 , r2 , 1 How is a process specified? ± Executable file: the linker/OS interface. What is code? What is data? Where should they live? ± Linker builds ex from object files: code data int a; foo: ret code=110 data=8, ... “foo.o” foo: call 0 ret bar: ret l: “hello world\n” 0 foo: 0: T bar: 40: t 4: printf 40 Header: code/data size, symtab offset Object code: instructions and data gen’d by compiler Symbol table: external defs (exported objects in file) external refs (global syms used in file) How is a process created? ± On Unix systems, read by “loader” reads all code/data segs into buffer cache; maps code (read only) and initialized data (r/w) into addr space fakes process state to look like switched out ± Big optimization fun: Zero-initialized data does not need to be read in. Demand load: wait until code used before get from disk Copies of same program running? Share code Multiple programs use same routines: share code (harder) ld loader Cache Compile time runtime
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS140 - Winter 2008 2 What does a process look like? (Unix) ± Process address space divided into “segments” text (code), data, heap (dynamic data), and stack Why? (1) different allocation patterns; (2) separate code/data heap stack code initialized data address 2^n-1 address >= 0 Who builds what?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2008 for the course CS 140 taught by Professor Rosenblum during the Winter '08 term at Stanford.

Page1 / 5

lecture08 - CS140 - Winter 2008 Today's Big Adventure CS...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online