Ch. 7: Generic abstraction. Generic units and instantiation. Generic units and instantiation. Generic units and instantiation

Size: px
Start display at page:

Download "Ch. 7: Generic abstraction. Generic units and instantiation. Generic units and instantiation. Generic units and instantiation"

Transcription

1 Ch. 7: Generic abstraction Generic units and instantiation Reusable program units are applicable in a variety of applications stack queue list set such program units are generic wrt the data the process A generic unit is a program unit parameterized wrt entities on which it depends Instantiation of a generic unit generates an ordinary program unit Generic units can be instantiated more than once prevents code duplication / Faculteit Wiskunde en Informatica PAGE 0 / Faculteit Wiskunde en Informatica PAGE 1 Generic units and instantiation Generic units and instantiation A procedure is an abstraction over an expression A generic unit is an abstraction over a declaration Generic units are supported by: C++ Ada Java (since 2004 and only for types) C++ generic class templates template <int capacity> class Queue { private: char elems[capacity]; int front, rear, length; public: Queue(); void add (char e); char remove(); / Faculteit Wiskunde en Informatica PAGE 2 / Faculteit Wiskunde en Informatica PAGE 3

2 Generic units and instantiation Generic units and instantiation C++ generic function templates template <int capacity> Queue<capacity>::Queue() { front = rear = length template <int capacity> void Queue<capacity>::add(char e) { elems[rear] = e; rear = (rear+1) % capacity; length++; template <int capacity> void Queue<capacity:: remove() { Every constructor and method definition must be prefixed by template <int capacity> Instantiation of generic classes via: Typedef Queue<80> Input_Buffer; Typedef Queue<120> Line_Buffer; Declaration of variables of type Input_Buffer and Line_Buffer: Input_Buffer inbuf; Line_ Buffer outbuf; Line_Buffer errbuf; Alternatively: Queue<80> inbuf; Queue<120>outbuf; e<120>o Queue<120>errbuf; / Faculteit Wiskunde en Informatica PAGE 4 / Faculteit Wiskunde en Informatica PAGE 5 Generic units and instantiation Type and class parameters A conceptual problem with C++ generic classes: Type equivalence: outbuf and errbuf are equivalent because both are derived from Queue<120> Queue<m> and Queue<n-1> are not equivalent arguments must be evaluated at compile-time A program unit that uses a type can also become a generic program unit, with a type parameter Ada, C++, and Java have generic units with type parameters A pragmatic problem with C++ generic classes: if Queue<120> occurs multiple times, multiple instance may be generated by a simple-minded i d compiler / Faculteit Wiskunde en Informatica PAGE 6 / Faculteit Wiskunde en Informatica PAGE 7

3 Type parameters in C++ Type parameters in C++ A C++ generic unit may be parameterized wrt any type or calls on which it depends Encapsulation of homogeneous lists template <class Element> class List is private: const int capacity = ; int length; Element elems[capacity]; public: List(); void append(element e); //other methods <class Element> states that Element is a formal parameter of the generic class and denotes an unknown type generic class constructor and methods: template <class Element> List<Element>::List () { length = 0; template <class Element> void List<Element>::append(Element e) { elems[length++] = e; instantiated via typedef List<char> Phrase or struct Trans { ; typedef List<Trans> Trans_List; / Faculteit Wiskunde en Informatica PAGE 8 / Faculteit Wiskunde en Informatica PAGE 9 Type parameters in C++ Type parameters in C++ Encapsulation of sequences, i.e., sortable lists template t <class Element> class List is private: const int capacity = ; int length; Element elems[capacity]; public: sequence(); void append(element e); void sort(); //other methods Generic class constructor and methods: template <class Element> void Sequence<Element>::sort() { Element e; if (e < elems[i]) Note the use of the < operator in the sort method / Faculteit Wiskunde en Informatica PAGE 10 / Faculteit Wiskunde en Informatica PAGE 11

4 Type parameters in C++ Type parameters in C++ The argument type <class Element> should be equipped with a < operation A proper instantiation is: typedef Sequence<float> Number_Sequence; Number_Sequence readings; readings.sort(); A seemingly proper instantiation is: typedef char* String; typedef Sequence<String> String_Sequence; however < < operation compares pointers instead of lexicographically Operations used for T in the generic unit operations with which the argument type is equipped The C++ compiler cannot completely type-check the definition of a generic unit An incorrect instantiation is: struct Trans { ; typedef Sequence<Trans> Trans_ Sequence; Trans type is not equipped with < operation / Faculteit Wiskunde en Informatica PAGE 12 / Faculteit Wiskunde en Informatica PAGE 13 Class parameters in Java Class parameters in Java Since 2004 Java supports generic abstraction in the form of generic classes, parameterized with other classes encapsulation of homogeneous lists class List <Element> { private length; private Element[] elems; public List() { public void append(element e) { heading states that Element is a formal parameter of the generic class List Generic class can be instantiated with: List<Character> sentence; List<Transaction> sentence; Argument must be a class, not a primitive type List<char> sentence; // illegal! / Faculteit Wiskunde en Informatica PAGE 14 / Faculteit Wiskunde en Informatica PAGE 15

5 Class parameters in Java Class parameters in Java If the generic Java class must be equipped with particular operations, the class parameter must be specified as an interface The class parameter is bounded by the interface Java generic class with a bounded class parameter interface Comparable <Item> { public abstract int compareto(item that); Following Java generic class encapsulates sequences equipped with a sort operation class Sequence <Element implements Comparable<Element>> { private length; private Element[] elems; public Sequence() { public void append() { public void sort() { Element e; if (e.compareto(elems[i]) < 0 ) / Faculteit Wiskunde en Informatica PAGE 16 / Faculteit Wiskunde en Informatica PAGE 17 Class parameters in Java Ch.8: Type systems A Java generic unit is to have a class parameter C of the form class C implements Interface The compiler checks the generic unit to ensure operations used for C in the generic unit operations declared for Interface operations declared in Interface operations with which the argument class is equipped Java generic units are based on type theory: compiler can type-check the declarations of each generic unit separately type-check every instantiation Weakness of Java generic classes: only classes as parameter Older languages g had very simple type systems C s type system is too weak Pascal s type system is too rigid Modern languages more powerful type systems: subtypes polymorphism overloading / Faculteit Wiskunde en Informatica PAGE 18 / Faculteit Wiskunde en Informatica PAGE 19

6 Inclusion polymorphism Inclusion polymorphism Inclusion polymorphism is a type system where types may have subtypes A type T is a set of values equipped with some operations A subtype of T is a subset of values equipped with the same operations as T If we know that a variable only ranges over a subset of values of T, it is better to allow a subtype declaration C has rudimentary subtypes: char and int are subtypes of long float is a subtype of double General properties of subtypes S is subtype of T if every value of S is also a value of T: S T subtype S inherits the operations of type T T 1 is compatible with T 2 T 1 is a subtype of T 2 T 2 is a subtype of T 1 T 1 and T 2 are subtypes of some other type / Faculteit Wiskunde en Informatica PAGE 20 / Faculteit Wiskunde en Informatica PAGE 21 Inclusion polymorphism Classes and subclasses If T 1 is compatible with T 2 T 1 is a subtype of T 2, no run-time check is necessary T 1 is not a subtype of T 2 some of fthe values of ft 1 are values of T 2 A run-time check is needed to check whether a value of T 1 is also a value of T 2 This kind of run-time check is cheaper the full run- time checking as for dynamic languages Class S is a subclass of class C a class C is a set of objects with variable components and operations each object of class S inherits all variable components and operations, but may add extra ones Subclasses are not exactly analogous to subtypes objects of class S may be used wherever objects of class C are expected S may have additional components, so the objects of S are not a subset of the objects of C / Faculteit Wiskunde en Informatica PAGE 22 / Faculteit Wiskunde en Informatica PAGE 23

7 Parametric polymorphism Parametric polymorphism Monomorphic procedures can only operate on arguments of a fixed type Polymorphic procedures can operate uniformly on arguments of a family of types Parametric polymorphism is a type system in which we can write polymorphic procedures functional languages, ML, Haskell, etc., provide parametric ti polymorphism A type variable is an identifier that stands for a family of types monomorphic second(x : Int, y : Int) = y polymorphic second(x : δ, y : τ) = y A polytype derives a family of similar types δ τ τ includes Integer Boolean Boolean String String String but not Boolean Integer Boolean Integer Integer / Faculteit Wiskunde en Informatica PAGE 24 / Faculteit Wiskunde en Informatica PAGE 25 Parameterized types Type inference A parameterized type takes other type(s) as parameter(s) In C array typesτ[]are parameterized types: char[] float[] All programming languages have built-in parameterized types ML and Haskell allow programmer to define their own parameterized types type Pair τ = (τ, τ) data List τ = Nil Cons(τ, List τ) plus polymorphic functions head, tail, length on these lists Statically type programming languages insist on explicit declaration of the type of entity in programs integer I := E In Haskell we can write a definition I = E where type of I is not explicitly stated, but inferred from E Type inference is a process where the type of a declared entity is inferred instead of explicitly stated monotype, if strong clues, e.g., if a monomorphic operator is used polytype in case of polymorphic operators / Faculteit Wiskunde en Informatica PAGE 26 / Faculteit Wiskunde en Informatica PAGE 27

8 Type inference Type inference even n = (n mod 2 = 0) type of even is: Integer Integer Integer id x = x type of id is: τ τ f. g = \x -> f(g(x)) types of f and g are β γ and α β, respectively variable x must be of type α subexpression f(g(x)) is of type γ expression \x -> f(g(x)) is of type α γ. is of type (β γ) (α β) (α γ) Type inference may lead to programs that are difficult to understand Explicitly declaring (redundant) types is good programming practice / Faculteit Wiskunde en Informatica PAGE 28 / Faculteit Wiskunde en Informatica PAGE 29 Overloading Overloading An identifier is overloaded of it denotes two or more distinct procedures in the same scope In older programming languages (e.g. C) identifiers and operators for certain built-in in functions are overloaded C - operator: integer negation (Integer Integer) floating-point negation (Float Float) integer subtraction (Integer Integer t I t Integer) ) floating-point subtraction (Float Float Float) C++, Java allow programmers to define overloaded identifiers and operators Identifier F denotes function (f 1 ) of type S 1 T 1 function (f 2 ) of type S 2 T 2 context-independent overloading requires S 1 and S 2 are non- equivalent if actual parameter E of F(E) is of type S 1 then F denotes f 1 if E is of type S 2 then F denotes f 2 with context-independent overloading the function can be uniquely identified by the type of the actual parameter / Faculteit Wiskunde en Informatica PAGE 30 / Faculteit Wiskunde en Informatica PAGE 31

9 Overloading Type conversions Identifier F denotes function (f 1 )of type S 1 T 1 function (f 2 ) of type S 2 T 2 context-dependent overloading requires S 1 and S 2 are non- equivalent or T 1 and T 2 are non-equivalent if S 1 and S 2 are non-equivalent, see previous slide if S 1 and S 2 are equivalent, but T 1 and T 2 are non-equivalent the context must be taken into consideration if the context F(E) is of type T 1 then F denotes f 1 if the context is of type T 2 then F denotes f 2 with context-dependent overloading, it is possible to formulate expressions which cannot be uniquely identified the programming language should prohibit this A type conversion is a mapping from the values of one type to corresponding values of a different type integers to real numbers real numbers to integers involve rounding and truncation A cast is an explicit type conversion In C, C++, Java: (T)E A coercion is an implicit type conversion C allows very restricted coercions: from integers to real number, from narrow-range to wide-range integers modern programming languages minimize or eliminate coercions altogether because of conflicts with polymorphism and overloading / Faculteit Wiskunde en Informatica PAGE 32 / Faculteit Wiskunde en Informatica PAGE 33 Ch 9: Control flow Sequencers We will study a number of alternatives traditional sequencers: sequential conditional iterative jumps, low-level e sequencers s to transfer control o escapes, sequencers to transfer control out of commands and procedures exceptions, sequencers to signal abnormal situations ti A sequencer is a language g construct to transfer control to some other point in a program, destination A sequencer implements a flow of control / Faculteit Wiskunde en Informatica PAGE 34 / Faculteit Wiskunde en Informatica PAGE 35

10 Jumps Jumps A jump transfers control to a specified program point A jump has typical the form goto L; and transfer the control to program point L, which is a label if (E 1 ) C 1 else { C 2 goto X; C 3 ; while (E 2 ) { C 4 ; X: C 5 Unrestricted jumps lead to spaghetti code, thus hard to understand, see edu/users/ewd/ewd02xx/ewd215 Most programming languages support gotos Java refuses jumps, because it supports higher-level escapes and exceptions Some languages have restrictions: the jump goto L; is legal only within the scope of L in C the scope of each label is the smallest enclosing block: jumps within a block jumps from a block to an enclosing one jumps into a block from outside is not allowed / Faculteit Wiskunde en Informatica PAGE 36 / Faculteit Wiskunde en Informatica PAGE 37 Jumps Escapes C restricts jumps because a jump out of a block must destroy the local variables Jumps out of a procedure should lead to destroying local variables and termination of procedure activation Jumps out of a recursive procedure is even more complicated Jumps introduce unwanted complexity in the semantics of high-level programming languages An escape is a sequencer that terminates the execution of a textually t enclosing command or procedure re In C, C++, Java: break sequencer to break loops In C, C++, Java: return sequencer to break loops and end procedures multiple return sequencers in a procedure is hard to maintain Escapes are restricted so that control cannot be transfer out of procedures A halt sequencer stops the entire program exit() in C / Faculteit Wiskunde en Informatica PAGE 38 / Faculteit Wiskunde en Informatica PAGE 39

11 Exceptions Exceptions Exceptions are a mechanism to deal with abnormal situations: arithmetic operation overflows uncompleted input/output operations Exceptions take of two things: error handling Controlled termination of flow of control Code that detects an abnormal situation throws an exception the exception can be caught in another part of the program programmer have control over exceptions and handling of it C++ and Java, being object-oriented languages, treat exceptions as objects / Faculteit Wiskunde en Informatica PAGE 40 / Faculteit Wiskunde en Informatica PAGE 41 Exceptions Exceptions Java has a built-in Exception class every exception is a subclass of Exception every exception represents a different abnormal situation try C 0 catch (T 1 I 1 ) C 1 catch (T n I n ) C n finally C f Able to catch any exception from class T 1 or or T n if C 0 throws an exception of type T i handler C i will be executed with identifier I i bound to that exception Exceptions can be caught at various levels: static float readfloat(bufferedreader input) throws IOException, NumberFormatException { if () throw new IOException( end of input ); String literal = ; float f = Float.parseFloat(literal); return f; Float.parseFloat throws the NumberFormatException / Faculteit Wiskunde en Informatica PAGE 42 / Faculteit Wiskunde en Informatica PAGE 43

12 Exceptions Exceptions Method annual rainfall data may catch the NumberFormatException static float[] readannual(bufferedreader input) throws IOException { try { float r = readfloat(input); catch (NumberFormatException e) { The main program calls readannual and deals with the IOException static void main() { float[] rainfall; try { rainfall = readannual(); catch (IOException e) { / Faculteit Wiskunde en Informatica PAGE 44 / Faculteit Wiskunde en Informatica PAGE 45 Ch 10: Concurrency Programs and processes Why concurrency? program design becomes more complex testing becomes less effective historically, i improvement of efficiency i via multiprogramming systems, usage of idle resources currently, end of Moore s law, efficiency e cy gain via multi-core processors A sequential process is a totally ordered set of steps each step is a change of state A sequential program specifies the state changes of a sequential process A concurrent program specifies the possible state changes of 2 or more sequential processes / Faculteit Wiskunde en Informatica PAGE 46 / Faculteit Wiskunde en Informatica PAGE 47

13 Problems with concurrency Problems with concurrency Nondeterminism: sequential programs are deterministic collateral and nondeterministic conditional commands may introduce unpredictability in sequential programs compiler is free to determine the order of execution different compilers may lead to different behavior A concurrent program is genuinely nondeterministic even for a specific compiler incorrect concurrent programs may behave correctly in general, but have sometimes unpredictable behavior Speed dependence sequential programs are speed-independent because correctness does not depend on execution speed concurrent programs are speed-dependentdependent behavior depends on the relative speed at which its constituent sequential processes run if absolute speeds are considered, outside world, we have real-time behavior if the outcome is speed-dependent, dependent, there is a race condition / Faculteit Wiskunde en Informatica PAGE 48 / Faculteit Wiskunde en Informatica PAGE 49 Problems with concurrency Problems with concurrency Deadlock means that processes are unable to make progress because of mutually incompatible demands for resources mutual exclusion: a process may be given exclusive access to resources incremental acquisition: a process holds previously acquired resource while waiting for new resources no preemption: resources cannot be removed from a process until it voluntarily releases them circular waiting: a cycle of resources or processes in which each process is waiting for resources that are held by the next process in the cycle Solutions for deadlocks: Ignore them and restart system if it occurs Recovery by detecting and kill involved processes Prevention by remove some of the preconditions Avoid by scheduling of resources / Faculteit Wiskunde en Informatica PAGE 50 / Faculteit Wiskunde en Informatica PAGE 51

14 Problems with concurrency Process interactions Starvation A concurrent program has the liveness property if it is guaranteed that every process will make some progress over a sufficiently long period of time Free of deadlock Fair scheduling Fair scheduling means that no process needing a resource is indefinitely prevented from obtaining it Sequential and collateral commands do not allow simultaneously execution of commands The parallel command B C indicates that B and C may executed simultaneously or arbitrarily interleaved / Faculteit Wiskunde en Informatica PAGE 52 / Faculteit Wiskunde en Informatica PAGE 53 Process interactions Process interactions Independent processes: commands B and C are independent if the execution of B has no effect on the execution of C, and vice versa concurrent composition of independent processes is deterministic Competing processes Commands B and C are competing if they need exclusive access to the same resource r Let B be the sequence B 1 ; B 2 ; B 3 Let C be the sequence C 1 ; C 2 ; C 3 B 1, C 1, B 3, C 3 are independent, none need r B 2 and C 2 both need r, so they cannot take place simultaneously, they are critical section wrt r B C may be executed as: ; B 2 ; ; C 2 ; ; C 2 ; ; B 2 ; but not as ; B 2 C 2 ; / Faculteit Wiskunde en Informatica PAGE 54 / Faculteit Wiskunde en Informatica PAGE 55

15 Process interactions Concurrency primitives Communicating processes let B be the sequence B 1 ; B 2 ; B 3 let C be the sequence C 1 ; C 2 ; C 3 there is communication from B to C if B 2 produces data that C 2 consumes, so B 2 must end before C 2 starts Thus B C has the same behavior as B; C Processes B and C intercommunicate if there is communication in both directions: B C yields numerous outcomes Process until now was a flow of control through a program a conventional, heavyweight, ht process is a program, which h involves: an address space allocation of main storage, share of CPU time access to files, devices, etc. context switching from one process to another involves a lot of time a thread is a lightweight alternative flow of control through a program without computational resources switching of threads involves swapping of content of working registers / Faculteit Wiskunde en Informatica PAGE 56 / Faculteit Wiskunde en Informatica PAGE 57 Concurrency primitives Concurrency primitives Process creation and control create a new child process load program code to be executed by a process start execution of a process suspend execution of a process resume execution of a (suspended) process let a process stop at the end of its execution let the creator wait for the process to stop destroy a stopped process, freeing resources create, load, start are combined into fork wait and destroy into join Process creation and control abstract operations for competition in order to make the critical sections disjoint in time acquire(r) to gain exclusive access to resource r relinquish(r) to give up exclusive access if resource r is already allocated, acquire(r) blocks the process it calls it if resource r is freed, processes waiting for access are unblocked and rescheduled abstract operations for (synchronous) communication transmit(m) called by a sender to send m receive(m) called by a receiver to wait for m asynchronous communication via broadcasting / Faculteit Wiskunde en Informatica PAGE 58 / Faculteit Wiskunde en Informatica PAGE 59

16 Concurrency primitives Concurrency primitives Interrupts ending a concurrent input/output operation is a infrequent operation to which the CPU should respond quickly ending input/output operations causes interrupts Spin locks and wait-free algorithms On a multiprocessor several processes may be executed simultaneously Most algorithms, Dekker s algorithm (presented by Dijkstra), Petterson s s algorithm, Simpson s s algorithm are complex and their behavior maybe corrupted by compiler optimizations Primitives should be built into the language events semaphores messages remote procedure calls / Faculteit Wiskunde en Informatica PAGE 60 / Faculteit Wiskunde en Informatica PAGE 61 Languages with concurrency primitives Next on GLT Object-oriented languages, g e.g. Java with threads Specification languages mcrl2 CHI POOSL Scripting languages ToolBus Meta-modeling: meta-model design xtext model transformations ti xpand GLT technology: Scanners Parsers Parser generators / Faculteit Wiskunde en Informatica PAGE 62 / Faculteit Wiskunde en Informatica PAGE 63

Ch 9: Control flow. Sequencers. Jumps. Jumps

Ch 9: Control flow. Sequencers. Jumps. Jumps Ch 9: Control flow Sequencers We will study a number of alternatives traditional sequencers: sequential conditional iterative jumps, low-level sequencers to transfer control escapes, sequencers to transfer

More information

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures Chapter 5: Procedural abstraction Proper procedures and function procedures Abstraction in programming enables distinction: What a program unit does How a program unit works This enables separation of

More information

Questions? Static Semantics. Static Semantics. Static Semantics. Next week on Wednesday (5 th of October) no

Questions? Static Semantics. Static Semantics. Static Semantics. Next week on Wednesday (5 th of October) no Questions? First exercise is online: http://www.win.tue.nl/~mvdbrand/courses/glt/1112/ Deadline 17 th of October Next week on Wednesday (5 th of October) no lectures!!! Primitive types Primitive value

More information

Performance Throughput Utilization of system resources

Performance Throughput Utilization of system resources Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency

More information

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result. Every program uses data, either explicitly or implicitly to arrive at a result. Data in a program is collected into data structures, and is manipulated by algorithms. Algorithms + Data Structures = Programs

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE

MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE MS Windows Concurrency Mechanisms Prepared By SUFIAN MUSSQAA AL-MAJMAIE 163103058 April 2017 Basic of Concurrency In multiple processor system, it is possible not only to interleave processes/threads but

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles

More information

CHAPTER 6: PROCESS SYNCHRONIZATION

CHAPTER 6: PROCESS SYNCHRONIZATION CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background

More information

Concurrency. Lecture 14: Concurrency & exceptions. Why concurrent subprograms? Processes and threads. Design Issues for Concurrency.

Concurrency. Lecture 14: Concurrency & exceptions. Why concurrent subprograms? Processes and threads. Design Issues for Concurrency. Lecture 14: Concurrency & exceptions Concurrency Processes and threads Semaphores, monitors and message passing Exception handling Concurrency Is is often desirable or necessary to execute parts of programs

More information

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6] 1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,

More information

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

Lecture #23: Conversion and Type Inference

Lecture #23: Conversion and Type Inference Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). Last modified: Fri Oct 20 10:46:40 2006 CS164:

More information

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = Hello; Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). In Java, this is legal: Object x = "Hello";

More information

Type Systems, Type Inference, and Polymorphism

Type Systems, Type Inference, and Polymorphism 6 Type Systems, Type Inference, and Polymorphism Programming involves a wide range of computational constructs, such as data structures, functions, objects, communication channels, and threads of control.

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Process Management And Synchronization

Process Management And Synchronization Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

1 Process Coordination

1 Process Coordination COMP 730 (242) Class Notes Section 5: Process Coordination 1 Process Coordination Process coordination consists of synchronization and mutual exclusion, which were discussed earlier. We will now study

More information

5/23/2015. Core Java Syllabus. VikRam ShaRma

5/23/2015. Core Java Syllabus. VikRam ShaRma 5/23/2015 Core Java Syllabus VikRam ShaRma Basic Concepts of Core Java 1 Introduction to Java 1.1 Need of java i.e. History 1.2 What is java? 1.3 Java Buzzwords 1.4 JDK JRE JVM JIT - Java Compiler 1.5

More information

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review

More information

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts. CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.

More information

Fundamentals of Programming Languages

Fundamentals of Programming Languages Fundamentals of Programming Languages 1. DEFINITIONS... 2 2. BUILT-IN TYPES AND PRIMITIVE TYPES... 3 TYPE COMPATIBILITY... 9 GENERIC TYPES... 14 MONOMORPHIC VERSUS POLYMORPHIC... 16 TYPE IMPLEMENTATION

More information

Compositional C++ Page 1 of 17

Compositional C++ Page 1 of 17 Compositional C++ Page 1 of 17 Compositional C++ is a small set of extensions to C++ for parallel programming. OVERVIEW OF C++ With a few exceptions, C++ is a pure extension of ANSI C. Its features: Strong

More information

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

Concurrent Programming using Threads

Concurrent Programming using Threads Concurrent Programming using Threads Threads are a control mechanism that enable you to write concurrent programs. You can think of a thread in an object-oriented language as a special kind of system object

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

Multitasking / Multithreading system Supports multiple tasks

Multitasking / Multithreading system Supports multiple tasks Tasks and Intertask Communication Introduction Multitasking / Multithreading system Supports multiple tasks As we ve noted Important job in multitasking system Exchanging data between tasks Synchronizing

More information

Java Threads and intrinsic locks

Java Threads and intrinsic locks Java Threads and intrinsic locks 1. Java and OOP background fundamentals 1.1. Objects, methods and data One significant advantage of OOP (object oriented programming) is data encapsulation. Each object

More information

CS420: Operating Systems. Process Synchronization

CS420: Operating Systems. Process Synchronization Process Synchronization James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background

More information

Types. What is a type?

Types. What is a type? Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,

More information

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem? What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular

More information

Resource management. Real-Time Systems. Resource management. Resource management

Resource management. Real-Time Systems. Resource management. Resource management Real-Time Systems Specification Implementation Verification Mutual exclusion is a general problem that exists at several levels in a real-time system. Shared resources internal to the the run-time system:

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS

More information

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes INF 212/CS 253 Type Systems Instructors: Harry Xu Crista Lopes What is a Data Type? A type is a collection of computational entities that share some common property Programming languages are designed to

More information

Imperative Programming Languages (IPL)

Imperative Programming Languages (IPL) Imperative Programming Languages (IPL) Definitions: The imperative (or procedural) paradigm is the closest to the structure of actual computers. It is a model that is based on moving bits around and changing

More information

Dealing with Issues for Interprocess Communication

Dealing with Issues for Interprocess Communication Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed

More information

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content Core Java - SCJP Course content NOTE: For exam objectives refer to the SCJP 1.6 objectives. 1. Declarations and Access Control Java Refresher Identifiers & JavaBeans Legal Identifiers. Sun's Java Code

More information

Synchronization SPL/2010 SPL/20 1

Synchronization SPL/2010 SPL/20 1 Synchronization 1 Overview synchronization mechanisms in modern RTEs concurrency issues places where synchronization is needed structural ways (design patterns) for exclusive access 2 Overview synchronization

More information

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I

More information

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014 AC OB S Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014 ACOBS ACtive OBject (operating) System Simplified FW System for Multi-Threading on ARM embedded systems ACOBS

More information

Compilers. Type checking. Yannis Smaragdakis, U. Athens (original slides by Sam

Compilers. Type checking. Yannis Smaragdakis, U. Athens (original slides by Sam Compilers Type checking Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Summary of parsing Parsing A solid foundation: context-free grammars A simple parser: LL(1) A more powerful parser:

More information

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules. Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Concurrent Programming

Concurrent Programming Concurrency Concurrent Programming A sequential program has a single thread of control. Its execution is called a process. A concurrent program has multiple threads of control. They may be executed as

More information

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS Type Systems. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright Instructors. What is a Data Type? A type is a collection of computational entities that share some common property Programming

More information

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

Chapter Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level

Chapter Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level Concurrency can occur at four levels: 1. Machine instruction level 2. High-level language statement level 3. Unit level 4. Program level Because there are no language issues in instruction- and program-level

More information

Multiple Inheritance. Computer object can be viewed as

Multiple Inheritance. Computer object can be viewed as Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 13 Robert Grimm, New York University 1 Review Last week Exceptions 2 Outline Concurrency Discussion of Final Sources for today s lecture: PLP, 12

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java

More information

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions) By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable

More information

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully

More information

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to: F2007/Unit5/1 UNIT 5 OBJECTIVES General Objectives: To understand the process management in operating system Specific Objectives: At the end of the unit you should be able to: define program, process and

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

Synchronization Principles

Synchronization Principles Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms

More information

Threads and Parallelism in Java

Threads and Parallelism in Java Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program

More information

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

SEMANTIC ANALYSIS TYPES AND DECLARATIONS SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether

More information

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

Static Semantics. Winter /3/ Hal Perkins & UW CSE I-1

Static Semantics. Winter /3/ Hal Perkins & UW CSE I-1 CSE 401 Compilers Static Semantics Hal Perkins Winter 2009 2/3/2009 2002-09 Hal Perkins & UW CSE I-1 Agenda Static semantics Types Symbol tables General ideas for now; details later for MiniJava project

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

CSCI 171 Chapter Outlines

CSCI 171 Chapter Outlines Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures

More information

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007 CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs

CSE 451: Operating Systems Winter Lecture 7 Synchronization. Steve Gribble. Synchronization. Threads cooperate in multithreaded programs CSE 451: Operating Systems Winter 2005 Lecture 7 Synchronization Steve Gribble Synchronization Threads cooperate in multithreaded programs to share resources, access shared data structures e.g., threads

More information

CISQ Weakness Descriptions

CISQ Weakness Descriptions CISQ Weakness Descriptions This document presents descriptions of the 86 weaknesses contained in the 4 CISQ Quality Characteristic measures. These descriptions have been simplified from their description

More information

Models of concurrency & synchronization algorithms

Models of concurrency & synchronization algorithms Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu

More information

Question 1. Notes on the Exam. Today. Comp 104: Operating Systems Concepts 11/05/2015. Revision Lectures

Question 1. Notes on the Exam. Today. Comp 104: Operating Systems Concepts 11/05/2015. Revision Lectures Comp 104: Operating Systems Concepts Revision Lectures Today Here are a sample of questions that could appear in the exam Please LET ME KNOW if there are particular subjects you want to know about??? 1

More information

CS370 Operating Systems Midterm Review

CS370 Operating Systems Midterm Review CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.

Chapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6. Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure

More information

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology

Real-Time Systems. Lecture #4. Professor Jan Jonsson. Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Lecture #4 Professor Jan Jonsson Department of Computer Science and Engineering Chalmers University of Technology Real-Time Systems Specification Resource management Mutual exclusion

More information

Types and Type Inference

Types and Type Inference CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic

More information

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi UNIT II Structuring the Data, Computations and Program B y Kainjan Sanghavi Contents Monomorphic versus polymorphic type systems Case Study- The type structure of C++ and Java Structuring the computation

More information

G Programming Languages Spring 2010 Lecture 8. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 8. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 8 Robert Grimm, New York University 1 Review Last time Types Fun with O Caml 2 Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.7 Barrett. Lecture notes,

More information

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples

Last Class: Synchronization Problems. Need to hold multiple resources to perform task. CS377: Operating Systems. Real-world Examples Last Class: Synchronization Problems Reader Writer Multiple readers, single writer In practice, use read-write locks Dining Philosophers Need to hold multiple resources to perform task Lecture 10, page

More information

A declaration may appear wherever a statement or expression is allowed. Limited scopes enhance readability.

A declaration may appear wherever a statement or expression is allowed. Limited scopes enhance readability. Scope vs. Lifetime It is usually required that the lifetime of a run-time object at least cover the scope of the identifier. That is, whenever you can access an identifier, the run-time object it denotes

More information

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First

More information

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey CS 370: OPERATING SYSTEMS [DEADLOCKS] Shrideep Pallickara Computer Science Colorado State University L16.1 Frequently asked questions from the previous class survey Exponential Moving Average Is the α

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Pierce Ch. 3, 8, 11, 15. Type Systems

Pierce Ch. 3, 8, 11, 15. Type Systems Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using

More information

Chapter 13 Topics. Introduction. Introduction

Chapter 13 Topics. Introduction. Introduction Chapter 13 Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Java Threads C# Threads Statement-Level Concurrency Copyright 2006 Pearson Addison-Wesley. All rights reserved.

More information