lecture19 - CSE 335 Dr. Charles B. Owen Object-Oriented...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 335 Dr. Charles B. Owen Object-Oriented Programming 1 Concurrency and Multithreading Threads application available on the class website CSE 335 Dr. Charles B. Owen Object-Oriented Programming 2 Moores Law CSE 335 Dr. Charles B. Owen Object-Oriented Programming 3 Moores Law The number of transistors that can be placed inexpensively on an integrated circuit doubles approximately every two years. What does this mean about speed? Will this go on forever? 1 CSE 335 Dr. Charles B. Owen Object-Oriented Programming 4 Observations If Moores law kept going for about 250 years, the number of transistors would exceed the number of atoms in our planet. After 500 years, the number of transistors on a chip would exceed the number of atoms in the universe. All good things must come to an end! CSE 335 Dr. Charles B. Owen Object-Oriented Programming 5 Moores Law and CPU Clock Speeds So, how can we make programs faster? CSE 335 Dr. Charles B. Owen Object-Oriented Programming 6 Concurrency Multiple processes existing simultaneously, potentially interacting with each other. When we have multiple CPUs (cores) we can assign processes to each, allowing them to work in parallel! CSE 335 Dr. Charles B. Owen Object-Oriented Programming 7 Concurrency Advantages Increased performance (more CPUs working) Mixing batch processing with event-driven processing Easier to use resources that block Isolating work Working in the background Advantages for both single- and multiple- processor applications CSE 335 Dr. Charles B. Owen Object-Oriented Programming 8 Concurrency Disadvantages Code is much more difficult to write and debug Some tasks are very hard to parallelized Introduces a random element into the execution of your program CSE 335 Dr. Charles B. Owen Object-Oriented Programming 9 Threads We can have concurrent processes or threads A thread is a new thread of execution, an execution context, that shares the memory and state of a process. We commonly refer to multi- threading CSE 335 Dr. Charles B. Owen Object-Oriented Programming 10 Threads vs. Processes Process Thread Start fork() pthread_create() Independence Independent Within a processes State Independent Shared Address space Separate Shared Communication Inter-process Shared and signals Context switch Slow Fast In General Expensive Cheap Modern processors have extensive support for fast multi-threading implementations. CSE 335 Dr. Charles B. Owen Object-Oriented Programming 11 A simple application Multiplies two 500x500 matrices Display timing information Continuously running Cylon eye CSE 335 Dr. Charles B. Owen Object-Oriented Programming...
View Full Document

Page1 / 45

lecture19 - CSE 335 Dr. Charles B. Owen Object-Oriented...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online