process control block & threads and their management
DESCRIPTION
A presentation by me on the Process Control Block & Threads and Their Management for my CS 5th Sem presentation.TRANSCRIPT
![Page 1: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/1.jpg)
Process Control BlockThreads & Their ManagementBy Ujjwal Kumar1149210055CS – V – 2013
![Page 2: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/2.jpg)
Presentation by Ujjwal Kumar
2
Process Control Block
or PCB
![Page 3: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/3.jpg)
Presentation by Ujjwal Kumar
3
Introduction•Each & every process in the Operating
System is represented by a Process Control Block.
•Process Control Block ~ Task Control Block or Task Struct.
![Page 4: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/4.jpg)
Presentation by Ujjwal Kumar
4
What exactly is PCB?
•It is a Data Structure in the operating system kernel containing the information needed to manage a particular process.
•The PCB is "the manifestation(Visible) of a process in an operating system”
![Page 5: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/5.jpg)
Presentation by Ujjwal Kumar
5
Source: http://lmgtfy.com/?q=define%3Amanifestation/
![Page 6: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/6.jpg)
Presentation by Ujjwal Kumar
6
Fig: Process Control Block (PCB)
![Page 7: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/7.jpg)
Presentation by Ujjwal Kumar
7
What exactly does this diagram mean?
![Page 8: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/8.jpg)
Presentation by Ujjwal Kumar
8
•Pointers: It contains the address of another process which is present in the ready queue.
• Process State: It contains information about the state of the process i.e.,
• New
• Ready
• Running
• Waiting
• Halted
![Page 9: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/9.jpg)
Presentation by Ujjwal Kumar
9
•Program Counter: The address of the next instruction to be executed.
• CPU Registers: The registers vary in no.
and type depending on the type of
computer architecture, they include:
• Accumulators, index registers, stack pointers
and general purpose registers
![Page 10: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/10.jpg)
Presentation by Ujjwal Kumar
10
•CPU scheduling information: This
information includes
▫Process priority
▫Pointer to scheduling queues
▫Other scheduling parameters.
•Memory management information: This
information includes
▫Value of base and limit registers
▫Page tables
▫Segment tables.
![Page 11: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/11.jpg)
Presentation by Ujjwal Kumar
11
• Accounting information: This information
includes
• Amount of CPU and real time used
• Time limits
• Account numbers
• Job or Process numbers etc.
• I/O status information: This information
includes
• List of I/O devices allocated to the process
• List of open files etc .
![Page 12: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/12.jpg)
Presentation by Ujjwal Kumar
12
Now we know what exactly the Process Control Block is. But do we know where
the location of PCB is?
![Page 13: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/13.jpg)
Presentation by Ujjwal Kumar
13
•Contains critical information of processes and hence it must be placed where it is protected from normal user access.
•In many Operating systems, it is placed in the beginning of the kernel stack of the process since that is a convenient protected location.
![Page 14: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/14.jpg)
Presentation by Ujjwal Kumar
14
Interleaving Execution of
Processes
![Page 15: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/15.jpg)
Presentation by Ujjwal Kumar
15
Interleaving Execution of Processes•Perception of normal end user:
Process A Process
B
Process C
Process D
Time
![Page 16: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/16.jpg)
Presentation by Ujjwal Kumar
16
Interleaving Execution of Processes•In reality, this is how the processes are
executed: Process 1Process 2Process 1
Process 2
![Page 17: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/17.jpg)
Presentation by Ujjwal Kumar
17
Threads & their Management
![Page 18: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/18.jpg)
Presentation by Ujjwal Kumar
18
Threads
•Definition: In simple words we can say that Threads are light weight processes.
•It is a sequence and not a program because it cannot run on its own so it returns within the program.
•A process is divided into smaller tasks and these tasks are known as threads.
•A basic unit of CPU Utilization.
![Page 19: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/19.jpg)
Presentation by Ujjwal Kumar
19
Advantages of Threads
•If a process has multiple threads then it will be able to perform more than one single task at the same time.
•Better Throughput.•Makes the program Responsive.
![Page 20: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/20.jpg)
Presentation by Ujjwal Kumar
20
Types of Threading
•Single Threading•Multi Threading
![Page 21: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/21.jpg)
Presentation by Ujjwal Kumar
21
Multithreading
•Sometimes several similar tasks have to be performed by the application in order to get the word done.
•This is where the Multithreading comes in.
![Page 22: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/22.jpg)
Presentation by Ujjwal Kumar
22
Real life examples of Multithreading - I•Web browsers: They have different
threads to do different work.▫One thread will retrieve data from the
remote servers.▫Another one will render the data received
into visual web pages.•Example: Google Chrome, Opera, Firefox
etc.
![Page 23: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/23.jpg)
Presentation by Ujjwal Kumar
23
Real life examples of Multithreading - II•Word Processors: Different threads in
word processor will do different jobs.▫One will render the text based materials.▫Another one will render graphic based
materials like the images etc.•Example: Microsoft Office
![Page 24: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/24.jpg)
Presentation by Ujjwal Kumar
24
Benefits of Multithreading
•Responsiveness: The process responds much better while using multithreading as compared to single threaded processes.
•Speed Up: The process is speeded up by using multithreading hence giving a much better experience to the end user.
•Efficient Communication: The threads of a specific process can communicate with each other efficiently because of the shared address space.
![Page 25: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/25.jpg)
Presentation by Ujjwal Kumar
25
•Utilization in multiprocessor systems: ▫Multithreading can take advantages of a
multiprocessor system.▫Multiple threads can be processed on
multiple cores of the system.
![Page 26: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/26.jpg)
Presentation by Ujjwal Kumar
26
Implementation of Threads
•Threads are implemented in a system in three different ways. ▫Kernel Level Threads▫User Level Threads▫Hybrid Level Threads
![Page 27: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/27.jpg)
Presentation by Ujjwal Kumar
27
Kernel Level Threads
•Implemented by the kernel itself.•Management of threads is also done by
the kernel itself.
Process
Threads
Process Table
![Page 28: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/28.jpg)
Presentation by Ujjwal Kumar
28
User Level Thread
Kernel Space
Thread Table
ThreadProcess
User Space
![Page 29: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/29.jpg)
Presentation by Ujjwal Kumar
29
User Level Thread
•These type of threads are loaded in the user space and the kernel doesn’t have anything to do with this.
•Threads are managed in user space so each process must have its own private thread table.
•This table consists the information of:▫Program Counter▫Stack Pointer▫Register.
![Page 30: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/30.jpg)
Presentation by Ujjwal Kumar
30
Acknowledgements
•Sir. Mukesh Kumar Singh•Google.com•Book: OS by Vijay Shukla
![Page 31: Process Control Block & Threads and Their Management](https://reader033.vdocument.in/reader033/viewer/2022061201/54793ee55906b59e048b4654/html5/thumbnails/31.jpg)
Presentation by Ujjwal Kumar
31
Questions
You can ask any questions you might have in your mind
related to my presentation.