Software Engineering 3156 19-Nov-01 #21: Language II Phil Gross.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Chapter 1 Chapter 2 Chapter 3 Code Gone Wrong Random 5 pt 5 pt 5 pt
CS1061: C Programming Lecture 21: Dynamic Memory Allocation and Variations on struct A. O’Riordan, 2004, 2007 updated.
Kernighan/Ritchie: Kelley/Pohl:
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
Memory Arrangement Memory is arrange in a sequence of addressable units (usually bytes) –sizeof( ) return the number of units it takes to store a type.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
COMS W3156: Software Engineering, Fall 2001 Lecture #20: C, continued Janak J Parekh
COMS W3156: Software Engineering, Fall 2001 Lecture #21: C, C++ Janak J Parekh
Software Engineering Nov-01 #22: OS, Language, Design Patterns Phil Gross.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
CS 61C L4 Structs (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #4: Strings & Structs
Object References. Objects An array is a collection of values, all of the same type An object is a collection of values, which may be of different types.
CS 61C L03 C Arrays (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #3: C Pointers & Arrays
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation –The new operator –The delete operator –Dynamic.
1 I/O Management in Representative Operating Systems.
CS 61C L03 C Arrays (1) A Carle, Summer 2006 © UCB inst.eecs.berkeley.edu/~cs61c/ CS61C : Machine Structures Lecture #3: C Pointers & Arrays
Software Engineering Nov-01 #18: Language I, CVEs, and Databases Phil Gross.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
Java and C++, The Difference An introduction Unit - 00.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 5 Acknowledgements: The syllabus and power point presentations are modified versions.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Variables and Objects, pointers and addresses: Chapter 3, Slide 1 variables and data objects are data containers with names the value of the variable is.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 12: Pointers continued, C strings.
CSC 2400 Computer Systems I Lecture 5 Pointers and Arrays.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
Introduction to Computer Systems and the Java Programming Language.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
CSE 451 – Operating Systems Section, Autumn 2003 TAs: Mike Swift Adrienne Noble
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
University of Washington Today Finished up virtual memory On to memory allocation Lab 3 grades up HW 4 up later today. Lab 5 out (this afternoon): time.
Copyright 2005, The Ohio State University 1 Pointers, Dynamic Data, and Reference Types Review on Pointers Reference Variables Dynamic Memory Allocation.
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Pointers in C Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens Memory and Addresses Memory is just a sequence of byte-sized.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
MORE POINTERS Plus: Memory Allocation Heap versus Stack.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 11: Pointers.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
RealTimeSystems Lab Jong-Koo, Lim
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
Spring 2006 Special Topics in Computer Engineering: Java Intro 1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J.
DYNAMIC MEMORY ALLOCATION. Disadvantages of ARRAYS MEMORY ALLOCATION OF ARRAY IS STATIC: Less resource utilization. For example: If the maximum elements.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Dynamic Allocation in C
Computer Organization and Design Pointers, Arrays and Strings in C
JAVA MULTIPLE CHOICE QUESTION.
The Hardware/Software Interface CSE351 Winter 2013
Pointers, Dynamic Data, and Reference Types
Memory Allocation CS 217.
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Homework Continue with K&R Chapter 5 Skipping sections for now
Java Programming Language
Presentation transcript:

Software Engineering Nov-01 #21: Language II Phil Gross

2 Administrivia Calendar tweak Wednesday class Research Fair – Nov 30 th, 10am-4pm – Intro to Perl & CGI – Nov 20 th, 6-8pm

3 Implementation Notes Chat – Formal/modal – Log messages – Should have distinguished… ChangeOther for bots – MapDelta? – RequestActorChange?

4 And More… Death sequence – Attacked with death=true – KickGame – DeletedObject – If actor, LDAP deletion “Raw” sockets: anyone going to be using these? Integration is … interesting

5 Advanced Programming You can’t take it Because Prof. Schulzrinne is taking hints from our syllabus So, going to try to cover as much of his stuff as possible

6 Review of C Manual compilation and linking – Multiple.o files manually linked into executable Statements and operators the same as Java Fewer datatypes – Everything is really some size of int or float – Including, in particular, booleans and chars – Very weak typing

7 EZ Aggregation struct point { int x; int y; }; struct point pt; pt.x = 3; pt.y = 4;

8 Pointers Integers that represent a machine address Typed, sorta – Pointer to int, pointer to char Declare, dereference with * – int *p; Define with & – int q; p = &q; /* p contains q’s address */

9 More Pointers int x = 7; ip = &x; printf(“%d\n”, *ip); Prints 7 *ip = 9 /* assignment */ printf(“%d\n”, x); Prints 9

10 Pointer Arithmetic If ip == 4C84, after ip++, ip == 4C88 – assuming ints are four bytes This is the meaning of the “type” of a pointer Doesn’t really have arrays, just pointers int a[7]; a ≡ &a[0] ++a ≡ &a[1]

11 C Likes Pointers No strings, just char arrays terminated with 0 Char pointers flying all over the place in a C program Pointers = modifiable args Note three meanings of 0 – Falseness – End-of-String char – Null pointer (guaranteed invalid)

12 C is Minimal i.e. nearly nonexistent runtime services No array/pointer bounds checking – Except for processor halt if you try to dereference 0 Carefree casting – Reinterpret bits as you please: You’re the boss! No exception mechanism Certainly no garbage collection

13 Memory management Everything is primitive by default If you want a block of bytes, just ask void *malloc(int size) int *myString = (int *)malloc(1024 * sizeof(int)); myString is all mine, until I free it – Exactly once, please And if I double-free or don’t free? – I’m F*(&%$!ed

14 Pointers Not Null-initialized char *cp; Copy a bunch of stuff to cp Perfectly legal Totally undefined Disaster Need to allocate space to cp

15 “Right” way char *cp = (char *) malloc (SOMESIZE); Now I can “safely” copy stuff to cp Why all the quotes? What if SOMESIZE isn’t big enough…

16 Systems Programming Unix, Windows (and JVM) all written in C/C++ Couldn’t write a JVM for a bare system in Java Need access to underlying system resources Located at particular memory locations Operating system provides (very) basic services System calls

17 System Calls Man page section 2, not 3 That is the sum total of what an OS does – It usually also comes with a bunch of software Systems programming involves dealing directly with the system calls, or just above

18 Typical System Calls File access Time and date Process management Signals Networking Security

19 File I/O open, creat, close read, write – Pure byte-oriented

20 Unix and Devices Everything’s a file Devices are “special files” Character or block oriented Character devs include some weird things – Mice – Audio Block devices are storage Mknod

21 Filesystems Sorta part of the OS Usually abstracted and modularized Primitive version has one filesystem per “volume” Unix model has “mount points” Hard links vs. soft links

22 Special Filesystems /proc – Virtual filesystem – Access to all kinds of information – Originally processes NFS – Network filesystem – RPC based Journalling Filesystems

23 Processes The fork model Copy on write Vfork

24 Virtual Memory and Paging Memory allocated by “pages” When full, some pages are copied to disk Replacement targets picked by some strategy – What strategy? Can leverage this yourself with “memory mapped files”

25 IPC Message/queue Shared memory/semaphore

26 Signals “software interrupts” Asynchronous model Not as nice as threads…

27 Sockets Way ugly Highly confusing I have examples…

28 C++ C with classes And function overloading And operator overloading And an amazing standard library