Department of Computer Science and Engineering Yonghong Yan

Size: px
Start display at page:

Download "Department of Computer Science and Engineering Yonghong Yan"

Transcription

1 Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution CSCE 212 Introduction to Computer Architecture, Spring Department of Computer Science and Engineering Yonghong Yan yanyh@cse.sc.edu

2 Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution Lecture 04 A.1 Introduction A.2 Assemblers A.3 Linkers 2.12 Translating and Starting a Program Hands-on Lecture 05 Dynamic linking, compilation process and preprocessing 2.12 Translating and Starting a Program Introducing memory Hands-on Lecture 06 Basic C programming A.4 Loading and A.5 Memory Usage To be covered as part of Chapter 2 2

3 Review of Lecture 03 and Chapter 01 3

4 Review: Power, Frequency and ILP Moore s Law to processor speed (frequency) CPU frequency increase was flattened around Two main reasons: 1. Limited ILP and 2. Power consumption and heat dissipation Note: Even Moore s Law is ending around 2021: conductors/devices/transistors -could-stop-shrinking-in w.com/s/601441/moores-lawis-dead-now-what/ imworstall/2016/07/26/econo mics-is-important-the-end-ofmoores-law 1.8 The Sea Change: The Switch to Multiprocessors 4

5 Multiprocessors Multicore microprocessors become main-stream starting from 2005 More than one processor per chip Requires explicitly parallel programming Compare with instruction level parallelism Hardware executes multiple instructions at once Hidden from the programmer Hard to do Programming for performance Load balancing Optimizing communication and synchronization 5

6 Review for Chapter 1: Three Most Important Topics Moore s Law: From 1970s, transistor density doubles every years CPU frequency (performance) doubles every 2 years till ~2005 From 2005, transistor density still double every years, CPU frequency flats Industry moves to multicore, manycore and multiprocessing Abstraction High-level language, assembly language/isa as HW/SW interface, binary for computer Software interface, method declaration and definition CPU Performance Power: Linearly proportional to the CPU frequency 6

7 Review: CPU Time Performance improved by Reducing number of clock cycles Increasing clock rate Hardware designer must often trade off clock rate against cycle count CPU Time = CPU Clock Cycles Clock Cycle Time = CPU Clock Cycles Clock Rate 7

8 Review: CPU Time, Instruction Count and CPI Hardware/CPU executes a program instruction by instructions Clock Cycles = Instruction Count Cycles per Instruction CPU Time = Instruction Count CPI Clock Cycle Time Instruction Count CPI = Clock Rate Instruction Count for a program Determined by program, ISA and compiler Average cycles per instruction Determined by CPU hardware If different instructions have different CPI Average CPI affected by instruction mix 8

9 Review: CPI Example Alternative compiled code sequences using instructions in classes A, B, C Class A B C CPI for class IC in sequence IC in sequence n Sequence 1: IC = 5 n Clock Cycles = å i= 1 Clock Cycles = = 10 n Avg. CPI = 10/5 = 2.0 n (CPIi Instruction Count i) n Sequence 2: IC = 6 n Clock Cycles = = 9 n Avg. CPI = 9/6 = 1.5 9

10 End of Review of Lecture 03 and Chapter 01 10

11 Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution Lecture 04 A.1 Introduction A.2 Assemblers A.3 Linkers 2.12 Translating and Starting a Program Hands-on Lecture 05 Dynamic linking, compilation process and preprocessing 2.12 Translating and Starting a Program Introducing memory Hands-on Lecture 06 Basic C programming A.4 Loading and A.5 Memory Usage To be covered as part of Chapter 2 11

12 Von Neumann Computer Programs and data are stored in the memory Data needs to be loaded from memory to register for compute E.g. lw $R2, 20[$R4]; int a = A[5]; Memory are used to store data and it has address E.g. sw $R3, 40[$R4]; A[10] = 5; In general, the computer can only perform one instruction at a time. 12

13 Data, Files/Folders, and Memory Source code, executable, object are all files Files: Hello.c, sum_full.c, sum Folder:.,.., /home/yanyh, etc Compiler, OS kernel, etc are all stored as files gcc, vmlinuz generic Information about files/folders and data are also files Metadata Files need to be loaded to memory in order to be processed./hello: load the file hello and execute it ls: load the file ls, which is the command ls, and execute it 13

14 Levels of Program Code to Multiple Target Architectures Java C/C++ Python Javac and JIT gcc/clang python MIPS X86/X86_64 ARM 14

15 X86_64 Assembly Example Disassembly a machine binary code using objdump 15

16 Code in Assembly Language Assembly language either is written by a programmer or is the output of a compiler. 16

17 High-Level Program, Assembly Code and Binary 17

18 Hand-On, sum x86_ A method in assembly.globl: a global symbol.type.cfi_startproc.cfi_endproc ret: return for loop check i<n, if true, else goto end; loop body i++ end 18

19 Sum, MIPS Mainly different instructions 19

20 Sum, x86_64 Number of instructions per loop iteration Count it 20

21 When to Use Assembly Language Advantage: Speed, size and predictable No compiler middle-man Fit for mission-critical, embedded domain, e.g. space shuttle or car control Hybrid approach Non-critical part in high-level language Critical part in assembly language Explore special instructions E.g. those special-purpose instructions that can do more than one thing 21

22 Drawbacks of Assembly Language Assembly language has many (and more) disadvantages that strongly argue against its wide-spread use. Machine-specific code, i.e. assembly code are not portable Rewrite for new or different architectures Harder than high level language to write large code or software Harder to keep a high-level software structure Harder to read and debug Most compilers are good enough to convince that you do not need to write assembly code for general-purpose applications Except embedded or IoT domain 22

23 Assembler Translates file of assembly language statements into a file of binary machine instructions and binary data. Two main steps: Find memory address for symbols (e.g. functions). Translate each assembly statement by combining the numeric equivalents of opcodes, register specifiers, and labels into a legal instruction Binary Produce object files 23

24 Object File ELF Format: #include <stdio.h> int a[10]={0,1,2,3,4,5,6,7,8,9}; int b[10]; int main(int argc, char* argv[]){ int i; static int k = 3; } for(i = 0; i < 10; i++) { printf("%d\n",a[i]); b[i] = k*a[i]; } 24

25 Contents of Object File for the Sample C program Offset Contents Comment Header section number of bytes of Machine code section 4 44 number of bytes of initialized data section 8 40 number of bytes of Uninitialized data section (array b[]) (not part of this object module) number of bytes of Symbol table section number of bytes of Relocation information section Machine code section (124 bytes) 20 X code for the top of the for loop (36 bytes) 56 X code for call to printf() (22 bytes) 68 X code for the assignment statement (10 bytes) 88 X code for the bottom of the for loop (4 bytes) 92 X code for exiting main() (52 bytes) Initialized data section (44 bytes) beginning of array a[] : end of array a[] (40 bytes) variable k (4 bytes) Symbol table section (60 bytes) 188 X array a[] : offset 0 in Initialized data section (12 bytes) 200 X variable k : offset 40 in Initialized data section (10 bytes) 210 X array b[] : offset 0 in Uninitialized data section (12 bytes) 222 X main : offset 0 in Machine code section (12 bytes) 234 X printf : external, used at offset 56 of Machine code section (14 bytes) Relocation information section (44 bytes) 248 X relocation information 25

26 Some Terms Object file vs Executable Object file is the file for binary format of machine instructions, not linked with others, nor positioned (in memory) for execution Executable is binary format of object files that are linked and positioned ready for execution. Symbol Names, e.g. global function name, variable name Library Archive or package of multiple object files 26

27 Inspect an ELF Object File or Executable Executable and Linkable Format (ELF) readelf and objdump command in Linux to inspect object/executable file or disassembly Only objdump can do disassembly nm command to display symbol information Try sum_full.o and sum example sum_full.o is an object file sum is an executable 27

28 Linking Linker (ld command) searches a collection of object files and program libraries to find nonlocal routines used in a program, combines them into a single executable file, and resolves references between routines in different files. 28

29 Role of the Linker ELF Header Section 1 Data Section 2 Data Section n Data Section-Header Table Linkable File ELF Header Section 1 Data Section 2 Data Section n Data Section-Header Table ELF Header Program-Header Table Segment 1 Data Segment 2 Data Segment n Data Executable File Linkable File 29

30 Compile Multiple Files and Link to One Executable Split the sum_full.c into two files sum.c that only contains the definition of sum method Also the #define REAL float line on top Remove the sum definition from sum_full.c, but still keep sum method declaration (referred too as function signature) Compile both together and generate sum executable Compile in one step: gcc sum_full.c sum.c -o sum The command compiles each *.c file one by one into object files and then link the two object files into one executable Compile in multiple steps: compile each.c file one by one and link together 30

31 Compile in One Step 31

32 Compile in Multiple Steps 32

33 Try readelf 33

34 Try objdump for both object file and executable 34

35 objdump -D to disassembly: convert binary object code back to symbolic assembly code 35

36 nm: list symbols from object files T: define a symbol U: undefined symbol Linker to link Address are relative 36

37 End of Lecture 04 37

38 Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution Lecture 04 A.1 Introduction A.2 Assemblers A.3 Linkers 2.12 Translating and Starting a Program Hands-on Lecture 05 Dynamic linking, compilation process and preprocessing 2.12 Translating and Starting a Program Introducing memory Hands-on Lecture 06 Basic C programming A.4 Loading and A.5 Memory Usage To be covered as part of Chapter 2 38

39 Review of Lecture 04 39

40 Review: Von Neumann Computer, How Array References are Translated to Load/Store Instructions Programs and data are stored in the memory Data needs to be loaded from memory to register for compute E.g. lw $R2, 20[$R4]; int a = A[5]; Right (of = ) value Memory are used to store data and it has address E.g. sw $R3, 40[$R4]; A[10] = 5; Left (of = ) value In general, the computer can only perform one instruction at a time. 40

41 Review: High-Level Program, Assembly Code and Binary, Loop is translated to use branch instruction Function call is translated to use jalinstruction bne: branch if not equal ble: branch if less than or equal jal: jump and link 41

42 Review: Pros and Cons of Assembly Code +: Speed and predictable Used for mission-critical application -: Machine and architecture-dependent -: Hard to program large software and debug Most compilers are good enough to convince that you do not need to write assembly code for general-purpose applications 42

43 Review: Compiling, Assembly and Disassembly Linking, e.g. gcc Compiling, e.g. gcc -s Assembly, e.g. gcc -s disassembly, e.g. objdump -d 43

44 Linking Linker (ld command) searches a collection of object files and program libraries to find nonlocal routines used in a program, combines them into a single executable file, and resolves references between routines in different files. 44

45 Review: Assembler and Linking Assembler: Convert symbolic machine instructions to binary instructions Linker: Link symbols (one is to define and the others are to use) from multiple object files Combine object files and create executables Know how to compile multiple source files into objects and then link them into one executable Static linking, hand-on exercises Dynamic linking Familiar with gcc, readelf, objdump, nm, ldd commands and their usage and purpose 45

46 Compile Multiple Files and Link to One Executable Split the sum_full.c into two files sum.c that only contains the definition of sum method Also the #define REAL float line on top Remove the sum definition from sum_full.c, but still keep sum method declaration (referred too as function signature) Compile both together and generate sum executable Compile in one step: gcc sum_full.c sum.c -o sum The command compiles each *.c file one by one into object files and then link the two object files into one executable Compile in multiple steps: compile each.c file one by one and link together 46

47 End of Review of Lecture 04 47

48 Appendix A and Chapter 2.12: Compiler, Assembler, Linker and Program Execution Lecture 04 A.1 Introduction A.2 Assemblers A.3 Linkers 2.12 Translating and Starting a Program Hands-on Lecture 05 Dynamic linking, compilation process and preprocessing 2.12 Translating and Starting a Program Introducing memory Hands-on Lecture 06 Basic C programming A.4 Loading and A.5 Memory Usage To be covered as part of Chapter 2 48

49 Static Linking If multiple program want to use read_timer functions They all include the full definition in their source code Duplicate: If the function changes, we need to change each file Separate reader_timer in a new file, compile and statically linked with other object files to create executables Duplicate the same object in multiple executables. Dynamic linking at the runtime Create a dynamic library that provides reader_timer implementation Tell ld to link the library at the runtime Runtime load and link them on the fly and execute 49

50 Static Library vs Shared (Dynamic) Library Static library needs to be duplicated in every executable Bigger code size, better optimized Shared library are loaded on the fly during the execution Smaller code size, performance hits of loading shared memory Combine both 50

51 Hands-On for dynamic linking Sum example for static and dynamic linking: from sum.c and sum_full.c created in the last exercise, Create a new file read_timer.c that includes the read_timer and read_timer_ms definition in the file Leave only the read_timer and read_timer_ms declaration in the sum_full.c They are the interface of the two methods. Compile read_timer.c into a dynamic library The library name is my_read_timer, and the library file is libmy_read_timer.so. You can choose any name. Compile sum.c and sum_full.c and link with lib my_read_timer gcc sum_full.c sum.c -o sum -L. -lmy_read_timer Use ldd command to list dependent libraries 51

52 Build Steps with Dynamic Library Linking error: cannot find reader_timer implementation when linking from sum_full.o Linking error: do not know where to find the libread_timer.so file. -L< >: to tell where to find the library file, in this case, the current folder (.) -l<...>: to tell the library file name, which will be expanded to lib< >.so file 52

53 ldd command to list the dependent libraries 53

54 Compilation Process in C Compilation process: gcc hello.c -o hello Constructing an executable image for an application FOUR stages Command: gcc <options> <source_file.c> Compiler Tool gcc (GNU Compiler) man gcc (on Linux m/c) icc (Intel C compiler) 54

55 4 Stages of Compilation Process Preprocessing gcc -E hello.c -o hello.i hello.c à hello.i Compilation (after preprocessing) gcc -S hello.i -o hello.s Assembling (after compilation) gcc -c hello.s -o hello.o Linking object files gcc hello.o -o hello Output à Executable (a.out) Run à./hello (Loader) 55

56 4 Stages of Compilation Process 1. Preprocessing (Those with # ) Expansion of Header files (#include ) Substitute macros and inline functions (#define ) 2. Compilation Generates assembly language,.s file Verification of functions usage using prototypes Header files: Prototypes declaration 3. Assembling Generates re-locatable object file (contains m/c instructions),.o file nm app.o T main U puts nm or objdump tool used to view object files 56

57 4 Stages of Compilation Process (contd..) 4. Linking Generates executable file (nm tool used to view exe file) Binds appropriate libraries Static Linking Dynamic Linking (default) Loading and Execution (of an executable file) Evaluate size of code and data segment Allocates address space in the user mode and transfers them into memory Load dependent libraries needed by program and links them Invokes Process Manager à Program registration 57

58 Compiling a C Program gcc <options> program_name.c Options: Four stages into one Wall: Shows all warnings -o output_file_name: By default a.out executable file is created when we compile our program with gcc. Instead, we can specify the output file name using "-o" option. -g: Include debugging information in the binary. man gcc 58

59 Linking Multiple files to make executable file Two programs, prog1.c and prog2.c for one single task To make single executable file using following instructions First, compile these two files with option "-c" gcc -c prog1.c gcc -c prog2.c -c: Tells gcc to compile and assemble the code, but not link. We get two files as output, prog1.o and prog2.o Then, we can link these object files into single executable file using below instruction. gcc -o prog prog1.o prog2.o Now, the output is prog executable file. We can run our program using./prog 59

60 Linking with other libraries Normally, compiler will read/link libraries from /usr/lib directory to our program during compilation process. Library are precompiled object files To link our programs with libraries like pthreads and realtime libraries (rt library). gcc <options> program_name.c -lpthread -lrt -lpthread: Link with pthread library à libpthread.so file -lrt: Link with rt library à librt.so file Option here is "-l<library>" Another option "-L<dir>" used to tell gcc compiler search for library file in given <dir> directory. 60

61 Preprocessing Things with # #include <stdio.h> #define REAL float Others Processes the C source files BEFORE handing it to compiler. `Pre`-process gcc E cpp 61

62 File Inclusion Recall : #include <filename> #include <foo.h> System directories #include foo.h Current directories gcc I/usr/include to specify where to search those header files gcc I/usr/include sum_full.c o sum Preprocessing replaces the line #include <foo.h> with the content of the file foo.h 62

63 Macros Define and replaced by preprocessing Every occurrence of REAL will be replaced with float before compilation. 63

64 About printf in C printf( format string,vars); Format string? This year is %d\n Your score is %d\n Conversion by % %d : int %f : float, double %c : char %s : char *, string %e : float, double in scientific form 64

65 Tools and Steps for Program Execution User-created files Makefile C/C++ C/C++ Source Source and and Header Header Files Files Assembly Assembly Source Source Files Files Linker Script File Make Utility preprocessor compiler assembler Archive Utility Library Library Files Files Object Object Files Files Linker and Locator Shared Object File Linkable Image File Executable Image File Link Map File 65

66 Loading and Introducing Memory To load a file from disk into memory Loading: To execute a file, e.g../ is to specify the path of sum file To execute any linux command, e.g. ls, cd, etc. Right-click an app icon to execute the app System search your file from folders specified in PATH env echo $PATH The runtime instance of an executable is called a process It occupies memory, It uses resources (files, sockets, driver, etc). It executes its threads (machine instructions). See the processes of the system using ps command, Windows task manager, and Mac OS X Activity Monitor 66

67 Computer Memory Addressing Memory is byte-addressed linearly A process can access 2 16 (64K), 2 32 (4G) or 2 64 bytes of memory depending on whether your computer is 16, 32 or 64 bit addressing 67

68 Data, Address and Pointer 68

69 End of Lecture 05 69

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. Translating and starting a program. High level languages, Assembly languages and object code. Subroutine

More information

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp)

A software view. Computer Systems. The Compilation system. How it works. 1. Preprocesser. 1. Preprocessor (cpp) A software view User Interface Computer Systems MTSU CSCI 3240 Spring 2016 Dr. Hyrum D. Carroll Materials from CMU and Dr. Butler How it works hello.c #include int main() { printf( hello, world\n

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program.

Language Translation. Compilation vs. interpretation. Compilation diagram. Step 1: compile. Step 2: run. compiler. Compiled program. program. Language Translation Compilation vs. interpretation Compilation diagram Step 1: compile program compiler Compiled program Step 2: run input Compiled program output Language Translation compilation is translation

More information

Compilation, Disassembly, and Profiling (in Linux)

Compilation, Disassembly, and Profiling (in Linux) Compilation, Disassembly, and Profiling (in Linux) CS 485: Systems Programming Spring 2016 Instructor: Neil Moore 1 Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc O1 p1.c

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 2: Hello World! Cristina Nita-Rotaru Lecture 2/ Fall 2013 1 Introducing C High-level programming language Developed between 1969 and 1973 by Dennis Ritchie at the Bell Labs

More information

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2 CS 220: Introduction to Parallel Computing Beginning C Lecture 2 Today s Schedule More C Background Differences: C vs Java/Python The C Compiler HW0 8/25/17 CS 220: Parallel Computing 2 Today s Schedule

More information

Introduction to Supercomputing

Introduction to Supercomputing Introduction to Supercomputing TMA4280 Introduction to UNIX environment and tools 0.1 Getting started with the environment and the bash shell interpreter Desktop computers are usually operated from a graphical

More information

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory

Draft. Chapter 1 Program Structure. 1.1 Introduction. 1.2 The 0s and the 1s. 1.3 Bits and Bytes. 1.4 Representation of Numbers in Memory Chapter 1 Program Structure In the beginning there were 0s and 1s. GRR 1.1 Introduction In this chapter we will talk about memory: bits, bytes and how data is represented in the computer. We will also

More information

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems

Programs. Function main. C Refresher. CSCI 4061 Introduction to Operating Systems Programs CSCI 4061 Introduction to Operating Systems C Program Structure Libraries and header files Compiling and building programs Executing and debugging Instructor: Abhishek Chandra Assume familiarity

More information

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005

Systems Programming. Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Systems Programming Fatih Kesgin &Yusuf Yaslan Istanbul Technical University Computer Engineering Department 18/10/2005 Outline How to assemble and link nasm ld gcc Debugging Using gdb; breakpoints,registers,

More information

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

Basic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:

More information

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006 C Compilation Model Comp-206 : Introduction to Software Systems Lecture 9 Alexandre Denault Computer Science McGill University Fall 2006 Midterm Date: Thursday, October 19th, 2006 Time: from 16h00 to 17h30

More information

Memory and C/C++ modules

Memory and C/C++ modules Memory and C/C++ modules From Reading #5 and mostly #6 More OOP topics (templates; libraries) as time permits later Program building l Have: source code human readable instructions l Need: machine language

More information

From Code to Program: CALL Con'nued (Linking, and Loading)

From Code to Program: CALL Con'nued (Linking, and Loading) ecture 13 Computer Science 61C Spring 2017 February 15th, 2017 From Code to Program: CALL Con'nued (Linking, and Loading) 1 Administrivia We know it still sucks but: Waitlist students: Please be patient.

More information

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading)

CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) CS 61C: Great Ideas in Computer Architecture CALL continued ( Linking and Loading) Instructors: Nicholas Weaver & Vladimir Stojanovic http://inst.eecs.berkeley.edu/~cs61c/sp16 1 Where Are We Now? 2 Linker

More information

Lecture 3: Instruction Set Architecture

Lecture 3: Instruction Set Architecture Lecture 3: Instruction Set Architecture CSE 30: Computer Organization and Systems Programming Summer 2014 Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1. Steps

More information

Executables and Linking. CS449 Spring 2016

Executables and Linking. CS449 Spring 2016 Executables and Linking CS449 Spring 2016 Remember External Linkage Scope? #include int global = 0; void foo(); int main() { foo(); printf( global=%d\n, global); return 0; } extern int

More information

Essentials for Scientific Computing: Source Code, Compilation and Libraries Day 8

Essentials for Scientific Computing: Source Code, Compilation and Libraries Day 8 Essentials for Scientific Computing: Source Code, Compilation and Libraries Day 8 Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Introduction In the first session we discussed instructions that the CPU processes

More information

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science

High Performance Computing Lecture 1. Matthew Jacob Indian Institute of Science High Performance Computing Lecture 1 Matthew Jacob Indian Institute of Science Agenda 1. Program execution: Compilation, Object files, Function call and return, Address space, Data & its representation

More information

How Compiling and Compilers Work

How Compiling and Compilers Work How Compiling and Compilers Work Dr. Axel Kohlmeyer Research Professor, Department of Mathematics Associate Director, Institute for Computational Science Assistant Vice President for High-Performance Computing

More information

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass.

CIT 595 Spring System Software: Programming Tools. Assembly Process Example: First Pass. Assembly Process Example: Second Pass. System Software: Programming Tools Programming tools carry out the mechanics of software creation within the confines of the operating system and hardware environment Linkers & Loaders CIT 595 Spring 2010

More information

C03c: Linkers and Loaders

C03c: Linkers and Loaders CISC 3320 MW3 C03c: Linkers and Loaders Hui Chen Department of Computer & Information Science CUNY Brooklyn College 2/4/2019 CUNY Brooklyn College: CISC 3320 OS 1 Outline Linkers and linking Loaders and

More information

CS 107 Lecture 18: GCC and Make

CS 107 Lecture 18: GCC and Make S 107 Lecture 18: G and Make Monday, March 12, 2018 omputer Systems Winter 2018 Stanford University omputer Science Department Lecturers: Gabbi Fisher and hris hute Today's Topics 1. What really happens

More information

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng

Slide Set 4. for ENCM 369 Winter 2018 Section 01. Steve Norman, PhD, PEng Slide Set 4 for ENCM 369 Winter 2018 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary January 2018 ENCM 369 Winter 2018 Section

More information

Compiler Theory. (GCC the GNU Compiler Collection) Sandro Spina 2009

Compiler Theory. (GCC the GNU Compiler Collection) Sandro Spina 2009 Compiler Theory (GCC the GNU Compiler Collection) Sandro Spina 2009 GCC Probably the most used compiler. Not only a native compiler but it can also cross-compile any program, producing executables for

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (yaseminb@kth.se) Overview Overview Roots of C Getting started with C Closer look at Hello World Programming Environment Discussion Basic Datatypes and printf Schedule Introduction to C - main part of

More information

Executables and Linking. CS449 Fall 2017

Executables and Linking. CS449 Fall 2017 Executables and Linking CS449 Fall 2017 Remember External Linkage Scope? #include int global = 0; void foo(); int main() { } foo(); printf( global=%d\n, global); return 0; extern int

More information

Compila(on, Disassembly, and Profiling

Compila(on, Disassembly, and Profiling Compila(on, Disassembly, and Profiling (in Linux) CS 485: Systems Programming Fall 2015 Instructor: James Griffioen 1 Recall the compila(on process/steps 2 Turning C into Object Code Code in files p1.c

More information

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; }

Modifiers. int foo(int x) { static int y=0; /* value of y is saved */ y = x + y + 7; /* across invocations of foo */ return y; } Modifiers unsigned. For example unsigned int would have a range of [0..2 32 1] on a 32-bit int machine. const Constant or read-only. Same as final in Java. static Similar to static in Java but not the

More information

EE458 - Embedded Systems Lecture 4 Embedded Devel.

EE458 - Embedded Systems Lecture 4 Embedded Devel. EE458 - Embedded Lecture 4 Embedded Devel. Outline C File Streams References RTC: Chapter 2 File Streams man pages 1 Cross-platform Development Environment 2 Software available on the host system typically

More information

ECE 15B COMPUTER ORGANIZATION

ECE 15B COMPUTER ORGANIZATION ECE 15B COMPUTER ORGANIZATION Lecture 17 Executing Programs: Compiling, Assembling, Linking and Loading (Part II) Project #3 Due June 10, 5pm Announcements Submit via email Homework #4 Due June 5, 5pm

More information

Programming Tools. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore

Programming Tools. Venkatanatha Sarma Y. Lecture delivered by: Assistant Professor MSRSAS-Bangalore Programming Tools Lecture delivered by: Venkatanatha Sarma Y Assistant Professor MSRSAS-Bangalore 1 Session Objectives To understand the process of compilation To be aware of provisions for data structuring

More information

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring

Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring Hand-on Labs for Chapter 1 and Appendix A CSCE 212 Introduction to Computer Architecture, Spring 2019 https://passlab.github.io/csce212/ Department of Computer Science and Engineering Yonghong Yan yanyh@cse.sc.edu

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Lec 13: Linking and Memory. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

Lec 13: Linking and Memory. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements Lec 13: Linking and Memory Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University PA 2 is out Due on Oct 22 nd Announcements Prelim Oct 23 rd, 7:30-9:30/10:00 All content up to Lecture on Oct

More information

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures

Review (1/2) IEEE 754 Floating Point Standard: Kahan pack as much in as could get away with. CS61C - Machine Structures Review (1/2) CS61C - Machine Structures Lecture 11 - Starting a Program October 4, 2000 David Patterson http://www-inst.eecs.berkeley.edu/~cs61c/ IEEE 754 Floating Point Standard: Kahan pack as much in

More information

Errors During Compilation and Execution Background Information

Errors During Compilation and Execution Background Information Errors During Compilation and Execution Background Information Preprocessor Directives and Compilation #define - defines a macro, identified by . During compilation, all instances of

More information

Computer Systems Organization

Computer Systems Organization Computer Systems Organization 1 Outline 2 A software view User Interface 3 How it works 4 The gcc compilation system 5 The gcc compilation system hello.c (source code) Pre-processor (cpp) hello.i (modified

More information

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions

Orange Coast College. Business Division. Computer Science Department CS 116- Computer Architecture. The Instructions Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture The Instructions 1 1 Topics: Assembly language, assemblers MIPS R2000 Assembly language Instruction set

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 6: Introduction to C (pronobis@kth.se) Overview Overview Lecture 6: Introduction to C Roots of C Getting started with C Closer look at Hello World Programming Environment Schedule Last time (and

More information

Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 6: A Quick Intro To C. Reading. goto Considered Harmful History Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program

More information

CISC2200 Threads Spring 2015

CISC2200 Threads Spring 2015 CISC2200 Threads Spring 2015 Process We learn the concept of process A program in execution A process owns some resources A process executes a program => execution state, PC, We learn that bash creates

More information

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder

Generating Programs and Linking. Professor Rick Han Department of Computer Science University of Colorado at Boulder Generating Programs and Linking Professor Rick Han Department of Computer Science University of Colorado at Boulder CSCI 3753 Announcements Moodle - posted last Thursday s lecture Programming shell assignment

More information

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13

C: Program Structure. Department of Computer Science College of Engineering Boise State University. September 11, /13 Department of Computer Science College of Engineering Boise State University September 11, 2017 1/13 Scope Variables and functions are visible from the point they are defined until the end of the source

More information

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview

Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring Topic Notes: C and Unix Overview Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009 Topic Notes: C and Unix Overview This course is about computer organization, but since most of our programming is

More information

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

MIPS (SPIM) Assembler Syntax

MIPS (SPIM) Assembler Syntax MIPS (SPIM) Assembler Syntax Comments begin with # Everything from # to the end of the line is ignored Identifiers are a sequence of alphanumeric characters, underbars (_), and dots () that do not begin

More information

PRACE Autumn School Basic Programming Models

PRACE Autumn School Basic Programming Models PRACE Autumn School 2010 Basic Programming Models Basic Programming Models - Outline Introduction Key concepts Architectures Programming models Programming languages Compilers Operating system & libraries

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

EC 413 Computer Organization

EC 413 Computer Organization EC 413 Computer Organization Review I Prof. Michel A. Kinsy Computing: The Art of Abstraction Application Algorithm Programming Language Operating System/Virtual Machine Instruction Set Architecture (ISA)

More information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 6, 2017 at 18:02 CS429 Slideset C: 1 Topics Simple C programs:

More information

Topics. CS429: Computer Organization and Architecture. File Inclusion. A Simple C Program. Intro to C

Topics. CS429: Computer Organization and Architecture. File Inclusion. A Simple C Program. Intro to C Topics CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: June 7, 2018 at 08:22 Simple C programs: basic structure,

More information

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview Computer Science 322 Operating Systems Mount Holyoke College Spring 2010 Topic Notes: C and Unix Overview This course is about operating systems, but since most of our upcoming programming is in C on a

More information

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization

CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Spring 2013 CSE2421 Systems1 Introduction to Low-Level Programming and Computer Organization Kitty Reeves TWRF 8:00-8:55am 1 Compiler Drivers = GCC When you invoke GCC, it normally does preprocessing,

More information

COS 318: Operating Systems

COS 318: Operating Systems COS 318: Operating Systems Overview Kai Li Computer Science Department Princeton University (http://www.cs.princeton.edu/courses/cos318/) Important Times Lectures 9/20 Lecture is here Other lectures in

More information

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o CS61C L18 Running a Program I (1) inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 19 Running a Program II aka Compiling, Assembling, Linking, Loading 2006-10-11 (aka 2006-0xB)

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C

Outline. Lecture 1 C primer What we will cover. If-statements and blocks in Python and C. Operators in Python and C Lecture 1 C primer What we will cover A crash course in the basics of C You should read the K&R C book for lots more details Various details will be exemplified later in the course Outline Overview comparison

More information

CS 550 Operating Systems Spring Process I

CS 550 Operating Systems Spring Process I CS 550 Operating Systems Spring 2018 Process I 1 Process Informal definition: A process is a program in execution. Process is not the same as a program. Program is a passive entity stored in the disk Process

More information

Computer and Information Sciences College / Computer Science Department CS 207 D. Computer Architecture

Computer and Information Sciences College / Computer Science Department CS 207 D. Computer Architecture Computer and Information Sciences College / Computer Science Department CS 207 D Computer Architecture The Computer Revolution Progress in computer technology Underpinned by Moore s Law Makes novel applications

More information

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o

Review C program: foo.c Compiler Assembly program: foo.s Assembler Object(mach lang module): foo.o CS61C L18 Running a Program I (1) inst.eecs.berkeley.edu/~cs61c UC Berkeley CS61C : Machine Structures Lecture 19 Running a Program II aka Compiling, Assembling, Linking, Loading 2007-03-02 Lecturer SOE

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Lecture 10: Program Development versus Execution Environment

Lecture 10: Program Development versus Execution Environment Lecture 10: Program Development versus Execution Environment CSE 30: Computer Organization and Systems Programming Winter 2010 Rajesh Gupta / Ryan Kastner Dept. of Computer Science and Engineering University

More information

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3 Hello, World! in C Johann Myrkraverk Oskarsson October 23, 2018 Contents 1 The Quintessential Example Program 1 I Printing Text 2 II The Main Function 3 III The Header Files 4 IV Compiling and Running

More information

Making Address Spaces Smaller

Making Address Spaces Smaller ICS332 Operating Systems Spring 2018 Smaller Address Spaces Having small address spaces is always a good idea This is good for swapping: don t swap as often (because if address spaces are small, then RAM

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one

More information

Embedded Systems Programming

Embedded Systems Programming Embedded Systems Programming OS Linux - Toolchain Iwona Kochańska Gdansk University of Technology Embedded software Toolchain compiler and tools for hardwaredependent software developement Bootloader initializes

More information

Response Time and Throughput

Response Time and Throughput Response Time and Throughput Response time How long it takes to do a task Throughput Total work done per unit time e.g., tasks/transactions/ per hour How are response time and throughput affected by Replacing

More information

assembler Machine Code Object Files linker Executable File

assembler Machine Code Object Files linker Executable File CSCE A211 Programming Intro What is a Programming Language Assemblers, Compilers, Interpreters A compiler translates programs in high level languages into machine language that can be executed by the computer.

More information

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger.

CS 110 Computer Architecture. Lecture 2: Introduction to C, Part I. Instructor: Sören Schwertfeger. CS 110 Computer Architecture Lecture 2: Introduction to C, Part I Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University

More information

COSC350 System Software

COSC350 System Software COSC350 System Software Topics: The UNIX/Linux Operating System Basics UNIX/Linux basic commands, login scripts and environment set up, C programming environment, introduction to basic shell scripts Working

More information

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University

COS 318: Operating Systems. Overview. Andy Bavier Computer Science Department Princeton University COS 318: Operating Systems Overview Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall10/cos318/ Logistics Precepts: Tue: 7:30pm-8:30pm, 105 CS

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

Lecture 4: MIPS Instruction Set

Lecture 4: MIPS Instruction Set Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software

More information

CS333 Intro to Operating Systems. Jonathan Walpole

CS333 Intro to Operating Systems. Jonathan Walpole CS333 Intro to Operating Systems Jonathan Walpole Threads & Concurrency 2 Threads Processes have the following components: - an address space - a collection of operating system state - a CPU context or

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations

More information

ECE 471 Embedded Systems Lecture 4

ECE 471 Embedded Systems Lecture 4 ECE 471 Embedded Systems Lecture 4 Vince Weaver http://www.eece.maine.edu/ vweaver vincent.weaver@maine.edu 12 September 2013 Announcements HW#1 will be posted later today For next class, at least skim

More information

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14

COSC 2P91. Introduction Part Deux. Week 1b. Brock University. Brock University (Week 1b) Introduction Part Deux 1 / 14 COSC 2P91 Introduction Part Deux Week 1b Brock University Brock University (Week 1b) Introduction Part Deux 1 / 14 Source Files Like most other compiled languages, we ll be dealing with a few different

More information

CSC258: Computer Organization. Functions and the Compiler Tool Chain

CSC258: Computer Organization. Functions and the Compiler Tool Chain CSC258: Computer Organization Functions and the Compiler Tool Chain 1 A Note about This Week s Quiz There were very few exercises this week, except for writing substantial pieces of code. Instead, I provided

More information

LC-3 Assembly Language

LC-3 Assembly Language Chapter 7 LC-3 Assembly Language CS Reality You ve got to know assembly Chances are, you ll never write program in assembly Compilers are much better & more patient than you are Understanding assembly

More information

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers

CSE 2421: Systems I Low-Level Programming and Computer Organization. Linking. Presentation N. Introduction to Linkers CSE 2421: Systems I Low-Level Programming and Computer Organization Linking Read/Study: Bryant 7.1 7.10 Gojko Babić 11-15-2017 Introduction to Linkers Linking is the process of collecting and combining

More information

Where Are We Now? Linker (1/3) Linker (2/3) Four Types of Addresses we ll discuss. Linker (3/3)

Where Are We Now? Linker (1/3) Linker (2/3) Four Types of Addresses we ll discuss. Linker (3/3) inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Where Are We Now? Lecture 19 Running a Program II (Compiling, Assembling, Linking, Loading) Lecturer SOE Dan Garcia 2008-03-06 20000 15000 10000

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture C.A.L.L. July 7, 2014 Review Three different instruction formats designed to be as similar as possible, while still handling all instructions: R: opcode rs rt rd shamt funct I: opcode rs rt immediate J:

More information

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading)

CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) CS 110 Computer Architecture Running a Program - CALL (Compiling, Assembling, Linking, and Loading) Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology

More information

CS3350B Computer Architecture CPU Performance and Profiling

CS3350B Computer Architecture CPU Performance and Profiling CS3350B Computer Architecture CPU Performance and Profiling Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada

More information

Laboratory 1 Semester 1 11/12

Laboratory 1 Semester 1 11/12 CS2106 National University of Singapore School of Computing Laboratory 1 Semester 1 11/12 MATRICULATION NUMBER: In this lab exercise, you will get familiarize with some basic UNIX commands, editing and

More information

CALL (Compiler/Assembler/Linker/ Loader)

CALL (Compiler/Assembler/Linker/ Loader) CALL (Compiler/Assembler/Linker/ Loader) 1 Integer Multiplication (1/3) Paper and pencil example (unsigned): Multiplicand 1000 8 Multiplier x1001 9 1000 0000 0000 +1000 01001000 72 m bits x n bits = m

More information

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4 Beyond this course Readings: CP:AMA 2.1, 15.4 CS 136 Spring 2018 13: Beyond 1 Machine code In Section 04 we briefly discussed compiling: converting source code into machine code so it can be run or executed.

More information

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory CSCI341 Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory REVIEW Assemblers understand special commands called directives Assemblers understand macro commands Assembly programs become

More information

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process

More information

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011 Oregon State University School of Electrical Engineering and Computer Science CS 261 Recitation 1 Spring 2011 Outline Using Secure Shell Clients GCC Some Examples Intro to C * * Windows File transfer client:

More information

ECE 486/586. Computer Architecture. Lecture # 7

ECE 486/586. Computer Architecture. Lecture # 7 ECE 486/586 Computer Architecture Lecture # 7 Spring 2015 Portland State University Lecture Topics Instruction Set Principles Instruction Encoding Role of Compilers The MIPS Architecture Reference: Appendix

More information

Sep 12, 2006 Lecture 2: System Programming

Sep 12, 2006 Lecture 2: System Programming Sep 12, 2006 Lecture 2: System Programming September 19, 2007 1 Introduction In this lecture, we will introduce the basics of systems programming using the language of choice C language. We also introduce

More information

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course

introduction week 1 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 imperative programming about the course week 1 introduction Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 20 class format 30 minutes (give or take a few) presentation 60 minutes (give or take a few) practice

More information

C - Basics, Bitwise Operator. Zhaoguo Wang

C - Basics, Bitwise Operator. Zhaoguo Wang C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled

More information

Introduction to Computer Systems

Introduction to Computer Systems CS-213 Introduction to Computer Systems Yan Chen Topics: Staff, text, and policies Lecture topics and assignments Lab rationale CS 213 F 06 Teaching staff Instructor TA Prof. Yan Chen (Thu 2-4pm, Tech

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives

More information

Cross Compiling. Real Time Operating Systems and Middleware. Luca Abeni

Cross Compiling. Real Time Operating Systems and Middleware. Luca Abeni Cross Compiling Real Time Operating Systems and Middleware Luca Abeni luca.abeni@unitn.it The Kernel Kernel OS component interacting with hardware Runs in privileged mode (Kernel Space KS) User Level Kernel

More information