You are on page 1of 3

Department Of Software Engineering

QUIZ - 02

Course name : Operating System


Submitted by : Zara Khush Bakhat
Submitted to : Miss Marayam Daud
Semester : 4 Th
Submitted on : 30 - March – 2024

Page | 1
1. Compare Single threaded vs Multi-threaded.

Single-threaded Multi-threaded
In a single-threaded application, there is only one In a multi-threaded application, multiple threads
sequence of instructions being executed at a time. are used to execute tasks concurrently. Each
This means that tasks are processed one after the thread represents a separate flow of execution,
other in a linear fashion. allowing multiple operations to be performed
simultaneously.
Performance
Multi-threaded applications can potentially offer Single-threaded applications are limited to the
better performance by leveraging multiple CPU processing power of a single core.
cores and executing tasks concurrently.
Complexity
Multi-threaded programming can be more Single-threaded applications are typically simpler
complex and error-prone due to issues like race to design and debug.
conditions, deadlocks, and thread synchronization.
Resource Utilization
Multi-threaded applications can make more Single-threaded applications may underutilize
efficient use of available resources, especially in resources if they're not designed to take advantage
scenarios where tasks can be executed of parallelism.
independently and concurrently.
Scalability
Multi-threaded applications can scale better on Single-threaded applications may struggle to scale
multi-core systems or in environments with high in such scenarios due to their sequential execution
concurrency requirements. model.
Example
A web server handling multiple client requests A simple calculator program that performs
concurrently, with each request being processed calculations one after the other without any
by a separate thread. parallel processing.

2. Compare User level thread vs kernel level thread.

User-level threads Kernel-level threads


User-level threads are managed entirely Kernel-level threads are managed directly
by the user-space library or runtime by the operating system kernel.
environment, without kernel intervention. Each kernel-level thread is represented as
Context switching between user-level a separate entity in the kernel's
threads is faster since it doesn't involve scheduling structures.
kernel mode transitions. Kernel-level threads can run concurrently
The operating system is unaware of user- on multiple processors or CPU cores,
level threads, treating them as single- allowing true parallel execution.
threaded processes.

Page | 2
Performance
User-level threads generally have lower Kernel-level threads may have higher
overhead for thread creation, context overhead due to involvement of the kernel in
switching, and synchronization since they are thread management.
managed entirely in user space.
Concurrency
User-level threads may be limited to pseudo- Kernel-level threads can achieve true
parallelism on a single core. parallelism by running concurrently on
multiple CPU cores.
Portability
User-level threads are more portable across Kernel-level threads may be more efficient on
different operating systems since they rely on some operating systems but may lack
user-space libraries. portability.
Example
Java threads managed by the Java Virtual POSIX Threads (pthreads) with kernel-level
Machine (JVM) implementation

Page | 3

You might also like