Threads and Concurrency in Java: Part 1
|
|
- Derrick Banks
- 6 years ago
- Views:
Transcription
1 Cocurrecy Threads ad Cocurrecy i Java: Part 1 What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured T. S. Norvell Memorial Uiversity Threads. Slide 2 Cocurrecy: What Cocurrecy: Where Cocurrecy meas that there are multiple agets ruig at the same time ad iteractig. Sources of cocurrecy: We have cocurrecy whe we have iteractig processes ruig o differet computers (e.g. Apache a web server o moa.egr.mu.ca ad Firefox a web browser o paradox.egr.mu.ca ) T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 4
2 Cocurrecy : Where Cocurrecy : Where We also have cocurrecy whe we have iteractig processes ruig o the same computer. E.g. Firefox ad Widows Explorer. Every iteractive program is part of a cocurret system: the user is a cocurret aget. Furthermore we ca have multiple threads of cotrol withi oe OS process. A.K.A. multithreadig Cocurrecy ca be itermachie, iterprocess, or multithreadig. These slides cocetrate o itraprocess cocurrecy i Java T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 6 Cocurrecy: Why Cocurrecy: Why Reasos for usig cocurrecy Speed. Multiple threads ca be ru o multiple processors (or multiple cores). This may give a speed advatage. Distributio. We may wish differet parts of a system to be located o differet machies for reasos of coveiece, security, reliability,. Reasos for usig cocurrecy Asychroy. It is easiest to deal with multiple sources of evets by havig oe thread dedicated to each stream of icomig or outgoig evets. For example, a web browser may use oe thread to deal with iput from the user ad oe thread for each server it is curretly iteractig with. Likewise a web server will typically dedicate at least oe thread to each curret sessio T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 8
3 Threads Each thread has its ow program couter registers local variables ad stack All threads share the same heap (objects) Cocurrecy: How Multiple processors Multiprocessor (ad mulitcore) CPU L1 Cache CPU L1 Cache 2 threads 2 processors time L2 Cache Cetral Memory T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 10 Cocurrecy: How Time slicig implemetatio 2 threads 1 processor Cotext switch Memory Previously The This Pipelie PC Iitially ad gree is a registers the coceptual saved PC drais thread red thread ow are view ad saved. executes register values are is of executig the process. fetched. Implemetatio details will vary. Sigle processor The CPU is switched betwee threads at upredictable times time Copy of PC Copy of registers PC Registers Copy of PC Copy of registers Multiple processor Thread may occasioally migrate 3 threads 2 processors Stack IF DEC EX WB CPU Stack time Istructios Heap T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 12
4 Thread Objects i Java I Java, threads are represeted by objects of class java.lag.thread. The ru method cotais the actual code for the thread to execute. public class ThreadExample exteds Thread { private Strig message; ThreadExample( Strig message ) { this.message = getname() + ": " + public void ru() { for( it i=0 ; i<20 ; ++i ) System.out.pritl( message ); T. S. Norvell Memorial Uiversity Threads. Slide 13 Startig a ew thread Callig t.start() starts a ew thread which executes the t.ru() public class ThreadExampleMai { public static void mai(strig[] args) { ThreadExample thread0 = ew ThreadExample("Hi"); ThreadExample thread1 = ew ThreadExample("Ho"); thread0.start(); thread1.start(); System.out.pritl( Thread.curretThread().getName() + ": Mai is doe"); T. S. Norvell Memorial Uiversity Threads. Slide 14 Output for example Race Coditios Possible output for example: Thread-1: Ho Thread-1: Ho Thread-0: Hi mai: Mai is doe Thread-1: Ho Thread-0: Hi (ad so o for aother 35 lies) Whe t.ru() completes the thread stops. Whe all threads have stopped the program exits A system has a race coditio whe its correctess depeds the order of certai evets, but the order of those evets is ot sufficietly cotrolled by the desig of the system T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 16
5 Race Coditios Race Coditios Ofte race coditios occur because 2 agets have ucotrolled access to a shared resource Cosider two trai routes that share the same bridge A solutio: Before crossig the bridge, trais acuire a toke After crossig the bridge, trais reliuish the toke Acuire the toke Reliuish the toke Uless access to the shared resource is cotrolled, disaster may esue. Acuire the toke Reliuish the toke Oly Both As Iitially the soo oe trais other as ca try trai toke the succeed. toke ca acuire is free acuire is free at the the agai same toketime T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 18 Race Coditios i Software Remember: objects are shared by threads I Java, access to a object s methods is ucotrolled, by default!!!! Suppose we have public class Couter { private it cout = 0; public void icremet() { ++cout; System.out.pritl(cout); Race Coditios i Software Differet threads ca share the same Couter public class CouterThread exteds Thread { private Couter couter; CouterThread(Couter c) { this.couter = public void ru() { for( it i=0 ; i<10 ; ++i ) { couter.icremet(); T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 20
6 Race Coditios i Software Execute the followig: public class CouterMai { public static void mai(strig[] args) { Couter c = ew Couter(); // Threads p ad share the same couter CouterThread p = ew CouterThread(c); CouterThread = ew CouterThread(c); p.start();.start(); Race Coditios i Software public class CouterMai { public static void mai(strig[] args) { Couter c = ew Couter(); CouterThread p = ew CouterThread(c); CouterThread = ew CouterThread(c); p.start();.start(); Possible Result: WTF? T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 22 Race Coditios i Software The reaso is that the icremet operatio results i multiple bytecode (low-level JVM) istructios that ca get iterleaved Focus oly o ++cout public class Couter { private it cout = 0; Race Coditios i Software The statemet ++cout results i the followig bytecode load cout to r0 store r0 to cout public void icremet() { ++cout; System.out.pritl(cout); r0 represets register T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 24
7 Race Coditios i Software Two threads ivoke icremet at about the same time (Recall: Registers are local to the thread.) A race coditio results. p cout r0 (i p) r0 (i ) load cout to r0 store r0 to cout load cout to r0 store r0 to cout = 42? Of the two icremets, oe was lost Race Coditios: Aother Example Cosider trasfers o a accout class AccoutMaager { private Accout savigs ; private Accout cheuig; public void trasfertosavigs( it amout ) { it s = savigs.getbalace() ; it c = checkig.getbalace() ; savigs.setbal( s+amout ) ; cheuig.setbal( c-amout ) ; Two threads execute trasfers T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 26 Race Coditios : Aother Example Oe Thread Aother Thread sav ch (amout = 500) (amout = 1000) s = savigs.getbalace() c = cheuig.getbalace() s = savigs.getbalace() 4000 savigs.setbal(s+1000) 2000 cheuig.setbal(c-1000) c = cheuig.getbalace() savigs.setbal(s+500) 1500 cheuig.setbal(c-500) sychroized to the rescue Methods may be declared sychroized public class Couter { private it cout = 0; public sychroized void icremet() { ++cout; System.out.pritl(cout); I started with $6000 ad eded with $5000. This is ot good T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 28
8 sychroized to the rescue sychroized to the rescue Each object has a associated toke called its lock. Whe a thread ivokes a sychroized method x.m(): At each poit i time, each lock either is owed by o thread or is owed by oe thread. If it does ot already ow the recipiet s (x s) lock, It waits util it ca acuire the lock A thread that attempts to acuire a lock must wait util o thread ows the lock. After acuirig a lock, a thread ows it util it reliuishes it. Oce the lock has bee acuired the thread begis to execute the method Whe a thread leaves a ivocatio of a sychroized method: If it is leavig the last sychoroized ivocatio for that object It reliuishes the lock as it leaves T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 30 sychroized to the rescue sychroized to the rescue Hece, for ay object x, at most oe thread may be executig ay of x s sychroized methods. Example: Two threads ivoke c.icremet() at about the same time T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 32
9 sychroized to the rescue Thread p reuest lock o object c acuire lock o object c load cout to r0 store r0 to cout reliuish lock o object o Thread reuest lock o object o waits waits waits waits acuire lock o object o load cout to r0 store r0 to cout reliuish lock o object o T. S. Norvell Memorial Uiversity Threads. Slide 33 The Room metaphor Whe a thread Each has left all object is sychroized a room methods of the object, it leaves At the all room times, at most oe allowig thread is aother allowed thread to eter. to be i the room. The atechamber The room Whe a thread ot i the room calls a sychroized method, it eters a atechamber. There it waits util the room is empty. Whe the room is empty, at most oe thread is allowed to eter the room T. S. Norvell Memorial Uiversity Threads. Slide 34 Desig rule: Shared Objects Accouts For ay object that might be used by more tha oe thread at the same time Declare all methods that access or mutate the data sychroized (Note: private methods are exempted from this rule, as they ca oly be called oce a oprivate method has bee called.) Costructors eed ot (ad ca ot) be sychroized I AccoutMaager add sychroized to all methods class AccoutMaager { private Accout savigs ; private Accout cheuig; public sychroized void trasfertosavigs( it amout ) { it s = savigs.getbalace() ; it c = checkig.getbalace() ; savigs.setbal( s+amout ) ; cheuig.setbal( c-amout ) ; T. S. Norvell Memorial Uiversity Threads. Slide T. S. Norvell Memorial Uiversity Threads. Slide 36
Threads and Concurrency in Java: Part 1
Threads ad Cocurrecy i Java: Part 1 1 Cocurrecy What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.
More informationThreads and Concurrency in Java: Part 2
Threads ad Cocurrecy i Java: Part 2 1 Waitig Sychroized methods itroduce oe kid of coordiatio betwee threads. Sometimes we eed a thread to wait util a specific coditio has arise. 2003--09 T. S. Norvell
More informationCOMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter The Processor Part A path Desig Itroductio CPU performace factors Istructio cout Determied by ISA ad compiler. CPI ad
More informationThreads and Concurrency in Java
Threads and Concurrency in Java 1 Concurrency! What every computer engineer needs to know about concurrency: Concurrency is to untrained programmers as matches are to small children. It is all too easy
More informationLecture 28: Data Link Layer
Automatic Repeat Request (ARQ) 2. Go ack N ARQ Although the Stop ad Wait ARQ is very simple, you ca easily show that it has very the low efficiecy. The low efficiecy comes from the fact that the trasmittig
More informationRecursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames
Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of
More informationChapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings
Operatig Systems: Iterals ad Desig Priciples Chapter 4 Threads Nith Editio By William Stalligs Processes ad Threads Resource Owership Process icludes a virtual address space to hold the process image The
More informationCOSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1
COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,
More informationCOMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Single-Cycle Disadvantages & Advantages
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 4 The Processor Pipeliig Sigle-Cycle Disadvatages & Advatages Clk Uses the clock cycle iefficietly the clock cycle must
More informationOne advantage that SONAR has over any other music-sequencing product I ve worked
*gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig
More informationBasic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.
5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator
More informationChapter 4 The Datapath
The Ageda Chapter 4 The Datapath Based o slides McGraw-Hill Additioal material 24/25/26 Lewis/Marti Additioal material 28 Roth Additioal material 2 Taylor Additioal material 2 Farmer Tae the elemets that
More informationChapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 10 Defiig Classes Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 10.1 Structures 10.2 Classes 10.3 Abstract Data Types 10.4 Itroductio to Iheritace Copyright 2015 Pearso Educatio,
More informationDATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Data structures. Appetizer. Appetizer
Data structures DATA STRUCTURES Static problems. Give a iput, produce a output. Ex. Sortig, FFT, edit distace, shortest paths, MST, max-flow,... amortized aalysis biomial heaps Fiboacci heaps uio-fid Dyamic
More informationExceptions. Your computer takes exception. The Exception Class. Causes of Exceptions
Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:
More informationCIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13
CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis
More informationChapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4
More informationCMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 12: Virtual Memory Prof. Yajig Li Uiversity of Chicago A System with Physical Memory Oly Examples: most Cray machies early PCs Memory early all embedded systems
More informationClasses and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1
Classes ad Objects jvo@ualg.pt José Valete de Oliveira 4-1 Agai: Distace betwee poits withi the first quadrat Sample iput Sample output 1 1 3 4 2 jvo@ualg.pt José Valete de Oliveira 4-2 1 The simplest
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to
More informationMorgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5
Morga Kaufma Publishers 26 February, 28 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Set-Associative Cache Architecture Performace Summary Whe CPU performace icreases:
More informationData diverse software fault tolerance techniques
Data diverse software fault tolerace techiques Complemets desig diversity by compesatig for desig diversity s s limitatios Ivolves obtaiig a related set of poits i the program data space, executig the
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists
More informationCS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts
CS 111 Gree: Program Desig I Lecture 27: Speed (cot.); partig thoughts By Nascarkig - Ow work, CC BY-SA 4.0, https://commos.wikimedia.org/w/idex.php?curid=38671041 Robert H. Sloa (CS) & Rachel Poretsky
More informationChapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig
More informationWhat are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs
What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure
More informationPseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance
Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured
More informationEE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control
EE 459/500 HDL Based Digital Desig with Programmable Logic Lecture 13 Cotrol ad Sequecig: Hardwired ad Microprogrammed Cotrol Refereces: Chapter s 4,5 from textbook Chapter 7 of M.M. Mao ad C.R. Kime,
More informationUNIVERSITY OF MORATUWA
UNIVERSITY OF MORATUWA FACULTY OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING B.Sc. Egieerig 2014 Itake Semester 2 Examiatio CS2052 COMPUTER ARCHITECTURE Time allowed: 2 Hours Jauary 2016
More informationAvid Interplay Bundle
Avid Iterplay Budle Versio 2.5 Cofigurator ReadMe Overview This documet provides a overview of Iterplay Budle v2.5 ad describes how to ru the Iterplay Budle cofiguratio tool. Iterplay Budle v2.5 refers
More informationGuide to Applying Online
Guide to Applyig Olie Itroductio Respodig to requests for additioal iformatio Reportig: submittig your moitorig or ed of grat Pledges: submittig your Itroductio This guide is to help charities submit their
More informationWeston Anniversary Fund
Westo Olie Applicatio Guide 2018 1 This guide is desiged to help charities applyig to the Westo to use our olie applicatio form. The Westo is ope to applicatios from 5th Jauary 2018 ad closes o 30th Jue
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures
Uiversity of Waterloo Departmet of Electrical ad Computer Egieerig ECE 250 Algorithms ad Data Structures Midterm Examiatio ( pages) Istructor: Douglas Harder February 7, 2004 7:30-9:00 Name (last, first)
More information10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output
File class i Java File Iput ad Output TOPICS File Iput Exceptio Hadlig File Output Programmers refer to iput/output as "I/O". The File class represets files as objects. The class is defied i the java.io
More information. Written in factored form it is easy to see that the roots are 2, 2, i,
CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or
More informationCMSC Computer Architecture Lecture 15: Multi-Core. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 15: Multi-Core Prof. Yajig Li Uiversity of Chicago Course Evaluatio Very importat Please fill out! 2 Lab3 Brach Predictio Competitio 8 teams etered the competitio,
More informationChapter 5: Processor Design Advanced Topics. Microprogramming: Basic Idea
5-1 Chapter 5 Processor Desig Advaced Topics Chapter 5: Processor Desig Advaced Topics Topics 5.3 Microprogrammig Cotrol store ad microbrachig Horizotal ad vertical microprogrammig 5- Chapter 5 Processor
More informationElementary Educational Computer
Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 20 Itroductio to Trasactio Processig Cocepts ad Theory Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Trasactio Describes local
More informationAppendix D. Controller Implementation
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Appedix D Cotroller Implemetatio Cotroller Implemetatios Combiatioal logic (sigle-cycle); Fiite state machie (multi-cycle, pipelied);
More informationCSC 220: Computer Organization Unit 11 Basic Computer Organization and Design
College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:
More informationModule Instantiation. Finite State Machines. Two Types of FSMs. Finite State Machines. Given submodule mux32two: Instantiation of mux32two
Give submodule mux32two: 2-to- MUX module mux32two (iput [3:] i,i, iput sel, output [3:] out); Module Istatiatio Fiite Machies esig methodology for sequetial logic -- idetify distict s -- create trasitio
More informationIMP: Superposer Integrated Morphometrics Package Superposition Tool
IMP: Superposer Itegrated Morphometrics Package Superpositio Tool Programmig by: David Lieber ( 03) Caisius College 200 Mai St. Buffalo, NY 4208 Cocept by: H. David Sheets, Dept. of Physics, Caisius College
More informationEnd Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization
Ed Semester Examiatio 2013-14 CSE, III Yr. (I Sem), 30002: Computer Orgaizatio Istructios: GROUP -A 1. Write the questio paper group (A, B, C, D), o frot page top of aswer book, as per what is metioed
More informationAnalysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis
Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems
More informationMulti-Threading. Hyper-, Multi-, and Simultaneous Thread Execution
Multi-Threadig Hyper-, Multi-, ad Simultaeous Thread Executio 1 Performace To Date Icreasig processor performace Pipeliig. Brach predictio. Super-scalar executio. Out-of-order executio. Caches. Hyper-Threadig
More informationChapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3
More informationReview: The ACID properties
Recovery Review: The ACID properties A tomicity: All actios i the Xactio happe, or oe happe. C osistecy: If each Xactio is cosistet, ad the DB starts cosistet, it eds up cosistet. I solatio: Executio of
More informationCMPT 125 Assignment 2 Solutions
CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address
More informationOverview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup
Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates
More informationMorgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5.
Morga Kaufma Publishers 26 February, 208 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Virtual Memory Review: The Memory Hierarchy Take advatage of the priciple
More information27 Refraction, Dispersion, Internal Reflection
Chapter 7 Refractio, Dispersio, Iteral Reflectio 7 Refractio, Dispersio, Iteral Reflectio Whe we talked about thi film iterferece, we said that whe light ecouters a smooth iterface betwee two trasparet
More informationComputers and Scientific Thinking
Computers ad Scietific Thikig David Reed, Creighto Uiversity Chapter 15 JavaScript Strigs 1 Strigs as Objects so far, your iteractive Web pages have maipulated strigs i simple ways use text box to iput
More information6.854J / J Advanced Algorithms Fall 2008
MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms
More informationArchitectural styles for software systems The client-server style
Architectural styles for software systems The cliet-server style Prof. Paolo Ciacarii Software Architecture CdL M Iformatica Uiversità di Bologa Ageda Cliet server style CS two tiers CS three tiers CS
More informationGreedy Algorithms. Interval Scheduling. Greedy Algorithms. Interval scheduling. Greedy Algorithms. Interval Scheduling
Greedy Algorithms Greedy Algorithms Witer Paul Beame Hard to defie exactly but ca give geeral properties Solutio is built i small steps Decisios o how to build the solutio are made to maximize some criterio
More informationLecture 1: Introduction and Strassen s Algorithm
5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access
More informationCSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)
CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a
More informationExamples and Applications of Binary Search
Toy Gog ITEE Uiersity of Queeslad I the secod lecture last week we studied the biary search algorithm that soles the problem of determiig if a particular alue appears i a sorted list of iteger or ot. We
More informationCustomer Portal Quick Reference User Guide
Customer Portal Quick Referece User Guide Overview This user guide is iteded for FM Approvals customers usig the Approval Iformatio Maagemet (AIM) customer portal to track their active projects. AIM is
More informationCIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19
CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.
More informationSoftware development of components for complex signal analysis on the example of adaptive recursive estimation methods.
Software developmet of compoets for complex sigal aalysis o the example of adaptive recursive estimatio methods. SIMON BOYMANN, RALPH MASCHOTTA, SILKE LEHMANN, DUNJA STEUER Istitute of Biomedical Egieerig
More informationRunning Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments
Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The
More informationRunning Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments
Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.
More informationAnalysis of Algorithms
Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The
More informationChapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 8 Strigs ad Vectors Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Slide 8-3 8.1 A Array Type for Strigs A Array Type for Strigs C-strigs ca be used to represet strigs
More informationComputer Science Foundation Exam. August 12, Computer Science. Section 1A. No Calculators! KEY. Solutions and Grading Criteria.
Computer Sciece Foudatio Exam August, 005 Computer Sciece Sectio A No Calculators! Name: SSN: KEY Solutios ad Gradig Criteria Score: 50 I this sectio of the exam, there are four (4) problems. You must
More informationGraphs. Minimum Spanning Trees. Slides by Rose Hoberman (CMU)
Graphs Miimum Spaig Trees Slides by Rose Hoberma (CMU) Problem: Layig Telephoe Wire Cetral office 2 Wirig: Naïve Approach Cetral office Expesive! 3 Wirig: Better Approach Cetral office Miimize the total
More informationComputer Architecture. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
Computer rchitecture Microcomputer rchitecture ad Iterfacig Colorado School of Mies Professor William Hoff Computer Hardware Orgaizatio Processor Performs all computatios; coordiates data trasfer Iput
More informationCMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 3: ISA ad Itroductio to Microarchitecture Prof. Yajig Li Uiversity of Chicago Lecture Outlie ISA uarch (hardware implemetatio of a ISA) Logic desig basics Sigle-cycle
More informationCMSC Computer Architecture Lecture 10: Caches. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 10: Caches Prof. Yajig Li Uiversity of Chicago Midterm Recap Overview ad fudametal cocepts ISA Uarch Datapath, cotrol Sigle cycle, multi cycle Pipeliig Basic idea,
More informationGuaranteeing Hard Real Time End-to-End Communications Deadlines
Guarateeig Hard Real Time Ed-to-Ed Commuicatios Deadlies K. W. Tidell A. Burs A. J. Welligs Real Time Systems Research Group Departmet of Computer Sciece Uiversity of York e-mail: ke@mister.york.ac.uk
More informationDEFINITION OF CELL BEHAVIOUR. Actions and Behaviour. CELL = a CELL CELL = b CELL
Actios ad Behaviour Let us start to itroduce some modellig laguage features which will allow us to model the behaviour of a cell compoet. Suppose the cell compoet holds a sigle piece of iformatio which
More informationUsing VTR Emulation on Avid Systems
Usig VTR Emulatio o Avid Systems VTR emulatio allows you to cotrol a sequece loaded i the Record moitor from a edit cotroller for playback i the edit room alog with other sources. I this sceario the edit
More informationn Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis
Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig
More informationReliable Transmission. Spring 2018 CS 438 Staff - University of Illinois 1
Reliable Trasmissio Sprig 2018 CS 438 Staff - Uiversity of Illiois 1 Reliable Trasmissio Hello! My computer s ame is Alice. Alice Bob Hello! Alice. Sprig 2018 CS 438 Staff - Uiversity of Illiois 2 Reliable
More informationCOP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen
COP4020 mig Laguages Compilers ad Iterpreters Prof. Robert va Egele Overview Commo compiler ad iterpreter cofiguratios Virtual machies Itegrated developmet eviromets Compiler phases Lexical aalysis Sytax
More informationChapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4
More informationInvestigation Monitoring Inventory
Ivestigatio Moitorig Ivetory Name Period Date Art Smith has bee providig the prits of a egravig to FieArt Gallery. He plas to make just 2000 more prits. FieArt has already received 70 of Art s prits. The
More informationΤεχνολογία Λογισμικού
ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών και Μηχανικών Υπολογιστών Τεχνολογία Λογισμικού, 7ο/9ο εξάμηνο 2018-2019 Τεχνολογία Λογισμικού Ν.Παπασπύρου, Αν.Καθ. ΣΗΜΜΥ, ickie@softlab.tua,gr
More informationEE University of Minnesota. Midterm Exam #1. Prof. Matthew O'Keefe TA: Eric Seppanen. Department of Electrical and Computer Engineering
EE 4363 1 Uiversity of Miesota Midterm Exam #1 Prof. Matthew O'Keefe TA: Eric Seppae Departmet of Electrical ad Computer Egieerig Uiversity of Miesota Twi Cities Campus EE 4363 Itroductio to Microprocessors
More information3.1 Overview of MySQL Programs. These programs are discussed further in Chapter 4, Database Administration. Client programs that access the server:
3 Usig MySQL Programs This chapter provides a brief overview of the programs provided by MySQL AB ad discusses how to specify optios whe you ru these programs. Most programs have optios that are specific
More informationData Structures and Algorithms. Analysis of Algorithms
Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 22 Database Recovery Techiques Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Recovery algorithms Recovery cocepts Write-ahead
More informationProgramming with Shared Memory PART II. HPC Spring 2017 Prof. Robert van Engelen
Programmig with Shared Memory PART II HPC Sprig 2017 Prof. Robert va Egele Overview Sequetial cosistecy Parallel programmig costructs Depedece aalysis OpeMP Autoparallelizatio Further readig HPC Sprig
More informationJava net programming II
Java et programmig II https://docs.oracle.com/javase/tutorial/etworkig/sockets/ Overview The problem Basic backgroud: TCP/IP, ports, Cliet/Server, sockets Commuicatio with sockets java.et (overview) Simple
More informationEvaluation scheme for Tracking in AMI
A M I C o m m u i c a t i o A U G M E N T E D M U L T I - P A R T Y I N T E R A C T I O N http://www.amiproject.org/ Evaluatio scheme for Trackig i AMI S. Schreiber a D. Gatica-Perez b AMI WP4 Trackig:
More informationHow do we evaluate algorithms?
F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:
More informationWeb OS Switch Software
Web OS Switch Software BBI Quick Guide Nortel Networks Part Number: 213164, Revisio A, July 2000 50 Great Oaks Boulevard Sa Jose, Califoria 95119 408-360-5500 Mai 408-360-5501 Fax www.orteletworks.com
More informationcondition w i B i S maximum u i
ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility
More informationCopyright 2016 Ramez Elmasri and Shamkant B. Navathe
Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 21 Cocurrecy Cotrol Techiques Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio Cocurrecy cotrol protocols Set of rules to guaratee
More informationChapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 8 Strigs ad Vectors Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 8.1 A Array Type for Strigs 8.2 The Stadard strig Class 8.3 Vectors Copyright 2015 Pearso Educatio, Ltd..
More informationMOTIF XF Extension Owner s Manual
MOTIF XF Extesio Ower s Maual Table of Cotets About MOTIF XF Extesio...2 What Extesio ca do...2 Auto settig of Audio Driver... 2 Auto settigs of Remote Device... 2 Project templates with Iput/ Output Bus
More informationExercise Set: Implementing an Object-Oriented Design
Exercise Set: Implemetig a Object-Orieted Desig I this exercise set, we have marked questios we thik are harder tha others with a [ ]. We have also marked questios for which solutios are provided at the
More informationA graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n))
ca see that time required to search/sort grows with size of We How do space/time eeds of program grow with iput size? iput. time: cout umber of operatios as fuctio of iput Executio size operatio Assigmet:
More informationData Structures Week #9. Sorting
Data Structures Week #9 Sortig Outlie Motivatio Types of Sortig Elemetary (O( 2 )) Sortig Techiques Other (O(*log())) Sortig Techiques 21.Aralık.2010 Boraha Tümer, Ph.D. 2 Sortig 21.Aralık.2010 Boraha
More informationThe Magma Database file formats
The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,
More informationL6: FSMs and Synchronization
L6: FSMs ad Sychroizatio Ackowledgemets: Materials i this lecture are courtesy of the followig sources ad are used with permissio. Rex Mi J. Rabaey, A. Chadrakasa, B. Nikolic. igital Itegrated Circuits:
More informationChapter 5. Functions for All Subtasks. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 5 Fuctios for All Subtasks Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 5.1 void Fuctios 5.2 Call-By-Referece Parameters 5.3 Usig Procedural Abstractio 5.4 Testig ad Debuggig
More informationUH-MEM: Utility-Based Hybrid Memory Management. Yang Li, Saugata Ghose, Jongmoo Choi, Jin Sun, Hui Wang, Onur Mutlu
UH-MEM: Utility-Based Hybrid Memory Maagemet Yag Li, Saugata Ghose, Jogmoo Choi, Ji Su, Hui Wag, Our Mutlu 1 Executive Summary DRAM faces sigificat techology scalig difficulties Emergig memory techologies
More information