Download presentation
Presentation is loading. Please wait.
Published byJustina O’Brien’ Modified over 8 years ago
1
T HREADS Lecture 5 1 L. Mohammad R.Alkafagee
2
H EAVYWEIGHT - PROCESSES The cooperation of traditional processes also known as heavyweight processes which have the following characteristics: They require space in main memory where they reside during their execution. They pass through several states from their initial entry into the computer system to their completion :ready, running, waiting, new, etc. These processes are often swapped between main memory and secondary memory during their execution to accommodate multiprogramming and to take advantage of virtual memory. 2 L. Mohammad R.Alkafagee
3
HEAVYWEIGHT PROCESSES ( CONT.) Every time a swap occurs overhead increase because of all the information must be saved. To minimize this overhead time the operating system support the implementation of threads or lightweight processes. Threads are supports at both kernel and user level and can be managed by either operating system or the application that created them. 3 L. Mohammad R.Alkafagee
4
HEAVYWEIGHT PROCESSES ( CONT.) 4 The aim of having multiple threads of execution is : To maximize degree of concurrent execution between operations To enable the overlap of computation with input and output To enable concurrent processing on multiprocessors. L. Mohammad R.Alkafagee
5
5
6
6
7
:T HREAD STATS New :create new thread. Runnable : Ready :Ready to execute Running :Thread in execution. Waiting : Thread Wait until a specific event has occurred. Timed Waiting : Thread putting for specified amount of time. Terminated : Terminate execution and release resources. Blocked : Waiting for I/O to complete. 7 L. Mohammad R.Alkafagee
8
T HREADS S TATES 8 New Runnable Waiting Timed Waiting Terminated Blocked Program starts the thread Notify all wait Wait sleep Interval expire Task completed I/O request Enter synchronized statement Acquire lock I/O completes L. Mohammad R.Alkafagee
9
I NTERNAL VIEW FOR R UNNABLE STATE 9 Ready Running Operating System Dispatches a thread Quantum expires Operating system’s internal view of java’s Runnable state L. Mohammad R.Alkafagee
10
T HREAD C ONTROL B LOCK (TCB) It contains basic information about a thread such as: * Thread ID. * Thread state. * CPU information. * Thread priority. * A pointer to the process that created the thread. 10 L. Mohammad R.Alkafagee
11
T YPES OF T HREADS : 1.User Threads : 11 L. Mohammad R. Alkafagee
12
2.KERNAL THREAD 12 L. Mohammad R.Alkafagee
13
M ULTITHREADING M ODELS : 1.Many-to-One Model: maps many user-level threads to one kernel thread. 2.One-to-One Model : maps each user thread to a kernel thread. 3.Many-to-Many Model: multiplexes many user- level threads to a smaller or equal number of kernel threads. 13 L. Mohammad R.Alkafagee
14
:(Many-to-One)Multithreading Models 14 K K User Thread Kernel Thread L. Mohammad R.Alkafagee Examples: Solaris Green Threads GNU Portable Threads
15
(Multithreading Models (One-to-One 15 K K User Thread Kernel Thread K K K K L. Mohammad R.Alkafagee Examples Windows NT/XP/2000 Linux Solaris 9 and later
16
(Multithreading Models (Many-to-Many 16 K K K K K K User Thread Kernel Thread Examples: Solaris prior to version 9 Windows NT/2000 with the ThreadFiberpackage
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.