1.14k likes | 1.32k Views
This course provides an introduction to computer systems, covering topics such as hardware, software, programming, and system design. The course includes hands-on labs and practical assignments to enhance learning.
E N D
Outline • Teaching staffs • Textbook and Grading • Course Schedule • Motivation • Suggested reading • Preface xvii~xx
Instructor • 路红 • Email: honglu@fudan.edu.cn • Office phone: 51355528 • 413-1, Computer Building • Make Appointment or Open Door Policy
Teaching Assistants • 蒋国宝,陆进 • 蒋国宝:11210240049@fudan.edu.cn;13917854916(314-计算机楼) • 陆进:11210240054@fudan.edu.cn; 18721708786(314-计算机楼)
Teaching Notes • 10.141.247.12 • User: ics2012 • Pwd: ics2012 • \ • Right: can read/write and cannot delete
Text Book • Randy Bryant and David O’Hallaron, • Computer Systems: A Programmer’s Perspective • Prentice Hall, August 12, 2002. • 电子工业出版社,2006. • Brian Kernighan and Dennis Ritchie, • The C Programming Language, Second Edition • Prentice Hall, 1988
Grading • Exams(70%) • Mid-term exam (20% ) • Final exam (50%) • All exams are open books/open notes; in Englishg • Labs (24%) • 4~5 labs, (4-10% each) • Home work + 点名 (6-10%)
Grading • Lab deadline & Late Submission • Due at 11:59pm of the specific due date • Give 5 late days • Lose 1/5 of points for each other late day
Course Schedule -1 • Mainly introduce the content of Chap 1 ~ Chap 6. Some content in Chap 10. And some content in Chap 7, Chap 8, if time permitted.
Course Schedule -2 • 2012 ICS课程PPT安排表.doc
Course Schedule -3 • Every Thursday afternnon --- Teaching • Every Monday morning, • Odd Week, Exercise Q/A • Even Week, LAB
Why are we here? • From abstractions to details (realities) • From application level to system level • From Java to C
Features of this course • Enduring Concepts • From programmer’s perspective • Actively study • Becoming the rare “power programmer” Enduring: 持久的
Enduring concepts • Computer systems consists hardware and systems software that work together to run programs • Specific implementations of systems change over time • But the underlying concepts do not • All computer systems have similar hardware and software components that perform similar functions
From programmer’s perspective • Written for programmers instead of system builders • Few students would have the opportunity to build a computer system • Even the computer engineers would be required to use and program computers on a daily basis • It covers a topic only if it affected • correctness, performance or utility of user-level C programs
From programmer’s perspective • Topics on hardware adder and bus designs were out • Introduce assembly in a different way • How C constructs are translated by the compiler • Pointers • Loops • Procedure calls and returns • Switch statements
From programmer’s perspective • Take a broader and more realistic view of the system • Linking and loading • Process, signals • Performance optimization • I/O and network and concurrent programming (Not introduced here, can read if you are interested in.)
Actively study • New concepts are followed by practical problems • Homework problems and labs are also real • Learning by doing • Working concrete problems • Writing and running programs on real systems • Practical, concrete, hands-on and exciting
Becoming the rare “power programmer” • Enlightened by an understanding of • the underlying computer system • and its impact on your application programs • You know • How things work and • How to fix them when they break
Examples that we are going to learn • How to avoid strange numerical errors • caused by the way that computers represent numbers • How to optimize the C code by using • Clever tricks that exploit the designs of modern processors and memory systems
Examples that we are going to learn • How the compiler implements procedure call • How to use above knowledge to avoid • The security holes from buffer overflow bugs that • Plague network and Internet software • How to recognize and avoid the nasty errors during linking • That confound the average programmer Plague: 引起麻烦 Nasty: 危险的 Confound: 混淆
Examples that we are going to learn • How to write our own (*Optional) • Unix shell • Dynamic storage allocation • Web server
Fundamental course for systems • Compilers • Operating Systems • Networking • Architectures (with digital component design)
Platforms • Hardware platform • Intel IA-32 • Operating system • Linux • Programming language • ANSI C • Compiler • GNU-gcc
The C Programming Language • C was developed • in 1969 to 1973 • by Dennis Ritchie of Bell Laboratories. • The American National Standards Institute (ANSI) • ratified the ANSI C standard in 1989. • The standard defines • the C language • and a set of library functions known as the C standard library. Ratify: 批准,认可
The C Programming Language • Kernighan and Ritchie describe ANSI C in their classic book • which is known affectionately as “K&R” . • In Ritchie’s words [60], C is • quirky, • flawed, • and an enormous success. • Why the success? Quirky: 离奇的 Flawed: 有缺陷的
The C Programming Language • C was closely tied with the Unix operating system. • C was developed from the beginning as the system programming language for Unix. • Most of the Unix kernel, and all of its supporting tools and libraries, were written in C. • As Unix became popular in universities in the late 1970s and early 1980s, many people were exposed to C and found that they liked it. • Since Unix was written almost entirely in C, it could be easily ported to new machines, which created an even wider audience for both C and Unix.
The C Programming Language • C is a small, simple language. • The design was controlled by a single person, rather than a committee, and the result was a clean, consistent design with little baggage. • The K&R book describes the complete language and standard library, with numerous examples and exercises, in only 261 pages. • The simplicity of C made it relatively easy to learn and to port to different computers.
The C Programming Language • C was designed for a practical purpose. • C was designed to implement the Unix operating system. • Later, other people found that they could write the programs they wanted, without the language getting in the way.
The C Programming Language • C is the language of choice for system-level programming • There is a huge installed based of application-level programs as well.
The C Programming Language • However, it is not perfect for all programmers and all situations • C pointers are a common source of confusion and programming errors • C also lacks explicit support for useful abstractions such as classes and objects • Newer languages such as C++ and Java address these issues for application-level programs
How do we start • From a very simple program “Hello” • To run and completion this simple program • Every major part of the system must work in concert • This course is to help you understand • what happens and why • When you run hello on your system
“Hello world” example 1 #include <stdio.h> 2 3 int main() 4 { 5 printf("hello, world\n"); 6 }
How do we start • We begin our study of systems by • Tracing the lifetime of the hello program • From it is created by a programmer • To it runs on a system, prints its result, and terminates
Outline • Bit and Byte • Context is very important • Understand machine representations of numbers • Information storage • Bit level manipulation • Suggested reading • Chap 1.1, 2.1
“Hello world” example 1 #include <stdio.h> 2 3 int main() 4 { 5 printf("hello, world\n"); 6 } • Source program • Created by editor and saved as a text file
“Hello world” example # i n c l u d e <sp> < s t d i o . 35 105 110 99 108 117 100 101 32 60 115 116 100 105 111 46 h > \n \n i n t <sp> m a i n ( ) \n { 104 62 10 10 105 110 116 32 109 97 105 110 40 41 10 123 \n <sp> <sp> <sp> <sp> p r i n t f ( " h e 10 32 32 32 32 112 114 105 110 116 102 40 34 104 101 l l o , <sp> w o r l d \ n " ) ; \n } 108 108 111 44 32 119 111 114 108 100 92 110 34 41 59 10 125
Why Bit? • The source program is a sequence of bits • Modern computers store and process • Information represented as two-valued signals • These lowly binary digits are bits • Bits form the basis of the digital revolution
The Decimal Representation • Base-10 • Has been in use for over 1000 years • Developed in India • Improved by Arab mathematicians in the 12th century • Brought to the West in the 13th century by • the Italian mathematician Leonardo Pisano, • better known as Fibonacci. * Fibonacci:斐波纳契数列(一种整数数列, 其中每数等于前面两数之和)
Why Bit? • Using decimal notation is natural for ten-fingered humans • But binary values work better when building machines • that store and process information
Why Bit? • Two-valued signals can readily be • represented, stored, and transmitted, • Examples • The presence or absence of a hole in a punched card • A high or low voltage on a wire • A magnetic domain oriented clockwise or counterclockwise.
Why Bit? • The electronic circuitry is very simple and reliable for • storing and performing computations on two-valued signals • This enabling manufacturers to integrate • millions of such circuits on a single silicon chip
Group Bits • In isolation, a single bit is not very useful • However, we are able to represent the elements of any finite set by using bits • To do this, we • first group bits together • then apply some interpretation to the different possible bit patterns • that gives meaning to each patterns Interpretation: 解释
ASCII standard • 8-bit chunks are organized as a byte • Each byte represents some text character in the program • Most modern systems represent text characters • using the ASCII standard • ASCII standard represents • each character with a unique byte-sized integer value
“Hello world” example # i n c l u d e <sp> < s t d i o . 35 105 110 99 108 117 100 101 32 60 115 116 100 105 111 46 h > \n \n i n t <sp> m a i n ( ) \n { 104 62 10 10 105 110 116 32 109 97 105 110 40 41 10 123 \n <sp> <sp> <sp> <sp> p r i n t f ( " h e 10 32 32 32 32 112 114 105 110 116 102 40 34 104 101 l l o , <sp> w o r l d \ n " ) ; \n } 108 108 111 44 32 119 111 114 108 100 92 110 34 41 59 10 125
Text file • Source program is stored in a file • As a sequence of bytes • Each byte has an integer value that corresponds to some character • Text files • Files that consist exclusively of ASCII characters • Binary files • Files other than text files
Information is Bits+Context • All information in a system is represented • as a bunch of bits • Such as • Disk files • Programs stored in memory • User data stored in memory • Data transferred across a network
Information is Bits+Context • The only thing that distinguishes different data objects is • the context in which we view them • In different contexts, the same sequence of bytes might represent • A number (integer or floating point number) • A character string • A machine instruction • Context is very important in interpreting bits!
Three number encodings • Unsigned encoding • Representing numbers greater than or equal to 0 • Using traditional binary representation • Two’s-complement encoding • Most common way to represent either positive or negative numbers • Floating point encoding • Base-two version of scientific notation for representing real numbers
Understanding numbers • Machine representation of numbers are not same as • Integers and real numbers • They are finite approximations to integers and real numbers • Sometimes, they can behave in unexpected way