Professional Documents
Culture Documents
Process Architecture
• Stack: The Stack stores temporary data like function parameters,
returns addresses, and local variables.
• Heap Allocates memory, which may be processed during its run
time.
• Data: It contains the variable.
• Text:
Text Section includes the current activity,
Process States
Process States
Diagram
A process state is a condition of the process at a specific instant of time.
It also defines the current position of the process.
After completing every step, all the resources are used by a process,
and memory becomes free.
Process Control Block (PCB)
Every process is represented in the operating system by a process
control block, which is also called a task control block.
The process can be split down into so many threads. For example, in a browser, many tabs
can be viewed as threads. MS Word uses many threads - formatting text from one thread,
processing input from another thread, etc.
Need of Thread:
o It takes far less time to create a new thread in an existing process than to create
a new process.
o Threads can share the common data, they do not need to use Inter- Process
communication.
o It takes less time to terminate a thread than a process.
o Enhanced throughput of the system: When the process is split into many
threads, and each thread is treated as a job, the number of jobs done in the unit
time increases. That is why the throughput of the system also increases.
o Responsiveness: When the process is split into several threads, and when a
thread completes its execution, that process can be responded to as soon as
possible.
o Resource sharing: Resources can be shared between all threads within a
process, such as code, data, and files. Note: The stack and register cannot be
shared between threads. There is a stack and register for each thread.
S.N. Process Thread
4 If one process is blocked, then no other process can While one thread
execute until the first process is unblocked. is blocked and
waiting, a second
thread in the same
task can run.
Advantages of Thread
Types of Thread
Threads are implemented in following two ways −
• User Level Threads − User managed threads.
• Kernel Level Threads − Operating System managed threads acting on
kernel, an operating system core.
Advantages
• Kernel can simultaneously schedule multiple threads from the same process
on multiple processes.
• If one thread in a process is blocked, the Kernel can schedule another thread
of the same process.
• Kernel routines themselves can be multithreaded.
Disadvantages
• Kernel threads are generally slower to create and manage than the user
threads.
• Transfer of control from one thread to another within the same process
requires a mode switch to the Kernel.
3 User-level thread is generic and Kernel-level thread is specific to the operating system.
can run on any operating
system.
Multithreading Model:
Multithreading allows the application to divide its task into individual threads. In multi-
threads, the same process or task can be done by the number of threads, or we can
say that there is more than one thread to perform the task in multithreading. With the
use of multithreading, multitasking can be achieved.
The main drawback of single threading systems is that only one task can be performed
at a time, so to overcome the drawback of this single threading, there is multithreading
that allows multiple tasks to be performed.
Example -
In the above example, client1, client2, and client3 are accessing the web server without
any waiting. In multithreading, several tasks can run at the same time.