Professional Documents
Culture Documents
The term process (Job) refers to program code that has been loaded
into a computer’s memory so that it can be executed by the central
processing unit (CPU). A process can be described as an instance of
a program running on a computer or as an entity that can be
:
assigned to and executed on a processor. A program becomes a
process when loaded into memory and thus is an active entity.
Program Process
Program contains a set of instructions
Process is an instance of an executing program.
designed to complete a specific task.
Program is a passive entity as it resides Process is a active entity as it is created during
in the secondary memory. execution and loaded into the main memory.
Program exists at a single place and Process exists for a limited span of time as it gets
continues to exist until it is deleted. terminated after the completion of task.
Program is a static entity. Process is a dynamic entity.
Program does not have any resource Process has a high resource requirement, it needs
requirement, it only requires memory resources like CPU, memory address, I/O during its
space for storing the instructions. lifetime.
Program does not have any control Process has its own control block called Process
block. Control Block.
In addition to program data, a process also requires
Program has two logical components:
additional information required for the management
code and data.
and execution.
Many processes may execute a single program.
Program does not change itself. There program code may be the same but program
data may be different. these are never same.
Program contains instructions Process is a sequence of instruction execution.
Here are some of the key pieces of information that are typically
stored in a PCB:
Working:
S.
Parameters User Level Thread Kernel Level Thread
No.
Implemented User threads are implemented by Kernel threads are implemented
1.
by users. by Operating System (OS).
The operating System doesn’t Kernel threads are recognized by
2. Recognize
recognize user-level threads. Operating System.
Implementation of User threads is Implementation of Kernel-Level
3. Implementation
easy. thread is complicated.
Context switch
4. Context switch time is less. Context switch time is more.
time
Hardware Context switch requires no
5. Hardware support is needed.
support hardware support.
If one user-level thread performs If one kernel thread performs a
Blocking
6. a blocking operation then the blocking operation then another
operation
entire process will be blocked. thread can continue execution.
:
Multithread applications cannot
7. Multithreading take advantage of Kernels can be multithreaded.
multiprocessing.
User-level threads can be Kernel-level level threads take
Creation and
8. created and managed more more time to create and
Management
quickly. manage.
Operating Any operating system can Kernel-level threads are
9.
System support user-level threads. operating system-specific.
The application code does not
The thread library contains the
contain thread management
code for thread creation,
Thread code. It is merely an API to the
10. message passing, thread
Management kernel mode. The Windows
scheduling, data transfer, and
operating system makes use of
thread destroying
this feature.
Example: Java thread, POSIX
11. Example Example: Window Solaris.
threads.
User Level Threads are simple Scheduling multiple threads that
and quick to create. Can run on belong to the same process on
any operating system They different processors is possible
perform better than kernel in kernel-level threads.
12. Advantages threads since they don’t need to Multithreading can be there for
make system calls to create kernel routines. When a thread at
threads. In user-level threads, the kernel level is halted, the
switching between threads does kernel can schedule another
not need kernel mode privileges. thread for the same process.
Transferring control within a
Multithreaded applications on
process from one thread to
user-level threads cannot benefit
another necessitates a mode
from multiprocessing. If a single
13. Disadvantages switch to kernel mode. Kernel-
user-level thread performs a
level threads take more time to
blocking operation, the entire
create and manage than user-
process is halted.
level threads.
In kernel-level threads have their
In user-level threads, each thread own stacks and their own
Memory
14. has its own stack, but they share separate address spaces, so they
management
the same address space. are better isolated from each
other.
User-level threads are less fault-
Kernel-level threads can be
tolerant than kernel-level threads.
managed independently, so if
15. Fault tolerance If a user-level thread crashes, it
one thread crashes, it doesn’t
can bring down the entire
necessarily affect the others.
process.
User-level threads don’t take full
It can access to the system-level
advantage of the system
Resource features like I/O operations. So it
16. resources, As they don’t have
utilization can take full Advantages of
direct access to the system-level
System Resources.
features like I/O operations
User-level threads are more Kernel-level threads are less
17. Portability portable than kernel-level
:
threads. portable than User-level threads.
System calls are functions provided by the kernel that allow user-
level programs to interact with the operating system. They provide a
standardized interface for accessing system resources such as files,
memory, and I/O devices. System calls are invoked by user-level
programs using a special instruction called a trap or interrupt, which
switches the CPU from user mode to kernel mode. The kernel then
executes the requested system call and returns control back to the
user-level program.
Find average waiting time for Shortest job first scheduling, and
Round robin scheduling algorithm.
factorial() {
if [ $1 -eq 0 ] || [ $1 -eq 1 ]; then
echo 1
else
local n=$1
local result=1
while [ $n -gt 1 ]; do
result=$((result * n))
n=$((n - 1))
done
echo $result
fi
}
# Main script
read -p "Enter a number to find factorial: " num
find_greatest() {
if [ $1 -gt $2 ] && [ $1 -gt $3 ]; then
echo $1
elif [ $2 -gt $1 ] && [ $2 -gt $3 ]; then
echo $2
else
echo $3
fi
}
# Main script
read -p "Enter the first number: " num1
read -p "Enter the second number: " num2
read -p "Enter the third number: " num3