반응형

15-213 9

Lecture 09: Machine-Level Programming 5: Advanced Topics

Memory Layout x86-64 Linux Memory Layout 최대 주소 값이 00007FFFF....FF 인 이유는 x86-64에서는 47 비트를 주소에 사용하기 때문 메모리 할당은 주소의 낮은쪽이나 높은쪽에서부터 된다 Memory Allocation Example malloc으로 할당한 메모리 중에 큰 메모리는 주소값이 큰 쪽에 할당되고, 작은 메모리는 주소값이 작은 쪽에 할당됨 계속 할당하다보면 사이에 존재하는 공간이 없어진다 Buffer Overflow : Vulnerability, Protection Recall: Memory Referencing Bug Example Such problems are a BIG deal String Library Code Vulnerable Buffe..

Lecture 08: Machine-Level Programming 4: Data

Arrays Array Allocation Array Access char *p; p++; // 실제로 p = p + 1; int *ip; ip++; // c언어에서는 +1이지만 실제로 ip = ip + 4; *(ip + 2) // 아래와 같다 ip[2] ip + x // notation ip + 4x // computation &는 주소값을 반환 *( 포인터 주소 )는 해당 주소에 저장된 값을 반환 Q. *(ip + negative_value) 가능한가? A. 컴파일러는 아무 상관없이 작동할 것이다. 다만 undefined value가 찾아질 뿐.. Q. *(2 + ip) 라면 어떻게 되는가? A. 불가능할 것이다 ㅎㅎ *(ip + 2)가 가능했던 것은 컴파일러가 포인터라는 것을 알고 +2를 scale..

Lecture 07: Machine-Level Programming 3: Procedures

Mechanisms in Procedures Passing Control : 빨간색 화살표와 같이 호출되면 이동했다가 리턴되면 다시 돌아가는 Passing data : P에서 정의된 x 값이 Q에 i로 전달되고, 리턴되는 값이 다시 P로 반환되는 Memory management : C에서는 반환되면 deallocate x86-64에서는 오버헤드를 많이 줄였다 Procedures x86-64 Stack LIFO : Last In First Out x86-64 Stack: Push x86-64 Stack: Pop Coding Conventions Procedure Control Flow %rip : program counter callq instruction은 아래의 3가지 역할을 한다 decrement s..

Lecture 06: Machine-Level Programming 2: Control

Control: Condition codes Processor State (x86-64, Partial) x86-64에는 16개의 register가 존재 rsp는 stack을 나타내는 레지스터 rip는 명령문을 가리키는 레지스터 condition codes는 주어진 4개의 1 bit flag 말고도 8개가 존재 Condition Codes (Implicit Setting) CF : 너무 큰 수의 연산에서 MSB 비트에서 올림이 발생한 경우 ZF : 연산으로 인해 0의 값이 발생한 경우 SF : 두 수의 연산으로 인해 음수의 값이 발생한 경우 OF : 연산에서 overflow가 발생한 경우(positive overflow & negative overflow) Condition Codes (Explicit ..

Lecture 05: Machine-Level Programming 1: Basics

History of Intel processors and architectures Intel x86 Processors Complex instruction set computer (CISC) Many different instructions with many different formats Hard to match performance of Reduced Instruction Set Computers (RISC) 2015 State of the Art Core i7 Broadwell 2015 DDR : DRAM (메인 메모리)로 이어진다 PCI : Peripheral Devices로 이어진다 SATA : 여러 디스크로 이어진다 Ethernet : 네트워크로 이어진다 Our Coverage IA32 The..

Lecture 04: Floating Point

K Fractional Binary Numbers Representable Numbers Limitation 1 - Can only exactly represent numbers of the form x / 2^k - 다른 숫자들은 무한 소수가 된다 Limitation 2 - Just one setting of binary point within the w bits - 소수점을 왼쪽으로 옮기면 큰 수를 나타낼 수 없고, 오른쪽으로 옮기면 소수점 자리를 자세하게 나타내지 못한다 Floating Point Representation Precision Options Normalized Values When : exp != 0000...0 and exp != 1111...1 Normalized Encoding ..

Lecture 03: Bits, Bytes, and Integers (cont.)

Unsigned Addition in C Operands : w bits True Sum : w + 1 bits Discard Carry : w bits 따라서 Unsigned int 두 수의 합은 (실제 두 수의 합 mod 2^w) 의 값과 같다 Two's Complement Addition 두 수의 합에서 discard를 하더라도 실제 값과 동일한 경우가 존재한다 두 음수의 합에서 negative overflow가 발생하기도 한다 두 양수의 합에서 positive overflow가 발생하기도 한다 Unsigned Multiplication in C Operands : w bits True product : 2 * w bits Discard w bits : w bits 따라서 Unsigned int 두..

Lecture 02: Bits, Bytes, and Integers

비트는 특정 구간대의 전기 신호만 해당 신호로 받아들이고 0.2V ~ 0.9V 사이의 전압은 신호로 받아들이지 않아서 노이즈 등에 영향을 받지 않을 수 있다. binary에서 쓰이는 소수점은 decimal에서의 소수점과 다르다. 1.20 (10진법) 에서 소수 첫째 자리는 1 / 10을 의미 1.20 (2진법) 에서 소수 첫째 자리는 1 / 2을 의미 아래 도표 익숙해지기 bit 및 bit 연산을 이용해서 Set를 표현하고 조작할 수 있다. (비트 마스킹과 유사한 방식) File I/O (C library) 에서 시스템에 어떤 파일들이 input으로 주어질 수 있는지를 판단할 때도 흔히 사용되는 방식 Logical Operations in C &&, ||, ! 연산자는 항상 0이나 1만 반환한다 0은 "..

Lecture 01: Course Overview

Jim Tobin 교수의 15-213 Introduction to Computer Systems 강의를 들을 계획입니다. 1강에서는 해당 강의에서 다룰 내용들과 목표 등에 대한 소개를 해주셨습니다. 간략히 강의 개요를 살펴보자면 아래와 같습니다. 1. Programs and Data 2. Memory Hierarchy 3. Exceptional Control Flow 4. Virtual Memory 5. Networking and Concurrency 각각의 챕터에서 어떤 것을 배우게 되는지에 대해서 자세하게 알려주셨습니다. 또한 강의 내내 총 7개의 흥미로운 과제가 주어집니다. 1. L1 (datalab) : Manipulating bits 조건문이나 반복문 없이 입력한 수의 절대값을 반환하는 등의 간..

반응형