Computer Organization CS224 Fall 2012 Lesson 12. Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data.

Slides:



Advertisements
Similar presentations
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 2 Instructions: Language of the Computer.
Advertisements

The University of Adelaide, School of Computer Science
The University of Adelaide, School of Computer Science
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
MIPS ISA-II: Procedure Calls & Program Assembly. (2) Module Outline Review ISA and understand instruction encodings Arithmetic and Logical Instructions.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Lecture 8 Sept 23 Completion of Ch 2 translating procedure into MIPS role of compilers, assemblers, linking, loading etc. pitfalls, conclusions Chapter.
Wannabe Lecturer Alexandre Joly inst.eecs.berkeley.edu/~cs61c-te
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
CS3350B Computer Architecture Winter 2015 Lecture 4
Lecture 8: MIPS Instruction Set
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Linkage Editors Difference between a linkage editor and a linking loader: Linking loader performs all linking and relocation operations, including automatic.
Chapter 3 Loaders and Linkers
Loaders and Linkers CS 230 이준원. 2 Overview assembler –generates an object code in a predefined format »COFF (common object file format) »ELF (executable.
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
1 Starting a Program The 4 stages that take a C++ program (or any high-level programming language) and execute it in internal memory are: Compiler - C++
Lec 9Systems Architecture1 Systems Architecture Lecture 9: Assemblers, Linkers, and Loaders Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some.
Assembly Process. Machine Code Generation Assembling a program entails translating the assembly language into binary machine code This requires more than.
 Procedures (subroutines) allow the programmer to structure programs making them : › easier to understand and debug and › allowing code to be reused.
Loader- Machine Independent Loader Features
MIPS Assembler Programming
1 Lecture 5: MIPS Examples Today’s topics:  the compilation process  full example – sort in C Reminder: 2 nd assignment will be posted later today.
CS 61C L14Introduction to MIPS: Instruction Representation II (1) Garcia, Spring 2004 © UCB Roy Wang inst.eecs.berkeley.edu/~cs61c-tf inst.eecs.berkeley.edu/~cs61c.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Software Development and Software Loading in Embedded Systems.
Computer Architecture and Design – ECEN 350 Part 4 [Some slides adapted from M. Irwin, D. Paterson and others]
MIPS coding. SPIM Some links can be found such as:
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
Topic 2d High-Level languages and Systems Software
C OMPUTER A RCHITECTURE & O RGANIZATION Assemblers and Compilers Engr. Umbreen Sabir Computer Engineering Department, University of Engg. & Technology.
5-1 Chapter 5 - Languages and the Machine Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /29/2013 Lecture 13: Compile-Link-Load Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
CS412/413 Introduction to Compilers and Translators April 14, 1999 Lecture 29: Linking and loading.
Chapter 2 — Instructions: Language of the Computer — 1 Branch Addressing Branch instructions specify – Opcode, two registers, target address Most branch.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 31 Memory Management.
1 Lecture 6: Assembly Programs Today’s topics:  Large constants  The compilation process  A full example  Intro to the MARS simulator.
CSc 453 Linking and Loading
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 14, 15 Addressing Mode.
Chapter 2 Instructions: Language of the Computer.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface Chapter 2 Instructions: Language of the Computer.
Lecture 3 Translation.
Assemblers, linkers, loaders
Computer Architecture & Operations I
Lecture 6: Assembly Programs
Instruction Sets Chapter 2
The University of Adelaide, School of Computer Science
Linking & Loading.
Parallel Shared Memory
Program Execution in Linux
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
CS-3013 Operating Systems C-term 2008
Topic 2e High-Level languages and Systems Software
Lecture 4: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer part 2
Computer Organization and Design Assembly & Compilation
Linking & Loading CS-502 Operating Systems
Computer Architecture
Lecture 6: Assembly Programs
Program Execution in Linux
10/6: Lecture Topics C Brainteaser More on Procedure Call
Program Assembly.
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
Presentation transcript:

Computer Organization CS224 Fall 2012 Lesson 12

Synchronization  Two processors or threads sharing an area of memory l P1 writes, then P2 reads l Data race if P1 and P2 don’t synchronize -Result depends of order of accesses !!   Software synchronization routines needed l Lock and unlock, etc. l To implement mutual exclusion to shared memory  Hardware support required l Atomic read-and-modify memory operation l No other access to the location allowed between the read and write l Used for e.g. atomic swap of register ↔ memory l Could be a single instruction (as in some processors) l Or an atomic pair of instructions (as in MIPS and others) §2.11 Parallelism and Instructions: Synchronization

Atomic Exchange Support  Atomic exchange (atomic swap) – interchanges a value in a register for a value in memory atomically, i.e., as one operation (instruction) l Implementing an atomic exchange would require both a memory read and a memory write in a single, uninterruptable instruction. An alternative is to have a pair of specially configured instructions ll $t1, 0($s1)#load linked sc $t0, 0($s1)#store conditional

Atomic Exchange with ll and sc  If the contents of the memory location specified by the ll are changed before the sc to the same address occurs, the sc fails (returns a zero) try: add $t0, $zero, $s4#$t0=$s4 (exchange value) ll $t1, 0($s1)#load memory value to $t1 sc $t0, 0($s1)#try to store exchange #value to memory, if fail #$t0 will be 0 beq $t0, $zero, try#try again on failure add $s4, $zero, $t1#load value in $s4  If the value in memory between the ll and the sc instructions changes, then sc returns a 0 in $t0 causing the code sequence to try again.

The C Code Translation Hierarchy C program compiler assembly code assembler object code library routines executable linkerloader memory machine code §2.12 Translating and Starting a Program

Assembler Pseudoinstructions  Most assembler instructions represent machine instructions one-to-one  Pseudoinstructions: figments of the assembler’s imagination move $t0, $t1 → add $t0, $zero, $t1 blt $t0, $t1, L → slt $at, $t0, $t1 bne $at, $zero, L l $at (register 1): assembler temporary

Producing an Object Code Module  Assembler (or compiler) translates program into machine instructions, makes an object module  Provides information for building a complete program from the pieces l Header: described contents of object module l Text segment: translated instructions l Static data segment: data allocated for the life of the program l Relocation info: for contents that depend on absolute location of loaded program l Symbol table: global definitions and external refs l Debug info: for associating with source code

Linking Object Modules  Produces an executable image (.exe file) 1.Merges segments 2.Resolve labels (determine their addresses) 3.Patch location-dependent and external refs  Could leave location dependencies for fixing later with a relocating loader l But with virtual memory, no need to do this l Program can be loaded into absolute location in virtual memory space

Loading a Program  Load from image file on disk into memory 1.Read header to determine segment sizes for text and data 2.Create virtual address space (large enough for text and data) 3.Copy text and initialized data into memory 4.Copy parameters for main program (if any) onto stack 5.Initialize registers (including $sp, $fp, $gp) 6.Jump to startup routine -Copies arguments to $a0, … and calls main -When main returns, do exit syscall

Dynamic Linking  Only link/load library procedure when it is called l Requires procedure code to be relocatable l Avoids image bloat caused by static linking of all (transitively) referenced libraries l Automatically picks up new library versions

Lazy Linkage Indirection table Stub: loads routine ID, jumps to linker/loader Linker/loader code Dynamically mapped code

Starting Java Applications Simple portable instruction set for the JVM Interprets bytecodes Compiles bytecodes of “hot” methods into native code for host machine