0% found this document useful (0 votes)
6 views5 pages

Threads and Processes

The document explains the concepts of processes and threads in operating systems, highlighting that a process is a program in execution while a thread is the unit of execution within a process. It discusses CPU characteristics, multitasking, and concurrency, emphasizing how multiple threads can run simultaneously and switch between tasks. Additionally, it outlines the life cycle of a thread, including its various states from creation to termination, and methods for creating threads in programming.

Uploaded by

kaaladainne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Threads and Processes

The document explains the concepts of processes and threads in operating systems, highlighting that a process is a program in execution while a thread is the unit of execution within a process. It discusses CPU characteristics, multitasking, and concurrency, emphasizing how multiple threads can run simultaneously and switch between tasks. Additionally, it outlines the life cycle of a thread, including its various states from creation to termination, and methods for creating threads in programming.

Uploaded by

kaaladainne
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EE6253 Operating Systems and Network

Programming

PROCESSES AND THREADS


Processes and Threads
Process Thread
- A program in execution - A thread is the unit of execution
within a process
- A process can have just one
Process thread to many threads
Thread - i.e. within a process, there may
Thread be one or more units of
execution- which are threads
Thread

Thread
Processes and Threads
• CPU- central processing unit – The amount of cores in CPU decides the amount of operations that can happen at the same
time.
• Clock speed of the processor – decide the amount of operations per second
• Every thread is assigned to one of the core in CPU.
• Every core has bunch of different threads and they will execute and switch between them to perform operations.
• Multitasking – is a method that enables multiple processes to share processors and other system resources. With
multitasking, a CPU can switch between executing tasks without the need to wait for any single one to finish..
• Threading - not necessarily doing things in parallel at the same time - changing the order of the operations.
• Then why multiple threads require?
• concurrent programming/ Concurrency - If a thread (t1) is waiting for an operation to occur, the processor core can
switch and execute another thread (t2) while t1 is in a waiting state.
• Multiple threads can run simultaneously, with the CPU core switching between them during the execution stage.
Life Cycle of a Thread (Thread
States)
• New – when a thread is created
• Runnable – When the thread is ready to execute
Active State
• Running – When the thread gets the CPU
• Blocked/Waiting – When the thread is inactive/during any interruption
• Terminated/Stop – When the thread finished its job/ unusual events
(unhandled exception, segmentation fault, etc.)
Creating Threads
There are 2 ways to create Thread object;
• Have a class extending the thread class
• Implementing the Runnable interface

• In both cases run() method need to implement

You might also like