Operating Systems Lesson 5
Operating Systems Lesson 5
• The Forum
Lively and respectful discussions are encouraged
Daily readings
Weekly discussion questions
• Quizzes and Worksheets
On eLearning platform
• Tests (Please note that your account must be up-to-date for you to take part in the
test)
Multiple choice questions
Shorts answer questions
Long answer questions
• All assessments will be graded and contribute to your continuous assessment marks
Enquiries and questions
Lecturer– Mr P. Musindo
Head of Department – Mr C. Kasumba
Operating Systems 2
Lesson Overview
This lesson will focus on the concept of threads in a computer system. It will
look at the relationship between a thread and a process, together with
advantages and disadvantages of each. The lesson will also focus on the
types of threads available in a computing environment. Another concept
covered in this lesson is on parallel processing.
Operating Systems 3
Lesson Objective(s)
Operating Systems 4
Introduction
Operating Systems 5
Single thread vs multitheread
Operating Systems 6
Threads compared with processes
Similarities
Like processes threads share CPU and only one thread active (running) at a
time.
Like processes, threads within a process execute sequentially.
Like processes, thread can create children.
And like process, if one thread is blocked, another thread can run.
Differences
Unlike processes, threads are not independent of one another.
Unlike processes, all threads can access every address in the task .
Unlike processes, thread are design to assist one other. Note that
processes might or might not assist one another because processes may
originate from different users.
Operating Systems 7
Examples of threads
Operating Systems 8
Benefits of threads
Operating Systems 9
Multicore Programming
Operating Systems 10
Types of Threads
Operating Systems 11
User - Level Threads
Are above the kernel and without kernel support. These are the threads that
application programmers use in their programs.
User-level threads are small and much faster than kernel level threads. They are
represented by a program counter(PC), stack, registers and a small process control
block.
Advantages of User-Level Threads
User-level threads are easier and faster to create than kernel-level threads. They can
also be more easily managed.
User-level threads can be run on any operating system.
There are no kernel mode privileges required for thread switching in user-level
threads.
Disadvantages of User-Level Threads
Multithreaded applications in user-level threads cannot use multiprocessing to their
advantage.
The entire process is blocked if one user-level thread performs blocking operation.
Operating Systems 12
Kernel-Level Threads
Are supported within the kernel of the OS itself. All modern OSs support kernel-level
threads, allowing the kernel to perform multiple simultaneous tasks and/or to service
multiple kernel system calls simultaneously.
Because of this, kernel-level threads are slower than user-level threads.
Advantages of Kernel-Level Threads
Multiple threads of the same process can be scheduled on different processors in
kernel-level threads.
The kernel routines can also be multithreaded.
If a kernel-level thread is blocked, another thread of the same process can be
scheduled by the kernel.
Disadvantages of Kernel-Level Threads
A mode switch to kernel mode is required to transfer control from one thread to
another in a process.
Kernel-level threads are slower to create as well as manage as compared to user-
level threads.
Operating Systems 13
Parallel Processing
Parallel Processing Systems are designed to speed up the execution of programs
by dividing the program into multiple fragments and processing these fragments
simultaneously. Such systems are multiprocessor systems also known as tightly
coupled systems. Parallel systems deal with the simultaneous use of
multiple computer resources that can include a single computer with multiple
processors, a number of computers connected by a network to form a parallel
processing cluster or a combination of both.
A parallel processing system can carry out simultaneous data-processing to achieve
faster execution time.
Operating Systems 14
Parallel Processing cont…
All the processors in the parallel processing environment should run on the same
operating system.
All processors here are tightly coupled and are packed in one casing.
All the processors in the system share the common secondary storage like the hard
disk.
Operating Systems 15
Summary
Operating Systems 16
Review / discussion questions
Operating Systems 17
Resources
https://www.youtube.com/watch?v=exbKr6fnoUw
https://www.youtube.com/watch?v=q7sgzDH1cR8
Stallings, W (2018).Operating Systems: Internals and Design Principles (9th
Edition)
Study Guide
Operating Systems 18
The End
Thank you
Operating Systems 19