Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.

Slides:



Advertisements
Similar presentations
Instruction Level Parallelism and Superscalar Processors
Advertisements

Dependence Precedence. Precedence & Dependence Can we execute a 1000 line program with 1000 processors in one step? What are the issues to deal with in.
CS16: Data Structures & Algorithms | Spring 2014 Midterm Review 3/16/
Introduction to Computer Science Theory
Divide and Conquer Yan Gu. What is Divide and Conquer? An effective approach to designing fast algorithms in sequential computation is the method known.
Merge Sort1 Part-G1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Java How to Program, 9/e CET 3640 Professor: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
Quick-Sort     29  9.
© 2004 Goodrich, Tamassia Quick-Sort     29  9.
Searching and Sorting. Overview Search Analysis of search algorithms Sorting Analysis of sort algorithms Recursion p. 2 of 26.
© 2004 Goodrich, Tamassia Sorting Lower Bound1. © 2004 Goodrich, Tamassia Sorting Lower Bound2 Comparison-Based Sorting (§ 10.3) Many sorting algorithms.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
Search and Recursion CS221 – 2/23/09. List Search Algorithms Linear Search: Simple search through unsorted data. Time complexity = O(n) Binary Search:
CS 584. A Parallel Programming Model We need abstractions to make it simple. The programming model needs to fit our parallel machine model. Abstractions.
Processes, Threads and Scheduling OS Lecture #4. Processes Unit of resource allocation in the OS Allocation of space Clock time The abstraction of a process.
Wednesday, 11/25/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 11/25/02  QUESTIONS??  Today:  More on sorting. Advanced sorting algorithms.  Complexity:
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Wednesday, 11/13/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 11/13/02  QUESTIONS??  Today:  More on searching a list; binary search  Sorting a list;
Sorting Algorithms and Analysis Robert Duncan. Refresher on Big-O  O(2^N)Exponential  O(N^2)Quadratic  O(N log N)Linear/Log  O(N)Linear  O(log N)Log.
By D.Kumaragurubaran Adishesh Pant
Java How to Program, 9/e CET 3640 Professor: Dr. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Threading in Java – a Tutorial QMUL IEEE SB. Why Threading When we need to run two tasks concurrently So multiple parts (>=2) of a program can run simultaneously.
What is Concurrent Programming? Maram Bani Younes.
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises.
CS453 Lecture 3.  A sequential algorithm is evaluated by its runtime (in general, asymptotic runtime as a function of input size).  The asymptotic runtime.
By Garrett Kelly. 3 types or reasons for distributed applications Data Data used by the application is distributed Computation Computation is distributed.
PRET-OS for Biomedical Devices A Part IV Project.
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Chapter 12 Binary Search and QuickSort Fundamentals of Java.
SORTING 2014-T2 Lecture 13 School of Engineering and Computer Science, Victoria University of Wellington COMP 103 Marcus Frean.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Sorting.
1 Radix Sort. 2 Classification of Sorting algorithms Sorting algorithms are often classified using different metrics:  Computational complexity: classification.
CS- 492 : Distributed system & Parallel Processing Lecture 7: Sun: 15/5/1435 Foundations of designing parallel algorithms and shared memory models Lecturer/
Floating Point Numbers & Parallel Computing. Outline Fixed-point Numbers Floating Point Numbers Superscalar Processors Multithreading Homogeneous Multiprocessing.
Sorting 1. Insertion Sort
Algorithms.
Complexity Analysis. 2 Complexity The complexity of an algorithm quantifies the resources needed as a function of the amount of input data size. The resource.
Data Structures and Algorithms in Parallel Computing Lecture 8.
1 Merge Sort 7 2  9 4   2  2 79  4   72  29  94  4.
Heap Sort Uses a heap, which is a tree-based data type Steps involved: Turn the array into a heap. Delete the root from the heap and insert into the array,
Programming Multi-Core Processors based Embedded Systems A Hands-On Experience on Cavium Octeon based Platforms Lab Exercises: Lab 1 (Performance measurement)
Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a.
Introduction Goal: connecting multiple computers to get higher performance – Multiprocessors – Scalability, availability, power efficiency Job-level (process-level)
Page 1 2P13 Week 1. Page 2 Page 3 Page 4 Page 5.
329 3/30/98 CSE 143 Searching and Sorting [Sections 12.4, ]
Lec 10 agenda >git fetch origin lab10g; > git checkout -b lab10g origin/lab10g; Format/rules for Week 11 Advanced Topics (all beyond the scope of this.
Mergesort example: Merge as we return from recursive calls Merge Divide 1 element 829.
Using the VTune Analyzer on Multithreaded Applications
Multithreading / Concurrency
Sorting by Tammy Bailey
CS302 Data Structures Fall 2012.
Chapter 4 Multithreading programming
Chapter 15, Exploring the Digital Domain
Lec 09 Agenda 1/ Searching and sorting, logs
EE 422C Final Exam Review.
Sorting.
Sub-Quadratic Sorting Algorithms
Multithread Programming
Process Management -Compiled for CSIT
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Mobile Computing Dr. Mohsin Ali Memon.
CSE 332: Parallel Algorithms
Presentation transcript:

Concurrency (Threads) Threads allow you to do tasks in parallel. In an unthreaded program, you code is executed procedurally from start to finish. In a threaded program, you can have multiple threads working concurrently.

Concurrency (Threads) Concurrency is achieved through time-slicing. This is where the processor cycles through each active thread for an indeterminate period of time (the slice). This gives the illusion that there are multiple processes. With multi-core processors, this may mean, true multi-threading is possible, but NOT guaranteed

Thread Pools Thread Pools manage (and limit) the number of active threads. This tends to be more orderly and more efficient for scaled applications.

Synchronizing methods When multiple threads have access to the same object, it makes sense to synchronize those methods which are prone to concurrency errors. The bank account example.

Thread-safe collections // pi/java/util/concurrent/package- summary.html

Searching Linear search O(n) --slow Binary search O(log 2 n) --fast Refresher on logs: If 2 3 = 8 then log 2 8 = 3 Hashed search O(1) –fastest Search driver class

Sorting SelectionSort O(n 2 ) –-slow MergeSort O(n * log 2 n) –- fast HeapSort O(n * log 2 n) –- fast QuickSort O(n * log 2 n) –- fast