0% found this document useful (0 votes)
21 views20 pages

Lecture 1.3.5 Threads in OS

threads in os

Uploaded by

360siddharth
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)
21 views20 pages

Lecture 1.3.5 Threads in OS

threads in os

Uploaded by

360siddharth
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/ 20

UNIVERSITY INSTITUTE OF

COMPUTING
UNIT-1
Bachelor of Computer Applications
Operating System
(23CAT-153/22SCT-252)

INTRODUCTION TO OPERATING SYSTEM DISCOVER . LEARN . EMPOWER


COURSE OUTCOMES:

CO1 Classify the operating system categories

CO2 Identify OS as a resource manager that supports multiprogramming

CO3 Outline the concept of process and its scheduling algorithms used by the operating
system. CO2 Analyze the distributed and Network Operating Systems
and tabulate summary.
CO4 Explain how
. an operating system virtualises CPU and memory

CO5 Summarize the structure of file system


SYLLABUS (UNIT – I)

• Unit-1(Basics of Operating System)


• Generations of operating systems
• Definition, OS Architecture, Types of Operating Systems: Mainframe, Desktop, Multiprocessor, Distributed,
Clustered, Multiprogramming, Real time, Embedded and Time sharing.
• Multiprogramming
• Multitasking, Multiprogramming, Timesharing, Buffering, Spooling
• Components
• Process Management Component, Memory Management component, I/O Management component , File
Management component, Protection System, Networking management component, Command interpreter.
• Processes
• Processes: Definition, Process States, Process structure- PCB and components, Operations on Processes,
Threads.
SYLLABUS (UNIT – II)

• Cpu Scheduling
• Definition, Scheduling objectives, Types of Schedulers, Scheduling criteria, CPU utilization,
Throughput, Turnaround Time, Waiting Time, Response Time, Preemptive and Non – Preemptive,
FCFS, SJF, RR, Multiprocessor scheduling, Types, Performance evaluation of the scheduling.
• Shared Memory System
• Definition, Shared Memory System, Message passing, Critical section problem, Mutual Exclusion,
Semaphores.
• Deadlock
• Conditions, modeling, deadlock prevention, deadlock avoidance, detection and recovery, Banker’s
algorithms
SYLLABUS (UNIT – III)

• Multiprogramming
• Multiprogramming with fixed partition, variable partitions, virtual memory, paging, demand
paging, design and implementation issues in paging such as page tables, inverted page tables, page
replacement algorithms, page fault handling, working set model, local vs. global allocation, page
size, segmentation with paging.
• File system Structure
• Concept, Access Methods, File system Structure, Directory Structure, Allocation Methods, Free
Space Management, File Sharing, Protection and Recovery.
Topics to be Covered
1. Introduction of Thread in OS
2. Types of Threads
3. Components of Threads
4. Benefits of Threads
Introduction of Thread

• Thread is a sequential flow of tasks within a process. Threads in an


operating system can be of the same or different types. Threads are
used to increase the performance of the applications.
• Each thread has its own program counter, stack, and set of registers.
However, the threads of a single process might share the same code
and data/file. Threads are also termed lightweight processes as they
share common resources.
• Eg: While playing a movie on a device the audio and video are
controlled by different threads in the background.
Introduction of Thread

8
Need of Threads

• Threads in the operating system provide multiple benefits and improve


the overall performance of the system. Some of the reasons threads are
needed in the operating system are:
• Since threads use the same data and code, the operational cost between
threads is low.
• Creating and terminating a thread is faster compared to creating or
terminating a process.
• Context switching is faster in threads compared to processes.

9
Why Multithreading?

• In Multithreading, the idea is to divide a single process into multiple threads


instead of creating a whole new process. Multithreading is done to achieve
parallelism and to improve the performance of the applications as it is faster in
many ways which were discussed above. The other advantages of multithreading
are mentioned below.
• Resource Sharing: Threads of a single process share the same resources such
as code, data/file.
• Responsiveness: Program responsiveness enables a program to run even if part of
the program is blocked or executing a lengthy operation. Thus, increasing the
responsiveness to the user.
• Economy: It is more economical to use threads as they share the resources of a
single process. On the other hand, creating processes is expensive.

10
Types of Thread

• In the operating System, there are two types of threads.


• Kernel level thread.
• User-level thread.

11
Types of Threads

• User-Level Threads: The operating System does not recognize the


user-level thread. User threads can be easily implemented and it is
implemented by the user. If a user performs a user-level thread
blocking operation, the whole process is blocked.
• The kernel level thread does not know nothing about the user level
thread. The kernel-level thread manages user-level threads as if they
are single-threaded processes ? examples:Java thread, POSIX threads,
etc.

12
Types of Threads

• Advantages of User Level Thread:


• The user threads can be easily implemented than the kernel thread.
• User-level threads can be applied to such types of operating systems
that do not support threads at the kernel-level.
• It is faster and efficient.
• Context switch time is shorter than the kernel-level threads.
• It does not require modifications of the operating system.

13
Types of Threads

• Disadvantages of User Level Thread:


• User-level threads lack coordination between the thread and the
kernel.
• If a thread causes a page fault, the entire process is blocked.

14
Types of Threads

• Kernel Level Thread:


• The kernel thread recognizes the operating system. There is a thread
control block and process control block in the system for each thread
and process in the kernel-level thread. The kernel-level thread is
implemented by the operating system.
• The kernel knows about all the threads and manages them. The
kernel-level thread offers a system call to create and manage the
threads from user-space. The implementation of kernel threads is more
difficult than the user thread.
• Context switch time is longer in the kernel thread. If a kernel thread
performs a blocking operation, the Banky thread execution can
continue. Example: Window Solaris.
15
Types of Threads

• Advantages of Kernel-level threads


• The kernel-level thread is fully aware of all threads.
• The scheduler may decide to spend more CPU time in the process of
threads being large numerical.
• The kernel-level thread is good for those applications that block the
frequency.
• Disadvantages of Kernel-level threads
• The kernel thread manages and schedules all threads.
• The implementation of kernel threads is difficult than the user thread.
• The kernel-level thread is slower than user-level threads.
16
Components of Threads

• Any thread has the following components.


• Program counter
• Register set
• Stack space

17
Benefits of Threads
• 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.
• Effective Utilization of Multiprocessor system: When you have more than one thread in one
process, you can schedule more than one thread in more than one processor.
• Faster context switch: The context switching period between threads is less than the process
context switching. The process context switch means more overhead for the CPU.
• 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.
• Communication: Multiple-thread communication is simple because the threads share the same
address space, while in process, we adopt just a few exclusive communication strategies for
communication between two processes.
• Resource sharing: Resources can be shared between all threads within a process, such as code,
data, and files.

18
REFERENCE BOOKS

• Peterson, J.L. & Silberschatz, A. Operating System Concepts, Addison


Wesley, New Delhi.
• Tanenbaum, A.S., Operating System, PHI, New Delhi.
THANK YOU

You might also like