Cirrus Logic CS485 Instrukcja Użytkownika

Przeglądaj online lub pobierz Instrukcja Użytkownika dla Nie Cirrus Logic CS485. Here - Computer Science Department Instrukcja obsługi

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 67
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 0
CS485G classnotes
Raphael Finkel
May 4, 2015
1 Intro
Lecture 1, 1/14/2015
1. Handout 1 — My names
2. Plagiarism — read aloud
3. E-mail list: [email protected]
4. Labs: about five throughout the semester, typically on Fridays. The
first one is this Friday. Labs count toward your grade; you must do
them during the lab session.
5. Projects on web at https://www.cs.uky.edu/
˜
raphael/courses/
CS485.html. First project — Review of the C language
6. Accounts in MultiLab if you want; every student will have a virtual
machine as well, at [email protected], where name is your
LinkBlue account name.
7. Text: Randal E. Bryant and David R. O’Hallaron, Computer Systems:
A Programmer’s Perspective (2nd edition) – required.
2 Software tools
Implementation
Use (client)
Spec
Programmer
Compiler
Language
1
Przeglądanie stron 0
1 2 3 4 5 6 ... 66 67

Podsumowanie treści

Strona 1 - CS485G classnotes

CS485G classnotesRaphael FinkelMay 4, 20151 IntroLecture 1, 1/14/20151. Handout 1 — My names2. Plagiarism — read aloud3. E-mail list: [email protected]

Strona 2 - 3 Abstraction and reality

CS485G Spring 2015 10iv. 10002= −8. Try to negate this number.v. 01112= 7.vi. 10012= −7.13 Compilation and disassembly in Linux1. Compiler for C: gcc.

Strona 3 - 4 Memory-referencing bugs

CS485G Spring 2015 114. The microarchitecture describes how the architecture is implemented.It includes the sizes of caches and the frequency at which

Strona 4 - 5 Binary representation

CS485G Spring 2015 128. Generated x86 assembler (using -O1)sum:movl 8(%esp),%eaxaddl 4(%esp),%eaxret9. Interpretation: x is at 8(%ebp); y is at 4(%ebp

Strona 5 - 7 Byte ordering

CS485G Spring 2015 133. Registers32-bit 16-bit 8-bit original purposeeax ax ah/al accumulatorebx bx bh/bl baseecx cx ch/cl counteredx dx dh/dl dataesi

Strona 6 - 8 Memory organization

CS485G Spring 2015 14pushl %ebp # save base pointermovl %esp,%ebp # new base pointerpushl %ebx # save old contents of %ebxmovl 8(%ebp), %edx # edx = x

Strona 7 - 9 Strings and Buffers

CS485G Spring 2015 15(c) Load Effective Address of src and put it in dest.(d) Purpose: translate p = &x[i](e) Purpose: compute arithmetic expressi

Strona 8 - 10 Boolean algebra

CS485G Spring 2015 161 int arith(int x, int y, int z)2 {3 int t1 = x+y;4 int t2 = z+t1;5 int t3 = x+4;6 int t4 = y*48;7 int t5 = t3 + t4;8 int rval =

Strona 9 - 12 Encoding integers

CS485G Spring 2015 1711. Result of compilationpushl %ebp # save base pointermovl %esp,%ebp # new base pointermovl 12(%ebp),%eax # $a = yxorl 8(%ebp),%

Strona 10 - 14 Machine basics

CS485G Spring 2015 185. The test instruction (testl b, a) also sets the flags; it’s like com-puting a&b without modifying the destination. Usually,

Strona 11

CS485G Spring 2015 191 int absdiff(int x, int y)2 {3 int result;4 if (x > y) {5 result = x-y;6 } else {7 result = y-x;8 }9 return result;10 }absdif

Strona 12 - 16 IA32 = x86 architecture

CS485G Spring 2015 23 Abstraction and reality1. Most CS and CE courses emphasize abstraction; it matches how wethink, and it lets us hide implementati

Strona 13

CS485G Spring 2015 20absDiff:pushl %ebp # save base pointermovl %esp,%ebp # new base pointermovl 8(%ebp), %edx # d = xmovl 12(%ebp), %eax # a = ycmpl

Strona 14

CS485G Spring 2015 211 int countOnes(unsigned x)2 {3 int result = 0;4 loop:5 result += x & 0x1;6 x >>= 1;7 if (x)8 goto loop;9 return result

Strona 15 - 19 Arithmetic operations

CS485G Spring 2015 22(b) parameters(c) local variables(d) temporary locations (that don’t fit in registers)6. On the x86, the %epb register points to t

Strona 16

CS485G Spring 2015 2311. Linkage at the calling point for swap(&course1, &course2);subl $8,%esp # make room for two parametersmovl $course2, 4

Strona 17

CS485G Spring 2015 24(b) %ebx, %esi, %edi are non-volatile (callee-save) general-purposeregisters.(c) %esp and %ebp are non-volatile (callee-save) spe

Strona 18

CS485G Spring 2015 252. Example1 int add3(int x) {2 int localx = x;3 incrk(&localx, 3);4 return localx;5 }6 void incrk(int*ip, int k) {7*ip += k;8

Strona 19

CS485G Spring 2015 2625 x86 64 registers1. Eight upgraded 64-bit registers, now with names starting with r in-stead of e, such as %rax.2. Eight new 64

Strona 20 - 21 do while loops

CS485G Spring 2015 2727 Arrays1. Lecture 15, 2/23/20152. C declaration: T myArray[L], where T is some type and L is thenumber of elements (the first is

Strona 21 - 22 Procedures

CS485G Spring 2015 288. Loop example1 void zincr(myArrayType z) {2 int i;3 for (i = 0; i < ZLEN; i+=1)4 z[i] += 1;5 }# assume d = zmovl $0, %eax #

Strona 22

CS485G Spring 2015 298. Lecture 16, 2/25/20159. General addressing case: T A[R][C]; defines a two-dimensionalarray of type T with R rows and C columns.

Strona 23

CS485G Spring 2015 3(d) Operating systems need to deal with the intricacies of machinecode as they manipulate processes (keeping track of floatingpoint

Strona 24

CS485G Spring 2015 303. The compiler knows all the offsets.30 Linked lists1. Example:1 void set_val(struct rec*r, int val) {2 while (r) {3 int i = r-&

Strona 25

CS485G Spring 2015 31(b) 2 bytes (short): address ends with 02(c) 4 bytes (int, void *): address ends with 002(d) 8 bytes (double): address ends with

Strona 26 - 26 Data types

CS485G Spring 2015 3234 Unions1. Snow day: 3/6/20152. Lecture 18, 3/9/20153. A union type is like a struct, but the fields all start at offset 0, sothe

Strona 27 - 27 Arrays

CS485G Spring 2015 332. The limit program shows per-process limitations; by default, for in-stance, the stack is limited to 8MB.36 Buffer overflow1. Un

Strona 28 - 28 Nested arrays

CS485G Spring 2015 34gcc, use -fstack-protector (adds code to evidently suspi-cious routines) or -fstack-protector-all (adds code to allroutines)80486

Strona 29 - 29 Structures

CS485G Spring 2015 35(a) Programs define symbols and reference them:1 void swap() {...} // exported global identifier2 extern int myGlobal; // imported

Strona 30 - 31 Alignment

CS485G Spring 2015 36(d) Windows calls shared object files Dynamic Link Libraries (DLLs).7. Lecture 21, 3/23/20158. Relocation(a) The linker combines t

Strona 31 - 33 Discussion of midterm test

CS485G Spring 2015 374. Global symbols: defined in this module, may be referenced by othermodules. In C: functions (except static) and file-global varia

Strona 32 - 35 Linux x86 memory layout

CS485G Spring 2015 386. Advice:(a) Multiple compilation units should share global declarations viaa .h file.(b) Use static if possible to prevent confli

Strona 33 - 36 Buffer overflow

CS485G Spring 2015 3942 Interpositioning1. Replace standard routine with a special one in order to monitor (forexample, to find memory leaks), profile (

Strona 34 - 37 Linking

CS485G Spring 2015 4(h) There are tools to help you detect referencing errors (such asvalgrind).5 Binary representation1. Bits are represented by two

Strona 35

CS485G Spring 2015 40(a) Monolithic: many functions, all linked together.(b) Other: object-oriented, layered, dynamically loaded modules(c) Linux: Mos

Strona 36 - 38 Format for object files

CS485G Spring 2015 41(d) When the kernel is ready to return from the exception:i. The CPU changes to its previous mode (typically user mode)and its pr

Strona 37 - 39 Unix tools for object files

CS485G Spring 2015 4247 System calls invoked by C library routines1. Many C library routines include system calls.(a) printf() calls write() which exe

Strona 38 - 41 Libraries

CS485G Spring 2015 43(f) The only difference is the return value. For A, it is B’s processidentifier (PID). For B, it is 0.9. The exit() system call te

Strona 39 - 42 Interpositioning

CS485G Spring 2015 442. Lecture 27, 4/6/20153. login starts a shell for each logged-in user.(a) sh: original shell, Stephen Bourne, 1977(b) csh: BSD U

Strona 40 - 44 Exception handling

CS485G Spring 2015 45(a) Terminate(b) Ignore(c) Terminate and create a dump file (called core).(d) Temporarily stop the process.(e) Continue the proces

Strona 41 - 46 Example: Page fault

CS485G Spring 2015 46(b) The POSIX standard requires 117 functions, such as write(),to be safe. But printf() is not safe.51 Nonlocal jumps1. Nonlocal

Strona 42 - 48 Processes

CS485G Spring 2015 47(a) open() and close(): open() returns a file descriptor; thekernel allocates and initializes a data structure. close() letsthe ke

Strona 43 - 49 Processes in Unix

CS485G Spring 2015 48(b) connect() to attach the socket to the server (like “call a num-ber”).5. Server(a) socket() to create a local file descriptor (

Strona 44 - 50 Signals

CS485G Spring 2015 499. Sample client for ”echo”1 int client(int argc, char**argv) {2 int toserverfd, port;3 char*host, buf[MAXLINE];4 rio_t rio;5 if

Strona 45

CS485G Spring 2015 56. What is the largest signed integer you can store in 16 bits? (Answer:215− 1 = 32767)7. How many bits do you need to store 4893?

Strona 46 - 52 Files

CS485G Spring 2015 5010. Implementation of open clientfd1 int open_clientfd(char*hostname, int port) {2 int toserverfd;3 struct hostent*serverHostEntr

Strona 47 - 53 Sockets

CS485G Spring 2015 5111. Sample server for ”echo”1 int server(int argc, char**argv) {2 int listenfd, connfd, listenPort;3 struct sockaddr_in clientAdd

Strona 48

CS485G Spring 2015 5212. Implementation of open listenfd1 int open_listenfd(int port) {2 int listenfd, optval=1;3 struct sockaddr_in serveraddr;45 /*C

Strona 49

CS485G Spring 2015 53(a) Read: reached the end of file, or the end of a line with fgets().(b) Network sockets or pipes: read or write can give a short

Strona 50

CS485G Spring 2015 54closedir(). readdir() returns a struct dirent pointer, whichincludes the name of the file.5. Directories associate file names with

Strona 51

CS485G Spring 2015 55(b) stdio: buffering increases efficiency, and short counts are han-dled automatically. But no way to read metadata, not async-sig

Strona 52 - 54 More about files

CS485G Spring 2015 56(a) Each process gets a uniform linear address space that does notcontain any addresses belonging to any other process or to thek

Strona 53

CS485G Spring 2015 57(d) Actually, instead of 220entries, the table is in two layers, but weignore that detail for simplicity.(e) Adjacent addresses w

Strona 54

CS485G Spring 2015 58(c) The general idea is to employ the ”recently accessed” bit in thepage table to find a victim that has not been recently accesse

Strona 55 - 55 Virtual memory

CS485G Spring 2015 59ii. Every free region has tags and also is linked into a list offree regions (the link is in the region itself).iii. To allocate,

Strona 56

CS485G Spring 2015 68. You can also use a program:1 typedef unsigned char*pointer;2 void show_bytes(pointer start, int len){3 int i;4 for (i = 0; i &l

Strona 57

CS485G Spring 2015 60(c) Then mark all allocated regions that are still in use.(d) Then reclaim all allocated regions that are not marked.3. How to kn

Strona 58 - 56 Free-space allocation

CS485G Spring 2015 613. An internetwork is an interconnected set of networks; the Internet isthe best example.4. Lowest level: ethernet segment(a) Hos

Strona 59 - 57 Garbage collection

CS485G Spring 2015 62(b) Software on hosts and routers agree on a common internet pro-tocol independent of the capacities of routers and links.9. IPv4

Strona 60 - 58 Networks

CS485G Spring 2015 63(d) Unix sockets can be established for either UDP or TCP.12. Internet components(a) Backbone: collection of routers connected to

Strona 61

CS485G Spring 2015 64(c) Class C: first octet 192-224; second and third octet 0-255. 28ad-dresses in region.(d) Special purpose addresses: first octet 2

Strona 62

CS485G Spring 2015 6559 Client-server1. Clients(a) Examples: ftp, telnet, ssh, browsers like Firefox.(b) Lecture 37, 5/1/2015(c) To find a server: use

Strona 63

CS485G Spring 2015 66(e) The client uses the host:port part to determine the addressand of the server and the port to connect to. It uses the servicep

Strona 64

CS485G Spring 2015 67unix> telnet mail.cs.uky.edu 25Trying 128.163.146.23...Connected to satchmo.cs.uky.edu.Escape character is ’ˆ]’.220 satchmo.cs

Strona 65 - 59 Client-server

CS485G Spring 2015 76. The operating system allocates physical space, which also looks likean array ranging from address 0 to a limit determined by ho

Strona 66

CS485G Spring 2015 86. A buffer is also an array of bytes, typically used to hold data sub-ject to I/O. The bytes hold arbitrary binary values, not ne

Strona 67

CS485G Spring 2015 97. One can use the Boolean operators in C and apply them to any inte-gral data type: char, short, int, long, long long.8. Don’t co

Komentarze do niniejszej Instrukcji

Brak uwag