Module 2.2 Thread & Thread Scheduling
Module 2.2 Thread & Thread Scheduling
2 Thread
Swati Mali
Nirmala Shinde Baloorkar
Assistant Professor
Department of Computer Engineering
Outline
• Thread
• Process Vs Thread
• Example
Thread
• Supports Parallelism with multiple threads of execution at a time
• A thread executes sequentially and is interrupt-able so that the processor
can turn to another thread
• Does not need entire process context to execute so considered as
lightweight.
• Includes the program counter and stack pointer) and its own data area for a
stack
• Supports multiple parallel executions
e.g. Notifications in background while you are using the app
• The idea is to achieve parallelism by dividing a process into multiple
threads.
Process and Thread
• It takes far less time to create a new thread in an existing process than
to create a brand-new process.
• It takes less time to terminate a thread than a process.
Types of threads
• Thread libraries provide programmers with API for the creation and
management of threads.
• Three types of Thread
• POSIX Pitheads may be provided as either a user or kernel library, as an
extension to the POSIX standard.
• Win32 threads are provided as a kernel-level library on Windows systems.
• Java threads: Since Java generally runs on a Java Virtual Machine, the
implementation of threads is based upon whatever OS and hardware the JVM
is running on, i.e. either Pitheads or Win32 threads depending on the system.
Thread
• Create
• Join
• Terminate
Create, Start and Join
• 2nd execution
Join() Method
• The join() method is used in that situation, it doesn’t let execute the
code further until the current thread terminates.
Assignment
• ULT vs KLT
• Pthread
• POSIX
Question ?