SlideShare une entreprise Scribd logo
1  sur  35
Pree Thiengburanathum
Nopparat Suwannarat

1
Agenda
Background
Motivation
Contribution
Working environment
Program design and Implementations
Measurements
Workloads
Benchmark
Analysis
Conclusion
Question
2
Background – quick overview
Multi-programming
Multi-processing
Multi-threading
Thread
Homogenous CMP system

3
Background
JAVA API Thread
start()
run()
wait()
join()
sleep()
getName()
isAlive()
Thread.isSleep()
4
JAVA Thread API
Wait : public final void wait(long timeout,

int nanos)

Causes the current thread to wait until another thread

invokes the method for this object, or some other
thread interrupts the current thread, or a certain
amount of real time has elapsed

Start : public void start()
Causes this thread to begin execution; the Java Virtual

Machine calls the run method of this thread.
JAVA Thread API
Run : public void run()
If this thread was constructed using a separate
Runnable run object, then that Runnable object's run
method is called; otherwise, this method does nothing
and returns. Subclasses of Thread should override this
method
Stop : public final void stop()
An application should not normally try to catch
ThreadDeath unless it must do some extraordinary
cleanup operation . If a catch clause catches a
ThreadDeath object, it is important to rethrow the
object so that the thread actually dies.
JAVA Thread API
Sleep : public static void sleep(long millis)
Causes the currently executing thread to sleep for the

specified number of milliseconds, subject to the
precision and accuracy of system timers and schedulers.
The thread does not lose ownership of any monitors.

Join : public final void join()
Waits for this thread to die.
Motivation
Multithreading with JAVA on large problems.
For large computation problems, we would like to
know how much performance will be improved if we
use thread-based programming instead of execute by
one process.
How multi processors affects when programming

with JAVA thread.
Advantages and disadvantages of multithread
programming with real applications.
Gain experiences with JAVA Thread, multi-thread
programming, CMP system, and various tools.

8
Contributions
Software : A JAVA program benchmark.


Why JAVA?
 Portability, can easily test on different operating systems.
 Synchronization

Three Workloads (input) modules.


Want to see the performance when having multiple
processors compute the workloads in multiprogramming
environment.

9
Working Environments
Operating Systems
Microsoft Window Vista
Ubuntu, Linux-based operating system.
VMWare virtual machine.

Tools and language
Eclipse IDE with JAVA JRE 1.6.03, JRE 1.5.0_13
Project hosting at (Google code) Subversion repository


URL: http://code.google.com/p/thread-programmingmultiprocessors/

10
Working Environments
Google code project.

11
Benchmark
Three input(workloads), large problems which can be

divided into small sub problems.
Trapezoid’s rule
Sorting array
Fibonacci number

12
Workloads Trapezoid's Rule
To compute the area under the function or Integrate

the function by compute the summation of the small
rectangular.

13
Workloads Trapezoid's Rule (cont.)
Trapezoid's Rule – An example of the complicate

function, a = 0, b = 10

14
Workloads Trapezoid's Rule(cont.)
Trapezoid's Rule – two threads and how they are

assigned.

15
Workloads Sorting Arrays
Sorting Random Integer Arrays.
Array before sort
8949

-3467

101

-2367

4050

2766

2

Assign a chuck of array to each thread.
8949

-3467

Thread 1

101

-2367

Thread 2

4050

2766

2

Thread 3
16
Workloads Sorting Arrays (cont.)
Sorting Random Integer Arrays.
The Array after sort
-3467

-2367

2

101

2766

4050

8949

17
Workloads Fibonacci number
the Fibonacci numbers are a sequence of numbers

named after Leonardo of Pisa, known as Fibonacci.
The first number of the sequence is 0
the second number is 1
each subsequent number is equal to the sum of the

previous two numbers of the sequence itself
Fibonacci number (cont.)
F0
0

F1
1

F2
1

F3
2

F4
3

F5
5

The family trees of cows and bees, the Fibonacci series, the Fibonacci Spiral
and sea shell shapes, branching plants, flower petal and seeds, leaves and
petal arrangements, on pineapples and in apples, pine cones and leaf
arrangements. All involve the Fibonacci
Fibonacci number (cont.)
Fibonacci number (cont.)
Program Design – UML


22
Program Implementation
Examples of program input
rapry@Morphine:~/csc5573/ThreadSim/ java ThreadSim 1
Run workloads with 1 thread(s).
Start trapaziod workload...
Thread-1 is running trapazoid workload.
Start sorting workload...
execution time is: 3879000 nanoseconds.
Running fibo workload...
Done finding fibonacci number.
execution time is: 12,192,912,000 nanoseconds.
Finished all the workloads.
Total execution time is: 12.19874 seconds.

23
Measurements
Number of thread and performance of large

problems.
Performance in multiple processors environment.
Performance in various operating systems
Window/Linux and so on.
Measurements on:
Intel Core 2 Duo, 3.0Ghz, 2G RAM, Vista, Ubuntu
Intel Centrino Duo, 1.44Ghz, 2G RAM, Vista
Run 3 times and find the average of the total execution
time.
24
Benchmark – 1 Vista
JAVA Thread(s) run for each workload

Time in seconds

25
Benchmark – 2 Vista

Time in seconds

26
Benchmark – 1 Ubuntu
JAVA Thread(s) run for each workload

Time in seconds

27
Benchmark – 2 Ubuntu

Time in seconds

28
Results Analysis
Benchmark 1 (divide large problem into sub

problems)

If we assign right number of thread to compute the

problems, better execution time.
The more thread assign to the problem, the worse
performance we get.

Benchmark 2 (a pack of workloads)
The more thread we assign to compute those problems,

the worse execution time we will have.

29
Results Analysis
For a better results we will need
CPU Intensive application


Need very large problem to compute in order to see an
improvement.

I/O Intensive application

See significantly improvement of execution time.
 Example.


30
Conclusion
JAVA Threads
Advantages
Better interaction with user.
Exploitation of multiple processors.
Do other things while waiting for Slow I/O operations.
Simplify object modeling
Synchronized, lock objects and classes
Inter-thread communication support


wait(), notify()
31
Conclusion(cont.)
JAVA Threads
Disadvantages

Memory resources
 Two stacks assigned by JavaVM
 One is used to keep track of java method calls and vars.
 The other stack is used to keep track of native code calls
 Processor resources
 Overhead, context switch
 Thread operations (start, stop, destroy).
 When adding additional threads to the design of a system,
these costs should be considered.


32
Conclusion(cont.)
JAVA Multi-thread programming
 Less effective in single processor?
 Need to assign right number of thread, more thread doesn’t
mean good.
 No synchronization need. No critical section in the program.
 Effective when the problem require intensive I/O operation.
 Programmer has to know the problem well in order to use
thread-based programming to archive the maximum.
utilization of system resources.
 Easy to start, tough to master.



Auto-garbage collection
Tasks such as getting lock, releasing lock are simplified.
33
References
[1] JAVA Standard Edition 6 API, Sun Microsystems,

http://java.sun.com/javase/6/docs/api/, 2006
[2] Eclipse IDE, www.eclipse.org, 2008
[3] Paul, H., Java Thread Programming, 1999
[4] Scott O., Henry W., Java Threads 2nd edition, 2001
[4] Operating System Concepts, by Silberschatz.
Galvin, and Gangne, 7th Edition , Wiley 2005.
Fibonacci,
http://britton.disted.camosun.bc.ca/fibslide/jbfibslide
.htmhttp://en.wikipedia.org/wiki/Fibonacci_number
34
Question

35

Contenu connexe

Tendances

Multithreading
MultithreadingMultithreading
Multithreading
sagsharma
 
JProfiler / an introduction
JProfiler / an introductionJProfiler / an introduction
JProfiler / an introduction
Tommaso Torti
 
Slot02 concurrency1
Slot02 concurrency1Slot02 concurrency1
Slot02 concurrency1
Viên Mai
 

Tendances (19)

Multithreading
MultithreadingMultithreading
Multithreading
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Chap2 2 1
Chap2 2 1Chap2 2 1
Chap2 2 1
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
Multi threading
Multi threadingMulti threading
Multi threading
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
JProfiler / an introduction
JProfiler / an introductionJProfiler / an introduction
JProfiler / an introduction
 
Java Course 10: Threads and Concurrency
Java Course 10: Threads and ConcurrencyJava Course 10: Threads and Concurrency
Java Course 10: Threads and Concurrency
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 
Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
 
Java Performance & Profiling
Java Performance & ProfilingJava Performance & Profiling
Java Performance & Profiling
 
Training course lect1
Training course lect1Training course lect1
Training course lect1
 
Concurrency with java
Concurrency with javaConcurrency with java
Concurrency with java
 
Slot02 concurrency1
Slot02 concurrency1Slot02 concurrency1
Slot02 concurrency1
 
Free FreeRTOS Course-Task Management
Free FreeRTOS Course-Task ManagementFree FreeRTOS Course-Task Management
Free FreeRTOS Course-Task Management
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 

Similaire à Java multi thread programming on cmp system

WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
babayaga920391
 
Multithreading
MultithreadingMultithreading
Multithreading
backdoor
 

Similaire à Java multi thread programming on cmp system (20)

OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTESOBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
OBJECT ORIENTED PROGRAMMING LANGUAGE - SHORT NOTES
 
Java Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data StructuresJava Performance, Threading and Concurrent Data Structures
Java Performance, Threading and Concurrent Data Structures
 
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptxWEEK07operatingsystemdepartmentofsoftwareengineering.pptx
WEEK07operatingsystemdepartmentofsoftwareengineering.pptx
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Threads
ThreadsThreads
Threads
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
04 threads-pbl-2-slots
04 threads-pbl-2-slots04 threads-pbl-2-slots
04 threads-pbl-2-slots
 
Multi t hreading_14_10
Multi t hreading_14_10Multi t hreading_14_10
Multi t hreading_14_10
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Multithreading.pptx
Multithreading.pptxMultithreading.pptx
Multithreading.pptx
 
Basic java part_ii
Basic java part_iiBasic java part_ii
Basic java part_ii
 
25 java tough interview questions
25 java tough interview questions25 java tough interview questions
25 java tough interview questions
 
J threads-pdf
J threads-pdfJ threads-pdf
J threads-pdf
 
Multithreading
MultithreadingMultithreading
Multithreading
 
A Casual Teaching Tool for Large Size Computer Laboratories ans Small Size Se...
A Casual Teaching Tool for Large Size Computer Laboratories ans Small Size Se...A Casual Teaching Tool for Large Size Computer Laboratories ans Small Size Se...
A Casual Teaching Tool for Large Size Computer Laboratories ans Small Size Se...
 
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
distage: Purely Functional Staged Dependency Injection; bonus: Faking Kind Po...
 
Performance Analysis of Idle Programs
Performance Analysis of Idle ProgramsPerformance Analysis of Idle Programs
Performance Analysis of Idle Programs
 

Plus de QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN (11)

Uml for Java Programmers
Uml for Java ProgrammersUml for Java Programmers
Uml for Java Programmers
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java
JavaJava
Java
 
Java
JavaJava
Java
 
Java
JavaJava
Java
 
Java applets
Java appletsJava applets
Java applets
 
Introduction to-java
Introduction to-javaIntroduction to-java
Introduction to-java
 
Introduction+to+java+2
Introduction+to+java+2Introduction+to+java+2
Introduction+to+java+2
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Threads
ThreadsThreads
Threads
 

Dernier

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Dernier (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 

Java multi thread programming on cmp system

  • 2. Agenda Background Motivation Contribution Working environment Program design and Implementations Measurements Workloads Benchmark Analysis Conclusion Question 2
  • 3. Background – quick overview Multi-programming Multi-processing Multi-threading Thread Homogenous CMP system 3
  • 5. JAVA Thread API Wait : public final void wait(long timeout, int nanos) Causes the current thread to wait until another thread invokes the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed Start : public void start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
  • 6. JAVA Thread API Run : public void run() If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns. Subclasses of Thread should override this method Stop : public final void stop() An application should not normally try to catch ThreadDeath unless it must do some extraordinary cleanup operation . If a catch clause catches a ThreadDeath object, it is important to rethrow the object so that the thread actually dies.
  • 7. JAVA Thread API Sleep : public static void sleep(long millis) Causes the currently executing thread to sleep for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers. The thread does not lose ownership of any monitors. Join : public final void join() Waits for this thread to die.
  • 8. Motivation Multithreading with JAVA on large problems. For large computation problems, we would like to know how much performance will be improved if we use thread-based programming instead of execute by one process. How multi processors affects when programming with JAVA thread. Advantages and disadvantages of multithread programming with real applications. Gain experiences with JAVA Thread, multi-thread programming, CMP system, and various tools. 8
  • 9. Contributions Software : A JAVA program benchmark.  Why JAVA?  Portability, can easily test on different operating systems.  Synchronization Three Workloads (input) modules.  Want to see the performance when having multiple processors compute the workloads in multiprogramming environment. 9
  • 10. Working Environments Operating Systems Microsoft Window Vista Ubuntu, Linux-based operating system. VMWare virtual machine. Tools and language Eclipse IDE with JAVA JRE 1.6.03, JRE 1.5.0_13 Project hosting at (Google code) Subversion repository  URL: http://code.google.com/p/thread-programmingmultiprocessors/ 10
  • 12. Benchmark Three input(workloads), large problems which can be divided into small sub problems. Trapezoid’s rule Sorting array Fibonacci number 12
  • 13. Workloads Trapezoid's Rule To compute the area under the function or Integrate the function by compute the summation of the small rectangular. 13
  • 14. Workloads Trapezoid's Rule (cont.) Trapezoid's Rule – An example of the complicate function, a = 0, b = 10 14
  • 15. Workloads Trapezoid's Rule(cont.) Trapezoid's Rule – two threads and how they are assigned. 15
  • 16. Workloads Sorting Arrays Sorting Random Integer Arrays. Array before sort 8949 -3467 101 -2367 4050 2766 2 Assign a chuck of array to each thread. 8949 -3467 Thread 1 101 -2367 Thread 2 4050 2766 2 Thread 3 16
  • 17. Workloads Sorting Arrays (cont.) Sorting Random Integer Arrays. The Array after sort -3467 -2367 2 101 2766 4050 8949 17
  • 18. Workloads Fibonacci number the Fibonacci numbers are a sequence of numbers named after Leonardo of Pisa, known as Fibonacci. The first number of the sequence is 0 the second number is 1 each subsequent number is equal to the sum of the previous two numbers of the sequence itself
  • 19. Fibonacci number (cont.) F0 0 F1 1 F2 1 F3 2 F4 3 F5 5 The family trees of cows and bees, the Fibonacci series, the Fibonacci Spiral and sea shell shapes, branching plants, flower petal and seeds, leaves and petal arrangements, on pineapples and in apples, pine cones and leaf arrangements. All involve the Fibonacci
  • 22. Program Design – UML  22
  • 23. Program Implementation Examples of program input rapry@Morphine:~/csc5573/ThreadSim/ java ThreadSim 1 Run workloads with 1 thread(s). Start trapaziod workload... Thread-1 is running trapazoid workload. Start sorting workload... execution time is: 3879000 nanoseconds. Running fibo workload... Done finding fibonacci number. execution time is: 12,192,912,000 nanoseconds. Finished all the workloads. Total execution time is: 12.19874 seconds. 23
  • 24. Measurements Number of thread and performance of large problems. Performance in multiple processors environment. Performance in various operating systems Window/Linux and so on. Measurements on: Intel Core 2 Duo, 3.0Ghz, 2G RAM, Vista, Ubuntu Intel Centrino Duo, 1.44Ghz, 2G RAM, Vista Run 3 times and find the average of the total execution time. 24
  • 25. Benchmark – 1 Vista JAVA Thread(s) run for each workload Time in seconds 25
  • 26. Benchmark – 2 Vista Time in seconds 26
  • 27. Benchmark – 1 Ubuntu JAVA Thread(s) run for each workload Time in seconds 27
  • 28. Benchmark – 2 Ubuntu Time in seconds 28
  • 29. Results Analysis Benchmark 1 (divide large problem into sub problems) If we assign right number of thread to compute the problems, better execution time. The more thread assign to the problem, the worse performance we get. Benchmark 2 (a pack of workloads) The more thread we assign to compute those problems, the worse execution time we will have. 29
  • 30. Results Analysis For a better results we will need CPU Intensive application  Need very large problem to compute in order to see an improvement. I/O Intensive application See significantly improvement of execution time.  Example.  30
  • 31. Conclusion JAVA Threads Advantages Better interaction with user. Exploitation of multiple processors. Do other things while waiting for Slow I/O operations. Simplify object modeling Synchronized, lock objects and classes Inter-thread communication support  wait(), notify() 31
  • 32. Conclusion(cont.) JAVA Threads Disadvantages Memory resources  Two stacks assigned by JavaVM  One is used to keep track of java method calls and vars.  The other stack is used to keep track of native code calls  Processor resources  Overhead, context switch  Thread operations (start, stop, destroy).  When adding additional threads to the design of a system, these costs should be considered.  32
  • 33. Conclusion(cont.) JAVA Multi-thread programming  Less effective in single processor?  Need to assign right number of thread, more thread doesn’t mean good.  No synchronization need. No critical section in the program.  Effective when the problem require intensive I/O operation.  Programmer has to know the problem well in order to use thread-based programming to archive the maximum. utilization of system resources.  Easy to start, tough to master.   Auto-garbage collection Tasks such as getting lock, releasing lock are simplified. 33
  • 34. References [1] JAVA Standard Edition 6 API, Sun Microsystems, http://java.sun.com/javase/6/docs/api/, 2006 [2] Eclipse IDE, www.eclipse.org, 2008 [3] Paul, H., Java Thread Programming, 1999 [4] Scott O., Henry W., Java Threads 2nd edition, 2001 [4] Operating System Concepts, by Silberschatz. Galvin, and Gangne, 7th Edition , Wiley 2005. Fibonacci, http://britton.disted.camosun.bc.ca/fibslide/jbfibslide .htmhttp://en.wikipedia.org/wiki/Fibonacci_number 34