+ Section 3 Threading and Locking + Definitions What is a thread? - - PowerPoint PPT Presentation

section 3 threading and locking definitions what is a
SMART_READER_LITE
LIVE PREVIEW

+ Section 3 Threading and Locking + Definitions What is a thread? - - PowerPoint PPT Presentation

+ Section 3 Threading and Locking + Definitions What is a thread? + Definitions What is a thread? A single flow of control with a process + Definitions What is a thread? A single flow of control with a process Why use threads? + Definitions


slide-1
SLIDE 1

+

Section 3

Threading and Locking

slide-2
SLIDE 2

+Definitions

What is a thread?

slide-3
SLIDE 3

+Definitions

What is a thread? A single flow of control with a process

slide-4
SLIDE 4

+Definitions

What is a thread? A single flow of control with a process Why use threads?

slide-5
SLIDE 5

+Definitions

What is a thread? A single flow of control with a process Why use threads? Exploit latency, concurrency

Event-driven software

slide-6
SLIDE 6

+Dangers

What could go wrong?

slide-7
SLIDE 7

+Dangers

What could go wrong? Race Conditions

slide-8
SLIDE 8

+Dangers

What could go wrong? Race Conditions How do we fix this?

slide-9
SLIDE 9

+Dangers

What could go wrong? Race Conditions How do we fix this? Locking

slide-10
SLIDE 10

+Definitions

What is a lock?

slide-11
SLIDE 11

+Definitions

What is a lock?

Serializes access to some critical region of code or data Used to enforce mutual exclusion concurrency control

slide-12
SLIDE 12

+Definitions

What is a lock?

Serializes access to some critical region of code or data Used to enforce mutual exclusion concurrency control Locks need help from hardware

slide-13
SLIDE 13

+Definitions

What is a lock?

Serializes access to some critical region of code or data Used to enforce mutual exclusion concurrency control Locks need help from hardware Different kinds of locks

slide-14
SLIDE 14

+Dangers

What could go wrong?

slide-15
SLIDE 15

+Dangers

What could go wrong? Impacts Performance

slide-16
SLIDE 16

+Dangers

What could go wrong? Impacts Performance

Hard to debug

slide-17
SLIDE 17

+Dangers

What could go wrong? Impacts Performance

Hard to debug Deadlocks

slide-18
SLIDE 18

+Dangers

What could go wrong? Impacts Performance

Hard to debug Deadlocks

How do we fix this?

slide-19
SLIDE 19

+Dangers

What could go wrong? Impacts Performance

Hard to debug Deadlocks

How do we fix this? Punt (if collisions aren’t our problem)

slide-20
SLIDE 20

+Dangers

What could go wrong? Impacts Performance

Hard to debug Deadlocks

How do we fix this? Punt (if collisions aren’t our problem)

Resource hierarchy/Conductor/Chandy-Misra

slide-21
SLIDE 21

+Using Threads

Creation Termination Detachment and Joining Self and Equal

slide-22
SLIDE 22

+Using Threads

Thread (class) Runnable (interface) ForkJoin ThreadPools/Executor Services

slide-23
SLIDE 23

+Project 0 Review

slide-24
SLIDE 24

+Project 1 Suggestions

John’s Suggestion

One thread for listening (waiting for server probes) One thread for keyboard input that handles server communication initiated by keyboard input One thread for periodic re-registration

slide-25
SLIDE 25

+Project 1 Reminders

John’s Suggestion

One thread for listening (waiting for server probes) One thread for keyboard input that handles server communication initiated by keyboard input One thread for periodic re-registration

Remember Terminate cleanly

You need to re-register Modularity

slide-26
SLIDE 26

+Questions?

Java:

http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html http://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/ thread_basics.html

C/Unix: http://www.mit.edu/people/proven/IAP_2000/index.html http://www.yolinux.com/TUTORIALS/ LinuxTutorialPosixThreads.html