Week6-Processes - Compilers, Interpreters, Libraries...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Compilers, Interpreters, Libraries Comparing compilers and interpreters Shared vs. non-shared libraries.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Compiler vs. Interpreter • Somehow we need to convert a program into machine code (object code). • A compiler passes over a whole program before translating it into object code. • An interpreter reads and executes one line of code at a time. • An interpreter is a compiled program (often written in C).
Background image of page 2
3 Preprocessor does text replacement – #include replaced by the text of the included file. – #define macros replaced throughout each file. Compiler parses the program, performs optimization, and produces assembly code. Assembler translates assembly code into machine code. Linker combines object files and libraries into an executable file. It resolves any remaining symbol references. C/C++ compiler
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Java Compiler/Interpreter Compiler translates program to byte code. • The JVM is a byte code interpreter that translates byte code to machine code. • Byte codes implement fine grain primitives. They are generic enough that other languages may be compiled to Java byte code.
Background image of page 4
5 Shell Interpreter • The interpreter is a C program! • The shell interpreter is the program executed when you write #!/bin/sh • Each line of a shell script is input to a C program that parses the line, and determines how to execute it.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Standard Libraries • System calls are not part of the C language definition. • System calls are defined in libraries (.a .so) • Libraries typically contain many .o object files. • To create your own library archive file: ar crv mylib.a *.o • Look in /usr/lib and /usr/local/lib for system libraries.
Background image of page 6
7 Shared Libraries • .a libraries are not shared. The functions used are copied into the executable of your program. – size bloat when lots of processes use the same libraries – performance and portability are the wins • .so libraries are shared. One copy exists in memory, and all programs using that library link to it to access library functions. – reduces total memory usage when multiple processes use the shared library. – small performance hit as extra work must be done either when a library function is called, or at the beginning. – many tradeoffs and variations between OS’s
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Shared vs. Non-Shared Libraries printf printf copy libc.a main(){ printf() } myprog Non-shared printf libc.so main(){ printf() } myprog Shared link
Background image of page 8
System calls • Perform a subroutine call directly to the Unix kernel. • libc
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 36

Week6-Processes - Compilers, Interpreters, Libraries...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online