Download presentation
Presentation is loading. Please wait.
Published byRobert Dale Johnson Modified over 8 years ago
1
Multithreaded Programming ( 4.1-4.3)
2
Components of a Process Figure 3.1
3
Multi-programming Systems Kernel
4
Single vs Multithreaded Processes Figure 4.1
5
Multi-programming Systems (with threads) Kernel
6
Demo – Spiral Turtles
7
Demo – Turtles’ speed limit Write the program that does the following: Turtle 1 moves forward every 3 seconds Turtle 2 moves forward every 5 seconds Compare using variables to count time vs using threads
8
Thread Example I: Modular Design Main Thread Screen Updater UI Monitor & Update Communications Handler Process
9
Thread Example II: Web Server Main Server Thread User Thread 1 Server Process User Thread 2 User Thread 3
10
Benefits of Multithreaded Programming Responsiveness Threads don’t block each other Resource Sharing Can access same resources Economy Cheaper to create a new thread Utilization of Multi-processors Program runs faster
11
Multithreading Modes User Threads: Thread management done in the user program (not the OS). Ex. Python Kernel Threads: The OS handles thread management. Ex. Java
12
Many-to-One Model Green Threads Portable Threads (pthreads) Figure 4.2
13
One-to-One Model Windows NT/XP/2000 Linux Solaris 9 and later Figure 4.3
14
Many-to-Many Model Figure 4.4
15
Two-level Model Solaris < version 9 IRIX HP-UX Tru64 UNIX Figure 4.5
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.