lab2 slide operator system

33 306 0
lab2 slide operator system

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

operator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator systemoperator system

Faculty of Computer Science and Engineering Ho Chi Minh City University of Technology CO2018 Operating Systems C programming Autumn, 2016 Nguyen Duc Hai Objective • Understand how to compile a C project • Get familiar with Makefile • Enhance C programing skills Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from a single source file? // hello.c #include int main() { printf(“Hello, world!”); } Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from a single source file? Preprocessor hello.i Autumn 2016 // hello.c #include int main() { printf(“Hello, world!”); } FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from a single source file? Preprocessor hello.i // hello.c #include int main() { printf(“Hello, world!”); } Compiler hello.s Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from a single source file? Preprocessor hello.i // hello.c #include int main() { printf(“Hello, world!”); } Compiler hello.s Autumn 2016 Assembler hello.o FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from a single source file? Preprocessor hello.i // hello.c #include int main() { printf(“Hello, world!”); } Compiler hello.s Autumn 2016 We need the implementation of printf from this file libc.a Assembler hello.o FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Linker a.out Compilation • How to create an executable file from multiple source files? • Suppose we have five files (you can find them in source code directory in Resource page at Sakai): • • • • • main.c swap.h swap.c rev.h rev.c  Compile source code first then link all of them together Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from multiple source files? main.c Translators (cpp, cc1, as) main.o Autumn 2016 swap.c rev.c Translators (cpp, cc1, as) Translators (cpp, cc1, as) swap.o rev.o FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY Compilation • How to create an executable file from multiple source files? main.c Translators (cpp, cc1, as) main.o libc.a Autumn 2016 swap.c rev.c Translators (cpp, cc1, as) Translators (cpp, cc1, as) swap.o rev.o Linker (ld) FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY prg 10 Makefile • How to compile source code efficiently? main.c We not recompile this file because its dependencies not change rev.h main.o swap.h swap.o rev.c rev.o all: main.o swap.o rev.o gcc main.o swap.o rev.o –o prg main.o: main.c rev.h gcc –c main.c prg swap.o: swap.c swap.h gcc –c swap.c rev.o: rev.c rev.h swap.h gcc –c rev.c swap.c Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY 19 C Programming Exercise • The value of exp1 and exp2? float a = 1e20; float b = -1e20; float c = 3.14; exp1 = (a + b) + c; exp2 = a + (b + c); Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY 20 C Programming Exercise • The value of exp1 and exp2? float a = 1e20; float b = -1e20; float c = 3.14; exp1 = (1e20 – 1e20) + 3.14 = 3.14 exp2 = a + (b + c); Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY 21 C Programming Exercise • The value of exp1 and exp2? float a = 1e20; float b = -1e20; float c = 3.14; exp1 = (1e20 – 1e20) + 3.14 = 3.14 exp2 = 1e20 + (-1e20 + 3.14) = 1e20–1e20 = Autumn 2016 FACULTY OF COMPUTER SCIENCE AND ENGINEERING HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY 22 C Programming Exercise • What is the value of exp in following expression: unsigned int a = 1; // assume unsigned int is 4-byte long unsigned long exp; // assume unsigned long is 8-byte long exp = (a

Ngày đăng: 19/09/2016, 21:11

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan