OS Unit 2a-6a

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Unit II.

Operating System Services-Operating System Design


1.User Interface
2. Program Execution
3.File System Manipulation
4.Input/Output Operations
5.Communication
6.Error Detection
7.Ensuring Efficient Operation

Lesson Objectives:

 Understand the purpose of the operating system Services


 To be able to create a good User Interface
 Recognize the manipulation of File System
 Distinguish Error Detection
 To apply efficiently the operations

Readings:
USER INTERFACE OPERATING SYSTEM
- Command line interface (CLI)- usually deals with using text commands and a
technique for entering those commands.
- Batch based interface (BI): commands and directives are used to manage those
commands that are entered into files and those files get executed.
- Graphical User Interface (GUI): which is a window system with a pointing device (like
mouse or trackball) to point to the I/O, choose from menus driven interface and to make
choices viewing from a number of lists and a keyboard.
PROGRAM EXECUTION OF OPERATING SYSTEM
- The operating system must have the capability to load a program into memory and
execute that program. Furthermore, the program must be able to end its execution, either
normally or abnormally / forcefully.
I/O OPERATIONS IN OPERATING SYSTEM
- The operating system must have the capability to load a program into memory and
execute that program. Furthermore, the program must be able to end its execution, either
normally or abnormally / forcefully.
FILE SYSTEM MANIPULATION IN OPERATING SYSTEM
- Programs need has to be read and then write them as files and directories. File handling
portion of operating system also allows users to create and delete files by specific name
along with extension, search for a given file and / or list file information.
COMMUNICATIONS IN OPERATING SYSTEM
- Process needs to swap over information with other process. Processes executing on same
computer system or on different computer systems can communicate using operating
system support. Communication between two processes can be done using shared
memory or via message passing.
ERROR DETECTION IN OPERATING SYSTEM
- Errors may occur within CPU, memory hardware, I/O devices and in the user program.
For each type of error, the OS takes adequate action for ensuring correct and consistent
computing.
ENSURING EFFICIENT OPERATION
• Resource allocation
- When multiple users or multiple jobs running concurrently, resources must be allocated
to each of them. Many types of resources -Some (such as CPU cycles, main memory, and file
storage) may have special allocation code, others (such as I/O devices) may have general request
and release code.
• Accounting
-This service of the operating system keeps track of which users are using how much and
what kinds of computer resources have been used for accounting or simply to accumulate usage
statistics.
• Protection and Security
-Protection includes in ensuring all access to system resources in a controlled manner.
For making a system secure, the user needs to authenticate him or her to the system before using
(usually via login ID and password).
OPERATING SYSTEM DESIGN
Operating System Structure
- Simple Structure
- Layered Approach
- Microkernel
- Modular
- Hybrid
Two Examples of Simple Structured
 MS-DOS
- It was written to provide the most functional in the least space
- It was originally designed and implemented by a few people
- Vulnerable to errant (or malicious) programs, causing entire system crashes
when user programs fail.

 UNIX
- Like MS-DOS, UNIX
initially was limited by
hardware functionality. It
consists of two separable
parts:
KERNEL
SYSTEM PROGRAMS

LAYERED
 Layered Structure is a
type of system structure in which the different
services of the operating system are split into
various layers, where each layer has a specific
well-defined task to perform. It was created to
improve the pre-existing structures like the
Monolithic structure (UNIX) and the Simple
structure (MS-DOS).
Example: The Windows NT operating system
uses this layered approach as a part of it.
MICROKERNEL
- Microkernel is one of the classifications of the kernel. Being a kernel, it manages all system
resources. But in a microkernel, the user services and kernel services are implemented in

different address space. The user services are kept in user address space, and kernel services are
kept under kernel address space, thus also reduces the size of kernel and size of operating
system as well.
MODULAR

- Uses object-oriented
approach
- Each core components are
separate
- Clearly defined interfaces
- Each is loadable as needed
within the kernel
- Overall similar, to layers
but with more flexible

HYBRID
 Hybrid structure - have some type of layered structure with certain functions and services
on certain layers and maybe a microkernel in there or just modules and there's always
new ideas coming along but this is just the basic understanding of the different ways you
can structure the services in this software of the operating system.
THREE WELL KNOWN HYBRID
1. Android
2. IOS
3. Apple MAC OS X

COMPUTER SYSTEMS
- Traditional
Traditional Computer System takes the input from the user and computes the output as the
function of the input. It basically computes function on the input.
- Interactive vs batch
Interactive systems are computer systems characterized by significant amounts of interaction
between humans and the computer.
Batch operating system - do not interact with the computer directly. To speed up processing,
jobs with similar needs are batched together and run as a group. The programmers leave their
programs with the operator and the operator then sorts the programs with similar requirements
into batches.
- Real time/ (hard vs soft)
• Used in real-time systems. The time interval which is needed to process and respond to
inputs is very less. This time interval is known as response time.
Hard Real-Time
For the applications where time constraints or conditions are very strict and even the
smallest or shortest possible delay is not accepted.
Soft Real-Time
For applications where for less strict time-constraint.
- Clustered
• Cluster Operating systems are mixer of software and hardware clusters. Hardware cluster
provides help to share of ultraperformance disks in between all computer systems, and
Software cluster offers better environment for all system to work together.
- Distributed
• These are called as loosely coupled or distributed systems. These systems processors vary
in sizes and functions. The major benefit of working is that it is always viable that a
single user can access the files or software which are not currently present on the system
but actually present on some other system connected in this network i.e., remote access is
enabled in the devices which are connected in this network.
- Network Operating System
• These systems run on a server. These systems provide the functionality to manage data,
users, applications, security, groups, and also some other networking roles. These allow
shared access to networking functions on minor or small private network.

Related Materials:
 https://shorturl.at/adqFR (OS Services)
 https://shorturl.at/cxySY (Operating System Services)
 https://shorturl.at/iHL01 (Operating System Services)

References:
[1] Operating System- Services-Tutoriapoints. (2021)- https://bit.ly/3vaqq5H
[2] Layered Operating System- GeeksforGeeks. (2020)- https://bit.ly/3bLiLD6
[3] Operating System: Structures. (2021)- https://bit.ly/3fGestI
[4] Operating-System Structure - Operating Systems Study Guide. (2021-https://bit.ly/2SgUhuu
[5] Advantages and Disadvantages of different types of Operating Systems. (2021)-
https://bit.ly/2Tboqfl
[6] Banger, E. (2020). What is Clustered Operating System (OS): Definition, Types,
Advantages- https://bit.ly/3u4BD6k

Exercises: (MULTIPLE CHOICE QUIZ)


Questions:
1. It usually deals with using text commands and a technique for entering those commands.
a. Command Line Interface
b. Graphical User Interface
c. Batch based Interface

2. It is a type of system structure in which the different services of the operating system are
split into various layers.
a. Layered
b. Microkernel
c. Hybrid

3. The following are benefits of using Microkernel except?


A. Easier to extend a microkernel
B. Easier to port the operating to new architectures
C. Strict structures

4. These are computer systems characterized by significant amounts of interaction between


humans and the computer.
A. Batch operating system
B. Interactive system
C. Cluster operating systems

5. These are advantages of layered structure except:


A. Easy debugging
B. No direct access to hardware
C. Both a and b
6. This service of the operating system keeps track of which users are using how much and
what kinds of computer resources have been used for accounting or simply to accumulate
usage statistics.
A. Protection and Security
B. Resource allocation]
C. Accounting

7. A process includes the complete execution context (code to execute, data to manipulate,
registers, OS resources in use). Following are the major activities of an operating system
with respect to program management except:
A. Loads a program into memory.
B. Provides a mechanism for deadlock handling
C. Handles program's execution.
D. All of the above

8. When multiple users or multiple jobs running concurrently, resources must be allocated
to each of them
Many types of resources -Some (such as CPU cycles, main memory, and file storage)
may have special allocation code, others (such as I/O devices) may have general request
and release code.
A. Resource allocation
B. Protection and Security
C. Accounting
D. Both a and b

9. The operating system must have the capability to load a program into memory and
execute that program. Furthermore, the program must be able to end its execution, either
normally or abnormally / forcefully.
A. Program Execution of Operating System
B. I/O Operations in Operating System
C. Communications in Operating System
D. Error Detection in Operating System

10. Process needs to swap over information with other process. Processes executing on same
computer system or on different computer systems can communicate using operating
system support. Communication between two processes can be done using shared
memory or via message passing.
A. Error Detection in Operating System
B. Communications in Operating System
C. File System Manipulation in Operating System
D. I/O Operations in Operating System

11. A user interface of Operating system which is a window system with a pointing device
(like mouse or trackball) to point to the I/O, choose from menus driven interface and to
make choices viewing from a number of lists and a keyboard to entry the texts.
A. Graphical user interface (GUI)
B. The command line interface (CLI)
C. The batch interface (BI)

12. These systems run on a server. These systems provide the functionality to manage data,
users, applications, security, groups, and also some other networking roles. These allow
shared access to networking functions on minor or small private network.
A. Network Operating System
B. Distributed
C. Clustered
D. Traditional

13. The operating system must have the capability to load a program into memory and
execute that program. Furthermore, the program must be able to end its execution, either
normally or abnormally / forcefully.
A. File System Manipulation in Operating System
B. Communications in Operating System
C. I/O Operations in Operating System
D. Error Detection in Operating System

14. Do not interact with the computer directly. Each user prepares his job on an off-line
device like punch cards and submits it to the computer operator. To speed up processing,
jobs with similar needs are batched together and run as a group. The programmers leave
their programs with the operator and the operator then sorts the programs with similar
requirements into batches.
A. Batch operating system
B. Interactive systems
C. Hard Real-Time
D. Soft Real-Time

15. _________ is one of the classifications of the kernel. Being kernel it manages all system
resources. But in a microkernel, the user services and kernel services are implemented in
different address space.
A. Layered
B. Microkernel
C. Modular
D. Hybrid

16. Have some type of layered structure with certain functions and services on certain layers
and maybe a microkernel in there or just modules and there's always new ideas coming
along but this is just the basic understanding of the different ways you can structure the
services in this software of the operating system.
A. Layered
B. Microkernel
C. Modular
D. Hybrid

17. ___________ are mixer of software and hardware clusters. Hardware cluster provides
help to share of ultra-performance disks in between all computer systems, and Software
cluster offers better environment for all system to work together.
A. Cluster Operating systems
B. Network Operating System
C. Cluster Operating systems
D. Real-time systems

18. Ensuring Efficient Operation includes:


A. Resource allocation
B. Accounting
C. Protection and Security
D. All of the above

19. This service of the operating system keeps track of which users are using how much and
what kinds of computer resources have been used for accounting or simply to accumulate
usage statistics.
A. Accounting
B. Protection and Security
C. Resource allocation
D. All of the above

20. _________ takes the input from the user and computes the output as the function of the
input. It basically computes function on the input.
A. Cluster Operating systems
B. Network Operating System
C. Real-time systems
D. Traditional Computer System

Answer Key:
Unit III. Process Concept
1.What is a process?
2. Process Control Block
3.Process State
4.Process Scheduling
5. Process Scheduling Queues
6.Schedulers
7.Operating System Process

Lesson Objectives:

 Determine hoe process works in OS


 Recognize the different Process States
 Determine how process control block execution
 Describe various CPU Schedulers
 Determine the Operating System Process

Readings:
PROCESS
 active program
 the execution must progress in a sequential fashion
 includes:
program code (text section)
current activity
stacks containing temporary data
4 SECTIONS
 Text
-the read-only location that contains executable instructions, constants and such, and is
sharable so another process can also use it
 Data
-stores the global and static variables, allocated and initialized prior to executing main
 Heap – provides dynamic memory allocation whenever memory is required by the
program during runtime
 Stack – contains the temporary data such as local variable, function and returns address
PROCESS CONTROL BLOCK (PCB)
 a data structure used by Computer OS to store all the information about a process. OS
creates PCB once a program becomes active. The architecture of the PCB is dependent
on the OS and may contain different information in different OS

Process State – the process of the program


execution
Program Counter – during execution, the CPU
performs the fetch-decode-execute cycle
CPU Registers – used by the processor to store
data needed during the process
CPU Scheduling Information – priorities,
scheduling queue pointers
Memory Management Allocation – memory
allocated to the process
Accounting Information – it is a system of
collecting and storing the information used by the
CPU to keep track of the active processes
I/O Status Information – it provides information
which are to be allocated for a particular process.
And it also shows which files are open.
PROCESS STATE
 When a process executes, it passes through different states. These stages may differ in
different operating systems, and the names of these states are also not standardized.
 New – the initial state when a process is first created, sometimes called “start”
 Ready – the process is waiting to be assigned to a processor
 Running – once the process is assigned by the OS scheduler, the process
state is set to running
 Waiting – the process is set to waiting if it needs to wait for a resource
to become available or if some event occurred
 Terminated – the process is terminated if its execution is complete
PROCESS SCHEDULING
- the process scheduling handles the removal of running process from the
CPU and the selection of another process on a particular strategy.
- the process scheduling system keeps the CPU busy at all times and to
deliver "acceptable" response times for all programs
PROCESS SCHEDULING QUEUES
 Job Queue – keeps all the processes
 Ready Queue – where the new process is place as it keeps a set of all processes residing
in main memory, ready and waiting to execute.
 Device Queue – where the processes that are blocked due to unavailability of I/O devices
takes place
SCHEDULERS
 special system software which handle process scheduling in various ways.
 their main task is to select the jobs to be submitted into the system and to decide which
process to run.
 Three types:
Long-term Schedulers
Short-term Schedulers
Medium-term Schedulers
Long Term Scheduler
 Job scheduler
- determines which programs are admitted to the system for processing
- selects processes from the queue and loads them into memory for execution
- controls the degree of multiprogramming
- when a process changes the state from new to ready, then there is use of
long-term scheduler.
Short Term Scheduler
 CPU scheduler or dispatcher
- to increase system performance in accordance with the chosen set of criteria
- the change of ready state to running state of the process
- selects a process among the processes that are ready to execute and
allocates CPU to one of them
- faster than long-term schedulers
Medium Term Scheduler
- part of swapping
- removes the processes from the memory
- reduces the degree of multiprogramming

Processes can be described as either:


 I/O-bound process – spends more time doing I/O than computations; many short CPU
bursts
 CPU-bound process – spends more time doing computations; few very long CPU bursts
OPERATIONS ON PROCESSES
 The execution of a process is a complex
activity. It involves various operations.
The following are the operations that
performed during execution of a process:

Context Switching
 the operating system switches the CPU from one process to another
Concurrency
• execution of two or more independent processes at the same time
Cooperating Processes
• processes that share data with one another
1. Creation
-This is the initial step of process execution activity.
-Process creation means the construction of a new process for the execution.
-System, user or old process itself might perform this.
-The creating process is called the Parent Process and the created process is
the child process.
- A child process can only have one parent process, but a parent process may
have many child processes.
2. Scheduling/Dispatching
- It means the operating system puts the process from ready state into the
‘running’ state.
- Dispatching is done by the operating system when the resources are free,
or the process has higher priority than the ongoing process.
- There are various other cases in which the process in running state is pre-
empted, and process in ready state is dispatched by the operating system.
-
3. Blocking
- This happens when a process invokes an input-output system call that
blocks the process, and the operating system is put in block mode.
- Block mode is a mode where process waits for input-output.
- Hence, on the demand of process itself, operating system blocks the process
and dispatches another process to the processor.
4. Preemption
- An interrupt mechanism is used in preemption that suspends the process
currently being executed, and the nest process to be executed is determined
by the short-term scheduler.
- Hence, in process preemption operation, the operating system puts the
process in ‘ready’ state.

5. Termination
- Process termination is the activity of ending the process. In other words,
process termination is the relaxation of computer resources taken by the
process for the execution.
- The termination of a process when all its instruction has been executed
successfully is called Normal Termination.
- However, there are instances when a process terminates due to some error.
This termination is called as Abnormal Termination.
Like creation, in termination also there may be several events that may lead to the process
termination.
• Process completes its execution fully and it indicates to the OS that it has
finished.
• Operating system itself terminates the process due to service errors.
• There may be problem in hardware that terminates the process.
• Another process can terminate one process.
Related Materials:
 https://bit.ly/3oEh4MX (Process Concept)
 https://bit.ly/34cX2Qt (Process Concept)
 https://bit.ly/3v3w0H1 (Process Concept)

References:
[1] Operating System - Processes - Tutorialspoint. (2021)- http://bit.ly/3cST1WH
[2] Operating System Process Scheduling -http://bit.ly/3rvXUcw
[3] GeeksforGeeks (2020). Operations on Processes- http://bit.ly/2My4MqZ
[4] Kent State University- https://bit.ly/2MQON7j
[5] Bisht, H. S. (2018). Memory Layout of a Process | Operating system)-
https://bit.ly/3rE3dGy
[6] Silberschatz, A., Gagne, g., & Galvin, P.B. Operating System Concepts, Ninth
Edition.- https://bit.ly/2YX1vUL
Exercises: (MULTIPLE CHOICE QUIZ)
Questions:
1. Its architecture is dependent on the OS and may contain different information in different
OS.
a) Process State
b) Schedulers
c) Process Control Block
d) Process Scheduling

2. It contains the temporary data such as local variable, function and returns address.
a) Stack
b) Heap
c) State
d) Data

3. When a process executes it passes through different states, from its creation to its
completion, and the state of a process is defined in part by the past activity of that
process.
a) True
b) False

4. Which of the following is NOT true?


a) If the program is going to be in execution and the process is being created its state
is new state.
b) Once the process has been created, it will be admitted to the ready state.
c) Running state is where the process begins its execution or is in the state of being
executed
d) The state will move to the terminated state if the process is waiting to be assigned
in a processor

5. Once the needed resource/s or event occurred has already been handled/completed or if
the process is not waiting for anymore occurrence, the process will go to the?
a) Ready state
b) Running state
c) Waiting state
d) Terminated state

6. Which is true about Process Scheduling?


a) It provides information which are to be allocated for a particular process
b) Its architecture is dependent on the OS and may contain different information in
different OS
c) It handles the removal of running process from the CPU and the selection of
another process on a particular strategy
d) It keeps all running processes in memory at the same time

7. This special system software handles process scheduling in various ways. Their main task
is to select the jobs to be submitted into the system and to decide which process to run.
a) Process State
b) Schedulers
c) Process Control Block
d) Process Scheduling

8. Which of the following is correct?


a) Long term: job scheduler: Short term: swapping scheduler
b) Short term: swapping scheduler: Medium term: job scheduler
c) Long term: job scheduler: Medium term: swapping
d) Short term: job scheduler: Medium term: CPU scheduler

9. It determines which programs are admitted to the system for processing. It selects
processes from the queue and loads them into memory for execution.
a) Long Term Scheduler
b) Short Term Scheduler
c) Medium Term Scheduler
d) Small Term Scheduler

10. It removes the processes from the memory and is in-charge of handling the swapped out-
processes.
a) Long Term Scheduler
b) Short Term Scheduler
c) Medium Term Scheduler
d) Small Term Scheduler

11. It increases system performance in accordance with the chosen set of criteria. It is the
change of ready state to running state of the process.
a) Long Term Scheduler
b) Short Term Scheduler
c) Medium Term Scheduler
d) Small Term Scheduler

12. Which of the following is NOT an operation that is performed during the execution of a
process?
a) Creation
b) Dispatching
c) Preemption
d) Concurrency

13. A child process can have two parent processes, but a parent process may have many child
processes.
a) True
b) False

14. The following are the several events that leads to the process creation, EXCEPT ONE.
a) When we start the computer, system creates several background processes.
b) A user may request to create a new process.
c) A process cannot create a new process itself while executing.
d) Batch system takes initiation of a batch job.

15. This is done by the OS when the resources are free, or the process has higher priority than
the ongoing process and there are various other cases in which the process in running
state is dispatched by the OS
a) Creation
b) Dispatching
c) Preemption
d) Concurrency
16. Blocking happens when a process invokes an input-output system call that terminates the
process, and the operating system is out in block mode.
a) True
b) False

17. The following are true about Preemption, EXCEPT ONE.


a) The OS preempts the process when a timeout occurs where the process hadn’t
been terminated in the allotted time interval and next process is ready to execute
b) This operation can be done even if the CPU scheduling does not support
preemption
c) This happens in priority scheduling where on the incoming of high priority
process the ongoing process is preempted
d) In process preemption operation, the operating system puts the process in ‘ready’
state.

18. The termination of a process when all its instruction has been executed successfully.
a) Normal Termination
b) Acute Termination
c) Special Termination
d) Abnormal Termination

19. The termination of a process when a process terminates due to some error.
a) Normal Termination
b) Acute Termination
c) Special Termination
d) Abnormal Termination

20. The following are the several events that may lead to the process termination, EXCEPT
ONE.
a) Process completes its execution fully and it indicates to the OS that it has
finished.
b) Operating system itself terminates the process due to service errors.
c) There may be problem in hardware that terminates the process.
d) Another process cannot terminate one process.
Answer Key:
Unit IV. Process Scheduling
1.Process Types
2. CPU Scheduling
3. Types CPU Scheduling
4. CPU Scheduling Criteria
5. CPU Scheduling Algorithms
6. CPU Scheduling Algorithm Types

Lesson Objectives:

 Understand the purpose of the Process Types


 Distinguish between a Scheduling criteria, algorithm and a process
 Explain the behavior of CPU Scheduling Algorithms Describe various memory
 Analyze how important Algorithm in CPU Scheduling
 Describe each Algorithm used in the process

Readings:
PROCESS TYPES
• CPU Bound Process - means the rate at which process progresses is limited by the speed
of the CPU. A task that performs calculations on a small set of numbers, for example
multiplying small matrices, is likely to be CPU bound.
• I/O Bound Process - means the rate at which a process progresses is limited by the speed
of the I/O subsystem. A task that processes data from disk, for example, counting the
number of lines in a file is likely to be I/O bound.
Context Switching
• The process of saving the context of one process and loading the context of another
process is known as Context Switching. In simple terms, it is like loading and unloading
the process from running state to ready state.
Dispatcher
• module gives control of the CPU to the process selected by the short-term scheduler; this
involves:
--switching context
-switching to user mode
-jumping to the proper location in the user program to restart that program
Dispatch latency
• time it takes for the dispatcher to stop one process and start another running
TYPES OF CPU SCHEDULING
1. Long term Scheduler (Job scheduler)
- It brings the new process to the ‘Ready State’.It controls Degree of Multi-
programming, number of process present in ready state at any point of time.
2. Short term or CPU Scheduler
- It is responsible for selecting one process from ready state for scheduling it on
the running state.
- The CPU scheduler is responsible for ensuring there is no starvation owing to
high burst time processes.
Note: Short-term scheduler only selects the process to schedule it doesn’t load the process on
running. Here is when all the scheduling algorithms are used.

3. Medium-term scheduler
It is responsible for suspending and resuming the process. It mainly does swap
(moving processes from main memory to disk and vice versa). Swapping may be
necessary to improve the process mix or because a change in memory requirements has
overcommitted available memory, requiring memory to be freed up. It is helpful in
maintaining a perfect balance between the I/O bound and the CPU bound. It reduces the
degree of multiprogramming.
What is CPU SCHEDULING?
• CPU scheduling is a process which allows one process to use the CPU while the
execution of another process is on hold (in waiting state) due to unavailability of any
resource like I/O etc., thereby making full use of CPU. The aim of CPU scheduling is to
make the system efficient, fast and fair.
• CPU burst – time on the CPU
CPU SCHEDULING CRITERIA
• CPU utilization: CPU utilization is the main task in which the operating system needs to
make sure that CPU remains as busy as possible. It can range from 0 to 100 percent.
However, for the RTOS, it can be range from 40 percent for low-level and 90 percent for
the high-level system.
• Throughput: is the number of processes that finish their execution per unit time. So, when
the CPU is busy executing the process, at that time, work is being done, and the work
completed per unit time is called Throughput.
• Turnaround time – the interval from the time a process is submitted until it is
completed; compute for the time the process is in the ready queue, executing & doing
I/O;
– Time Finished minus Arrival Time
• Response time – for an interactive process, this refers to the time between the
submission of the process until it starts responding.
• Waiting time – the total amount of time a process spends in the ready queue;
– Turnaround Time minus CPU Burst
CPU SCHEDULING ALGORITHMS
Non-Preemptive Scheduling
Under non-preemptive scheduling, once the CPU has been allocated to a process, the
process keeps the CPU until it releases the CPU either by terminating or by switching to the
waiting state.
It is the only method that can be used on certain hardware platforms, because It does not
require the special hardware (for example: a timer) needed for preemptive scheduling. Under the
non-preemptive are the:
• FCFS or First Come First Serve
• SJF or Short Job First
• Priority Scheduling
Pre-emptive Scheduling
In this type of Scheduling, the tasks are usually assigned with priorities. At times it is
necessary to run a certain task that has a higher priority before another task although it is
running. Therefore, the running task is interrupted for some time and resumed later when the
priority task has finished its execution. Under this are the,
• Round-Robin
• SJR OR Shortest Remaining Time
• Preemptive Priority
TYPES OF CPU SCHEDULING ALGORITHM
1. First Come First Serve (FCFS)
• In the "First come first serve" scheduling algorithm, as the name suggests, the process
which arrives first, gets executed first, or we can say that the process which requests the
CPU first, gets the CPU allocation first.

• First Come First Serve, is just like FIFO (First in First out) Queue data structure, where
the data element which is added to the queue first, is the one who leaves the queue first.

2. Shortest Job First Scheduling Algorithm (Non-Preemptive)


- the process which has the shortest job or CPU burst will be allocated first.
3. Priority Scheduling Algorithm (Non-Preemptive)
• Each process is assigned a priority and the CPU scheduler selects the process in the ready
queue with the highest priority to execute next. Note: The lower the number, the higher
the priority.
• In this type of scheduling method, the CPU has been allocated to a specific process. The
process that keeps the CPU busy, will release the CPU either by switching context or
terminating.

Pre-emptive Scheduling
4. Round Robin Algorithm
-Round Robin is the preemptive process scheduling algorithm.
-Each process is provided a fix time to execute, it is called a quantum.
-the processes are selected on a first-come, first-serve basis however, each process is a
given a time limit to execute at the CPU (Time Quantum)

5.

Priority Scheduling (Preemptive)


- at the time of arrival of a process in the ready queue, its Priority is compared
with the priority of the other processes present in the ready queue as well as with the one
which is being executed by the CPU at that point of time.

6. Shortest Remaining Time


• The full form of SRT is Shortest remaining time. It is also known as SJF preemptive
scheduling. In this method, the process will be allocated to the task, which is closest to its
completion. This method prevents a newer ready state process from holding the
completion of an older process.

Related Materials:
 https://bit.ly/3yyX6HV (SJF)
 https://bit.ly/34cX2Qt (Process Concept)
 https://bit.ly/3v3w0H1 (Process Concept)

References:
[1] Process Management in Operating System: PCB in OS. (2021)- https://bit.ly/3oEEbXD
[2] Process Scheduling in Operating System- GeeksforGeeks.(2015)- https://bit.ly/3hLvMQM
[3] Introduction of Process Management-GeeksforGeeks (2015)- https://bit.ly/347uw2o
[4] FCS Scheduling Algorithm: What is, Example Program (2021)- https://bit.ly/3u9MCvs
[5] Round Robin Scheduling Algorithm with Example (2021)- https://bit.ly/345XAY7
[6] Silberschatz, A., Gagne, g., & Galvin, P.B. Operating System Concepts, Ninth Edition.-
https://bit.ly/2YX1vUL
Exercises: (MULTIPLE CHOICE QUIZ)
Questions:
Consider the following process.

Process ID Arrival Time CPU Burst


P1 0 8
P2 3 4
P3 4 5
P4 6 3
P5 10 2

1. What is the correct Gantt chart for the SJF scheduling algorithm given above?

A.
P1 P5 P4 P2 P3
0 8 10 13 17 22
B.
P5 P4 P2 P3 P1
0 2 5 9 14 22
C.
P1 P4 P5 P2 P3
0 8 11 13 17 22

2. What is the Average turnaround time of P3?


A. 14
B. 10
C. 18
3. What is the Average Turnaround time of the given processes above?
A. 9.6
B. 12
C. 11
4. It is a preemptive process scheduling in which the process is selected on first-come, first
serve basis however each process has a given time limit to execute at the CPU.
A. FCFS/FIFO
B. Round Robin
C. Priority Scheduling
5. Is a scheduling method that is a preemptive version of shortest job next scheduling?
A. SRTF
B. FCFS
C. ROUND ROBIN

6. At the time of arrival of a process in the ready queue, its Priority is compared with the
priority of the other processes present in the ready queue as well as with the one which is
being executed by the CPU at that point of time?
A. Preemptive priority scheduling
B. SJF preemptive scheduling
C. Non-preemptive priority scheduling
7. SJF is the process which has the shortest job or CPU burst will be allocated first.
A. TRUE
B. FALSE
8. In FCFS, the lower the number the higher the priority.
A. TRUE
B. FALSE
9. Each process is assigned a priority and the CPU scheduler selects the process in the ready
queue with the highest priority to execute next?
A. FCFC
B. Round robin
C. Preemptive priority scheduling
D. Non preemptive priority scheduling

10. It is the only method that can be used on certain hardware platforms, because It does not
require the special hardware.
A. FCFC
B. Round robin
C. Non preemptive scheduling
D. Preemptive scheduling
11. It is a type of scheduler that used for swapping that is moving the process from main
memory to secondary and vice versa.
A. Long term scheduler
B. Short term scheduler
C. Medium term scheduler
12. The number of processes that finish their execution per unit time.
A. Throughput
B. Turnaround time
C. Response time
13. A scheduling algorithm that the process which requests the CPU first, gets the CPU
allocation first.
A. Short Job First
B. Round Robin
C. First Come First Serve
D. Priority

14. The main task in which the operating system needs to make sure that CPU remains as
busy as possible.
A. CPU bound
B. CPU utilization
C.CPU scheduling
D. CPU burst
15. The formula in getting the turn-around time.
A. Waiting time - CPU burst
B. CPU burst - arrival time
C. Time finished - arrival time
D. Time finished - CPU burst
16. The CPU is busy executing the process, at that time, work is being done, and the work
completed per unit time is called ____.
A. Response time
B. Throughput
C. Turnaround time
D. Burst time
17. Which of the following process scheduling algorithm may lead to starvation
A. FIFO
B. Round Robin
C. Shortest Job Next
D. None of the above
18. Which of the following is FALSE about SJF (Shortest Job First Scheduling)?
S1: It causes minimum average waiting time
S2: It can cause starvation

A. Only S1
B. Only S2
C. Both S1 and S2
D. Neither S1 nor S2

19. I. Shortest remaining time first scheduling may cause starvation


II. Preemptive scheduling may cause starvation
III. Round robin is better than FCFS in terms of response time
A. I only
B. I and III only
C.II and III only
D.I, II and III
20. Which of the following scheduling algorithms is non-preemptive?

A. Round Robin
B. FCFC
C. Priority
D. Shortest Job First
Answer Key:

1. C 11.C
2. C 12.A
3. A 13.C
4. B 14.B
5. A 15.C
6. A 16.B
7. A 17.C
8. B 18. D
9. D 19. D
10. C 20. B

Unit V. Round Robin CPU Scheduling


1.MLQ-CPU Scheduling
2. Multilevel Feedback Queues
3. CPU Scheduling Practice: FCFS
4. CPU Scheduling Practice: SJF
5. CPU Scheduling Practice: MLFQ

Lesson Objectives:

 Understand the purpose of Round Robin CPU Scheduling


 Recognize critical resources and explain the behavior MLQ-CPU Scheduling
 Describe MLQ-CPU Scheduling and how it is being use
 Distinguish between FCFS, SJF, MLFQ
 Describe the importance of each que

Readings:
MLQ – CPU Scheduling
Multi-level queue scheduling algorithm is used in scenarios where the processes can be
classified in to groups based on
property like process type, CPU time, IO
access, memory size, etc. One general
classification of the processes is foreground
processes and background processes.
A common division is
a foreground (interactive) process and background (batch) processes. These two classes have
different scheduling needs. For this kind of situation Multilevel Queue Scheduling is used. Now
let us see how it works. Ready Queue is divided into separate queues for each class of processes.
For example, let us take three different types of process System processes, Interactive processes
and Batch Processes.

• Fixed priority preemptive scheduling method – Each queue has absolute priority over
lower priority queue. Let us consider following priority order queue 1 > queue 2 > queue
3. According to this algorithm, no process in the batch queue (queue 3) can run unless
queue 1 and 2 are empty. If any batch process (queue 3) is running and any system
(queue 1) or Interactive process (queue 2) entered the ready queue the batch process is
preempted.
• In this method each queue gets certain portion of CPU time and can use it to schedule its
own processes. For instance, queue 1 takes 50 percent of CPU time queue 2 takes 30
percent and queue 3 gets 20 percent of CPU time.

• Priority of queue 1 is greater than queue 2. queue 1 uses Round Robin (Time Quantum =
2) and queue 2 uses FCFS.

 At starting both queues have process so process in queue 1 (P1, P2) runs first (because of
higher priority) in the round robin fashion and completes after 7 units then process in
queue 2 (P3) starts running (as there is no process in queue 1) but while it is running P4
comes in queue 1 and interrupts P3 and start running for 5 second and after its completion
P3 takes the CPU and completes its execution.
MULITLEVEL FEEDBACK QUEUES

• Multilevel feedback queues use part behavior to predict the future and assign job
priorities
=> overcome the prediction problem in SJF
• If process is I/O bound in the past, it is also likely to be I/O bound in the future
(program turn out not to be random.)
• To exploit this behavior, the scheduler can favor jobs that have used the least amount of
CPU time, thus approximating SJF.
• This policy is adaptive because it relies on past behavior and changes in behavior result
in changes scheduling decisions.
Approximating SJF: Multilevel Feedback Queues
• Multiple queues with different priorities.
• Use round robin scheduling at each priority level, running the jobs highest priority first.
• once those finish, run jobs at the next highest priority queue, etc.
(can lead to starvation)
• Round robin time slice increases exponentially at lower priorities.
Adjusting Priorities in MLFQ
• Job start in the highest priority queue.
• If job's time slices expires, drop its priority one level.
• If job's time slices does not expire (the content switch comes from an I/O request
instead), then increase its priority one level, up to the top priority level.
=> CPU bound jobs drop like a rock in priority and I/O bound jobs stay at a high priority.
Related Materials:
 https://bit.ly/3wuaKds (Round Robin CPU Scheduling)
 https://bit.ly/3oR2VfH (Round Robin CPU Scheduling)
 https://bit.ly/3oCOATU (Round Robin CPU Scheduling)
References:
[1] Process Management in Operating System: PCB in OS. (2021)- https://bit.ly/3oEEbXD
[2] Process Scheduling in Operating System- GeeksforGeeks.(2015)- https://bit.ly/3hLvMQM
[3] Introduction of Process Management-GeeksforGeeks (2015)- https://bit.ly/347uw2o
[4] FCS Scheduling Algorithm: What is, Example Program (2021)- https://bit.ly/3u9MCvs
[5] Round Robin Scheduling Algorithm with Example (2021)- https://bit.ly/345XAY7
[6] Silberschatz, A., Gagne, g., & Galvin, P.B. Operating System Concepts, Ninth Edition.-
https://bit.ly/2YX1vUL
Exercises: (MULTIPLE CHOICE QUIZ)
Questions:
1. This policy is adaptive because it relies on the past behavior and changes in behavior results
in changes scheduling decision?
a. Short Job First
b. Multilevel Feedback Queue
c. First Come First Serve
d. Multilevel Queue
2. This are under the approximating Short Job First except one?
a. Multiple queues with different priorities.
b. Round robin time slice increases exponentially at lower priorities.
c. Its behavior is to predict the future and assign job priorities.
d. Use round robin scheduling at each priority level, running the jobs highest priority
first.
3. In adjusting priorities in MLFQ we have a rule to follow except one?
a. Round robin time slice increases exponentially at lower priorities.
b. If job’s time slices expires, drop its priority one level.
c. Job start in the highest priority queue.
d. CPU bound jobs drop like a rock in priority and I/O bound jobs stay at a high priority.
4. Short Job first are use part behavior to predict the future and assign job priorities?
a. True
b. False
c. Maybe
5. This is an algorithm in which the process having the smallest execution time is chosen for the
next execution?
a. First Come First Serve
b. Multilevel Queue
c. Short Job First
d. Multilevel Feedback Queue

6. If a process uses too much CPU time, it will be moved to higher-priority queue.
a. true
b. false
c. partial true
d. partial false
7. A multilevel feedback queue scheduler is defined by the following parameters, except one:
a. The number of queues.
b. The scheduling algorithm for each queue.
c. The method used to determine when to upgrade a process to a lower-priority queue.
d. The method used to determine when to demote a process to a lower-priority queue.
8. Shortest Job First Pre-emptive Scheduling is also known as Shortest remaining Time (SRT) or
Shortest Next Time (SNT).
a. True b. False
9. In MLFQ, queue 3 is higher-priority than queue 2 and queue 2 is higher priority than queue 1.
a. False b. True
10. Which is not belong to the group?
a. MLFQ
b. FCFS
c. SJF
d. MLQ
Answer key:
Unit VI. Introduction to Kali Linux
1.What is Kali Linux?
2. Kali Linux History
3. Kali Net Hunter History

Lesson Objectives:

 Understand the significance of Kali Linux


 Know the history of Kali Linux
 Determine how abruptly Kali Linux change
 Distinguish what Kali Net Hunter is and its History

Readings:
What is Kali Linux?
Kali Linux (formerly known as BackTrack Linux) is an open-source, Debian-based
Linux distribution aimed at advanced Penetration Testing and Security Auditing. Kali Linux
contains several hundred tools targeted towards various information security tasks, such as
Penetration Testing, Security Research, Computer Forensics and Reverse Engineering. Kali
Linux is a multi-platform solution, accessible and freely available to information security
professionals and hobbyists.
Kali Linux was released on the 13th March 2013 as a complete, top-to-bottom rebuild
of BackTrack Linux, adhering completely to Debian development standards.
KALI LINUX FEATURES

 More than 600 penetration testing tools included: After reviewing every tool that was
included in BackTrack, we eliminated a great number of tools that either simply did not work or
which duplicated other tools that provided the same or similar functionality. Details on what’s
included are on the Kali Tools site.
 Free (as in beer) and always will be: Kali Linux, like BackTrack, is completely free of charge
and always will be. You will never, ever have to pay for Kali Linux.
 Open source Git tree: We are committed to the open source development model and
our development tree is available for all to see. All of the source code which goes into Kali
Linux is available for anyone who wants to tweak or rebuild packages to suit their specific needs.
 FHS compliant: Kali adheres to the Filesystem Hierarchy Standard, allowing Linux users to
easily locate binaries, support files, libraries, etc.
 Wide-ranging wireless device support: A regular sticking point with Linux distributions has
been supported for wireless interfaces. We have built Kali Linux to support as many wireless
devices as we possibly can, allowing it to run properly on a wide variety of hardware and making
it compatible with numerous USB and other wireless devices.
 Custom kernel, patched for injection: As penetration testers, the development team often
needs to do wireless assessments, so our kernel has the latest injection patches included.
 Developed in a secure environment: The Kali Linux team is made up of a small group of
individuals who are the only ones trusted to commit packages and interact with the repositories,
all of which is done using multiple secure protocols.
 GPG signed packages and repositories: Every package in Kali Linux is signed by each
individual developer who built and committed it, and the repositories subsequently sign the
packages as well.
 Multi-language support: Although penetration tools tend to be written in English, we have
ensured that Kali includes true multilingual support, allowing more users to operate in their
native language and locate the tools they need for the job.
 Completely customizable: We thoroughly understand that not everyone will agree with our
design decisions, so we have made it as easy as possible for our more adventurous users
to customize Kali Linux to their liking, all the way down to the kernel.
 ARMEL and ARMHF support: Since ARM-based single-board systems like the Raspberry
Pi and BeagleBone Black, among others, are becoming more and more prevalent and
inexpensive, we knew that Kali’s ARM support would need to be as robust as we could manage,
with fully working installations for both ARMEL and ARMHF systems. Kali Linux is available
on a wide range of ARM devices and has ARM repositories integrated with the mainline
distribution so tools for ARM are updated in conjunction with the rest of the distribution.

Kali Linux is specifically tailored to the needs of penetration testing professionals, and therefore
all documentation on this site assumes prior knowledge of, and familiarity with, the Linux
operating system in general. Please see Should I Use Kali Linux? for more details on what makes
Kali unique.

Should I use Kali Linux?

Kali Linux is specifically geared to meet the requirements of professional penetration testing
and security auditing. To achieve this, several core changes have been implemented in Kali
Linux which reflect these needs:

1. Network services disabled by default: Kali Linux contains systemd hooks that disable
network services by default. These hooks allow us to install various services on Kali
Linux, while ensuring that our distribution remains secure by default, no matter what
packages are installed. Additional services such as Bluetooth are also blacklisted by
default.
2. Custom Linux kernel: Kali Linux uses an upstream kernel, patched for wireless
injection.
3. A minimal and trusted set of repositories: given the aims and goals of Kali Linux,
maintaining the integrity of the system as a whole is absolutely key. With that goal in
mind, the set of upstream software sources which Kali uses is kept to an absolute
minimum. Many new Kali users are tempted to add additional repositories to
their sources list but doing so runs a very serious risk of breaking your Kali Linux
installation.
Kali Linux History

Kali Linux is based on years of knowledge and experience of building a pentestion testing
Operating Systems, which has spanned over multiple previous projects. During all these project’s
life-time, there has been only a few different developers, as the team has always been small. As a
result, Kali has been years in the making and has come a long way.

The first project was called Whoppix, which stood for WhiteHat Knoppix. As can be inferred
from the name, it was based on Knoppix for the underlining OS. Whoppix had releases ranging
from v2.0 to v2.7.

This made way for the next project, WHAX (or the long hand, WhiteHat Slax). The name
change was because the base OS changed from Knoppix to Slax. WHAX started at v3, as a nod
towards it carrying on from Whoppix.

There was a similar OS being produced at the same time, Auditor Security Collection (often
getting shorted to just Auditor), once again using Knoppix, and efforts were combined (with
WHAX) to produce BackTrack. BackTrack was based on Slackware from v1 to v3 but
switched to Ubuntu later on with v4 to v5.

Using the experience gained from all of this, Kali Linux came after BackTrack in 2013. Kali
started off using Debian stable as the engine under the hood before moving to Debian testing
when Kali became a rolling OS.

Kali Linux NetHunter History


Kali NetHunter is a custom OS for Android devices. This takes Kali Linux desktop and makes
it mobile.

Kali NetHunter is made up of three parts: ROM, App (and AppStore), Kali Chroot

Kali NetHunter was first released in September 2014 with v1.0, supporting just Nexus
devices (5,7 and 10). There was a minor release of Kali NetHunter v1.1 in January 2015, and at
the same time device support started to appear, such as OnePlus One and Nexus 4.

Kali NetHunter v3 was the next major release in January 2016, which was a complete
NetHunter app rewrite, allowing for more control and actions to be performed from it, build
scripts and Android 5 and 6 support. Nexus 6 device also became supported.

Kali NetHunter then joined the rolling release with 2019.2 release in May 2019, where 13
devices where supported, with a mixture of Android 4 to 9. From this point, Kali NetHunter
matched the release points of Kali Linux, with each of them adding more devices support, image
and overall features.

Related Materials:
 https://bit.ly/3oFnDyK (Kali Linux)
 https://bit.ly/3bItGgT (What is Kali Linux)
 https://bit.ly/3hQow6e (History of Kali Linux)
References:
[1] What is Kali Linux and Kali’s Features (2021)- https://bit.ly/3fcF86E
Exercises: (IDENTIFICATION QUIZ)
Questions:
1. It was released on the 13th March 2013 as a complete, top-to-bottom rebuild of BackTrack
Linux, adhering completely to Debian development standards.

2. It was the next major release in January 2016, which was a complete NetHunter app rewrite,
allowing for more control and actions to be performed from it, build scripts and Android 5 and 6
support. Nexus 6 device also became supported.

3.-6. Kali NetHunter is made up of three parts: _____, _____, _______?

7. It is specifically tailored to the needs of penetration testing professionals, and therefore all
documentation on this site assumes prior knowledge of, and familiarity with, the Linux operating
system in general.

8. How many devices does Kali NetHunter which was joined the rolling release with 2019.2
release in May 2019?
9. Kali Linux is formerly known as __________.

10. It was released on the 13th March 2013 as a complete, top-to-bottom rebuild of BackTrack
Linux, adhering completely to Debian development standards.
11. When was Kali Linux V1(Moto) released?
12. What is the Bases OS of Whoppix v2?
13. What is the Project released on the year 2016 specifically on the month of January?

14-20. Give at least 7 Kali Linux Features.

Answer Key:
1. Kali Nethunter

2. Kali Nethunter v3

3.-6. ROM, App (and AppStore), Kali Chroot

7. Kali Linux

8. 13 devices

9. BackTrack Linux

10. Kali Linux

11. 2013(March)

12. Knoppix

13 Kali Linux Rolling

14-20. (Refer to the given module)


PREPARED BY:

You might also like