Software structure and distribution How to share your code with the rest of the world Why it has to be… AA: Kurtis AB: YongChul

Slides:



Advertisements
Similar presentations
Copyright 2013 – Noah Mendelsohn Compiling C Programs Noah Mendelsohn Tufts University Web:
Advertisements

9.0 EMBEDDED SOFTWARE DEVELOPMENT TOOLS 9.1 Introduction Application programs are typically developed, compiled, and run on host system Embedded programs.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
Guide To UNIX Using Linux Third Edition
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
Operating Systems Concepts 1. A Computer Model An operating system has to deal with the fact that a computer is made up of a CPU, random access memory.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
1 uClinux course Day 3 of 5 The uclinux toolchain, elf format and ripping a “hello world”
Introduction to The Linaro Toolchain Embedded Processors Training Multicore Software Applications Literature Number: SPRPXXX 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
System Calls 1.
SCRAM Software Configuration, Release And Management Background SCRAM has been developed to enable large, geographically dispersed and autonomous groups.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
1 Further C  Multiple source code file projects  Structs  The preprocessor  Pointers.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
MIPS coding. SPIM Some links can be found such as:
Copyright 2001 Oxford Consulting, Ltd1 January Storage Classes, Scope and Linkage Overview Focus is on the structure of a C++ program with –Multiple.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Old Chapter 10: Programming Tools A Developer’s Candy Store.
Scons Writing Solid Code Overview What is scons? scons Basics Other cools scons stuff Resources.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 12/6/2006 Lecture 24 – Profilers.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
National Center for Supercomputing ApplicationsNational Computational Science Grid Packaging Technology Technical Talk University of Wisconsin Condor/GPT.
Covenant College November 27, Laura Broussard, Ph.D. Professor COS 131: Computing for Engineers Chapter 5: Functions.
Oracle Data Integrator Agents. 8-2 Understanding Agents.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
1 CS503: Operating Systems Spring 2014 Part 0: Program Structure Dongyan Xu Department of Computer Science Purdue University.
Slide Advanced Programming 2004, based on LY Stefanus's slides Native Methods.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: Operating-System Structures.
Introduction to OOP CPS235: Introduction.
Chapter 1 Basic Concepts of Operating Systems Introduction Software A program is a sequence of instructions that enables the computer to carry.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
How to configure, build and install Trilinos November 2, :30-9:30 a.m. Jim Willenbring.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
C++ Functions A bit of review (things we’ve covered so far)
1 Building a program in C: Preprocessor, Compilation and Linkage.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Lecture 1 Page 1 CS 111 Summer 2013 Important OS Properties For real operating systems built and used by real people Differs depending on who you are talking.
CLHEP Infrastructure Improvements CHEP 2004 Lynn Garren, FNAL and Andreas Pfeiffer, CERN.
Building programs LinuxChix-KE. What happens in your CPU? ● It executes a small set of instructions called "machine code" ● Each instruction is just a.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 18 – Linking and Libraries.
Programs – Preprocessing, Compilation and Linking
Lecture 3 Translation.
Development Environment
Operating System Structure
Visit for more Learning Resources
User-Written Functions
Software Development with uMPS
C Basics.
Chapter 2: Operating-System Structures
Operation System Program 4
Computer Science I CSC 135.
Ch 2 - Overview Interacting with services provided by the OS
9.0 EMBEDDED SOFTWARE DEVELOPMENT TOOLS
Outline (Chapters 1 and 2)
Advanced UNIX progamming
Outline Chapter 2 (cont) OS Design OS structure
CSE 303 Concepts and Tools for Software Development
System calls….. C-program->POSIX call
SPL – PS1 Introduction to C++.
Presentation transcript:

Software structure and distribution How to share your code with the rest of the world Why it has to be… AA: Kurtis AB: YongChul

2/36 Overview  You’ve already “shared code” Example 1: sharing your code with you  You write a method as part of some application  You invoke it from multiple places Example 2: sharing some else’s code  You run Firefox  There are many techniques in between  The spectrum illustrates some design principles (or at least issues)

3/36 General Issues  How hard is it for the user to make use of the shared code? What “environment” is required? How wide is the potential audience?  How flexible is the code? What decisions are hard coded? What can be customized by each user? How? Are “easy to use” and “flexible” antonyms?  To what extent does the shared code help the user debug misuse? Not just “if you use it correctly, you get the following results,” but also anticipating common problems and helping users get over them  Example: documentation vs. hotline vs. open source vs. informational error messages  How efficient is it to simply invoke the code?

4/36 Basic Options  Distribute an application Example: Firefox  Distribute object (compiled) code: Example: standard C library (Java API)  Distribute souce: Example: skeleton code in assignments We’ll assume code is written in C, but for many of the issues it really doesn’t matter (for some it does).

5/36 Why C? - portability  C compiler is the first compiler when a new platform is established Omnipresence  Fast If it is well-written  Source level compatibility Reuse source codes Philosophy of UNIX family Compile & Install & Run in new platform  Binary level compatibility? Any ideas? Talk about it later

6/36 Why source level compatibility?  Because there are more than 150 OSes 1BSD/2BSD/3BSD/4BSD/4.4BSD Lite 1/4.4BSD Lite 2/386 BSD/Acorn RISC iX/Acorn RISC Unix/AIX/AIX PS/2/AIX/370/AIX/6000/AIX/ESA/AIX/RT/AMiX/AOS Lite/AOS Reno/ArchBSD/ASV/Atari Unix/A/UX/BOS/BRL Unix/BSD Net/1/BSD Net/2/BSD/386/BSD/OS/CB Unix/Chorus/Chorus/MiX/Coherent/CTIX/CXOS/Darwin/Debian GNU/Hurd/DEC OSF/1 ACP/Digital Unix/DragonFly BSD/Dynix/Dynix/ptx/ekkoBSD/Eunice/FireFly BSD/FreeBSD/GNU/GNU-Darwin/Gnuppix GNU/Hurd-L4/HPBSD/HP-UX/HP-UX BLS/IBM AOS/IBM IX/370/Interactive 386/ix/Interactive IS/IRIX/Linux/Lites/LSX/Mac OS X/Mac OS X Server/Mach/MERT/MicroBSD/Mini Unix/Minix/Minix-VMD/MIPS OS RISC/os/MirBSD/Mk Linux/Monterey/more/BSD/mt Xinu/MVS/ESA OpenEdition/NetBSD/NeXTSTEP/NonStop-UX/Open Desktop/Open UNIX/OpenBSD/OpenServer/OpenSolaris/OPENSTEP/OS/390 OpenEdition/OS/390 Unix/OSF/1/PC-BSD/PC/IX/Plan 9/Plurix new/PWB/PWB/UNIX/QNX/QNX RTOS/QNX/Neutrino/QUNIX/ReliantUnix/Rhapsody/RISC iX/RT/SCO UNIX/SCO UnixWare/SCO Xenix/SCO Xenix System V/386/Security-Enhanced Linux/Silver OS/Sinix/Sinix ReliantUnix/Solaris/SPIX/SunOS/Triance OS/Tru64 Unix/Trusted IRIX/B/Trusted Solaris/Trusted Xenix/TS/Tunis/UCLA Locus/UCLA Secure Unix/Ultrix/Ultrix 32M/Ultrix-11/Unicos/Unicos/mk/Unicos/mp/Unicox-max/UNICS/UNIX 32V/UNIX Interactive/UNIX System III/UNIX System IV/UNIX System V/UNIX System V Release 2/UNIX System V Release 3/UNIX System V Release 4/UNIX System V/286/UNIX System V/386/UNIX Time-Sharing System/UnixWare/UNSW/USG/Venix/Xenix OS/Xinu/xMach/z/OS Unix System Services/ -- From  # of required distributions # of binary distribution = SUM(# of architectures supported by each OS) # of source distribution = 1  But the user has to compile it in their systems

7/36 Option 1 – Distribute a.exe

8/36 Option 1: Distribute a.exe  What does the user have to do to take advantage of your code?  How many different types of systems can y our code run on?  What assumptions does your code make about the configuration of the user’s machine?

9/36 Option 2: Distribute a library

10/36 Option 2: Distribute a library  What does the user have to do to take advantage of your code?  How many different types of systems can y our code run on?  What assumptions does your code make about the configuration of the user’s machine?

11/36 Library  Real life You want to solve a very difficult equation Will you devise a new numerical analysis method?  Programming You want to store your 1G data in B+-tree Will you write your own B+-tree?  Save your time! There are well-defined numerical analysis methods There are plenty of B+-tree implementations In “Library”

12/36 A library  IS A file contains a collection of precompiled functions  HAS An index of the functions in library  COMES WITH Header files to let C compiler do type-checking on the parameters and return type  Header file has Definitions of data structures Declarations of functions

13/36 Link library with program  Before linking Your object file(.o) contains a lot of holes where you make function calls  Linking Append compiled functions to your binary Fill out the holes with address in your binary  Does every program have a copy of the printf() source?! No.

14/36 Shared library  There are tooo common functions Why don’t we share the code instead copy to every program?  Shared library Only one copy in the disk Linker will specially tag the holes Loader will fill out the holes while your program is being loaded into memory  Reference

15/36 Option 3 – Distribute source

16/36 Writing code - functions  Can we use any function in our programs? Standard C library POSIX  What if we use platform dependent functions? BSD 4, UNIX System V GNU Linux/Mac OS X/Win32  Your program won’t be compiled! 

17/36 Writing code - functions  But the non-standard function I used is so convenient! I know. But then you sacrifice the portability  What shall we do then? Implement our own Use a portable library  Example bzero(char *,int)  BSD specific. Fill given buffer with zero How can we fix it?

18/36 Writing code – allowing customization  How can a user interact with your program? No. GUI is not a right answer here. (A GUI is an application all on its own…) Command line  Is command line enough? User ID/Current working directory/Home directory/OS/Hostname/Path/Login shell/Language/… These are useful common information to every program you run  Environment variable NAME=VALUE pairs Define the runtime environment per user

19/36 Environment variable  System wide environment OS/HOSTNAME  User specific environment HOME/PWD/TERM/SHELL/PROMPT/LANG/LOCALE  System wide default environment PATH/MANPATH/PAGER/LANG/LOCALE Can be overridden by user  Program can use implicit information Default behavior  They are passed down to the processes you invoke By your shell!

20/36 How can we use them?  By using getenv(3), setenv(3) setenv or putenv are not standard functions  Where the environment variables are stored? Usually below your stack Have a look at execve(2) int execve(const char *filename, char *const argv[], char *const envp[]); CODE DATA HEAP STACK ARGV ENV KERNEL

Build the application you distribute

22/36 Problem: tools  Now we need to build our programs  What do we use? At least preprocessor, C compiler, assembler, linker Libraries Platform specific functions  Problem? What if the names of the programs are different? What if the paths to the programs are different? What if the programs accept different options? What if the versions of the programs are different? …

23/36 More problems: source  We have implemented our own functions for the portability What if the platform has the function already? What if the platform does not have the function?  We have used a library for the portability What if the library does not exist? What if they have different library which has the same interface? What if the header and library files are in different location?

24/36 Solution to source problem  How can we address the source related problems? By conditional compilation #define, #if, #else, #elif, #endif  Typical usage #if HAVE_FUNC1 Use func1 #else Use our own implementation #endif  Define constants whether we can use specific features in current system Results in a huge header file which contains the information

25/36 Solution to tool problem  We can use variables in Makefile  Substitute the names of tools to variables gcc –o myprog myprog.o myprog1.o $(CC) –o myprog myprog.o myprog1.o  Append include path and library path gcc –I/usr/local/myprog/include –o myprog … $(CC) $(INC_PATH) –o myprog …  Now only need to fill the variables

26/36 Set up the building environment  We need to Construct a header file of feature lists Fill out variables of Makefiles  Nothing we can do except Collect information of building system Generate customized Makefile  Wait… this is just what everybody does! GNU auto* tools  autoconf  automake  libtool Save huge amount of time for this process

27/36 Autoconf  Autoconf Collects information of the current system Generates a header file(config.h) Generates Makefiles from templates(Makefile.am)  What should we do? Describe the libraries & tools & features you use in configure.in Run autoconf it will generate a shell script named configure The script does all dirty works

28/36 Automake  Automake Generates customized Makefile from template using information collected by autoconf  What shall we do? Write template Makefile.am in all directories under your source tree Specify the templates in configure.in Run automake

29/36 Ready to distribute  Congratulations! We have got a portable source distribution!  Now users can compile & install our program by typing./configure  collect information make  compile the source code make install  copy binaries and documents to proper location

30/36 Kernel compile?  Initialize building environment make mrproper  Collecting information make menuconfig  Compile make or make bzImage  Install make install  Exactly what we have covered!

31/36 Pros & Cons  Source distribution  Binary distribution

32/36 Case study: Java  Can we distribute binary? Why?  Do we need to distribute source code? Why?  Do we need to collect information of the system? Why?  Are there concepts of header file and library file? What are they?  Are there any concepts similar to environment variable? What are they?

33/36 Case study: Windows  Can we distribute binary? Why?  Do we need to distribute source code? Why?  Do we need to collect information of the system? Why?  Are there concepts of header file and library file? What are they?  Are there any concepts similar to environment variable? What are they?

Sample reasoning

35/36 Case study: Java  Can we distribute binary? Yes. If they are compiled in lower version of byte code specification.  Do we need to distribute source code? Not necessary. But it helps people those who want to optimize the program in their environment  Do we need to collect information of the system? Yes. Especially if the program interacts with other programs. Or to check whether there are required class libraries  Are there concepts of header file and library file? Each class file contains all information about return type and parameter types as well as binary code Compiler can do type-checking if it can find the classes Classloader does loading and linking in runtime  Are there any concepts similar to environment variable? java.lang.System.getProperty() = getenv() java.lang.System.setProperty() = setenv() or putenv()

36/36 Case study: Windows  Can we distribute binary? Yes. Because windows only supports x86 architecture. Well, let’s ignore Windows for Alpha platform  Do we need to distribute source code? Not necessary. But it helps people those who want to optimize the program in their environment.  Do we need to collect information of the system? Not necessary unless the program requires other programs or libraries.  Are there concepts of header file and library file? Yes. It is basically written in C/C++.  Are there any concepts similar to environment variable? There are environment variables just like UNIX. Type ‘set’ in cmd.exe Registry