Operating Systems Unit 1:
Introduction to OS:
The term "operating system" was first used in the early 1960s to describe the software that controls the execution of
computer programs and manages hardware resources such as memory and input/output devices. The term was coined
by John W. Tukey in 1958, in his book "An Introduction to Mathematical Methods of Statistics," where he used it to
describe the software that manages the operation of a computer system.
An operating system is software that manages a computer’s hardware. It also provides a basis for application programs
and acts as an intermediary between the computer user and the computer hardware. A fundamental responsibility of an
operating system is to allocate these resources to programs.
Operating system is a system software. It act as an intermediary between the computer user and computer hardware. An
operating system (OS) is a type of software that manages computer hardware and software resources. Provide a platform
on which other application program installed.
A program that acts as an intermediary between a user of a computer and the computer hardware.
An operating System is a collection of system programs that together control the operations of a computer system. Some
examples of operating systems are UNIX, Mach, MS-DOS, MS-Windows, Windows/NT, Chicago, OS/2, MacOS, VMS, MVS,
and VM.
Operating system goals:
Execute user programs and make solving user problems easier.
Make the computer system convenient to use.
Use the computer hardware in an efficient manner.
Components of OS:
OS has two parts. (1)Kernel. (2)Shell.
(1) Kernel is an active part of an OS i.e., it is the part of OS running at all times. It is a programs which can interact with the
hardware. Ex: Device driver, dll files, system files etc.
(2) Shell is called as the command interpreter. It is a set of programs used to interact with the application programs. It is
responsible for execution of instructions given to OS (called commands).
Operating systems can be explored from two viewpoints:
To understand more fully the operating system’s role, we next explore operating systems from two viewpoints: that of
user and that of the system.
From the computer’s point of view, the operating system is the program most intimately involved with the hardware. In
this context, we can view an operating system as a resource allocator. A computer system has many resources that may
be required to solve a problem: CPU time, memory space, storage space, I/O devices, and so on. The operating system
acts as the manager of these resources.
Computer-System Organization:
A modern general-purpose computer system consists of one or more CPUs and a number of device controllers connected
through a common bus that provides access between components and shared memory. Each device controller is in charge
of a specific type of device (for example, a disk drive, audio device, or graphics display).
Evolution of OS:
Evolution of Operating System In starting, mainframe computer were there. Common input and output device work card
reader and tape drive. User prepare a job which consisted of the program input data and control instructions. Input job is
given in the form of punch card and after processing result also appear in the form of punch card.
Disadvantages:
No concept of memory hierarchy.
Very less interactive systems.
Very poor CPU Utilization, speed mismatch between I/O device & CPU.
Every jobs have the different requirement.
Batch Operating System:
Batch processing was very popular in the 1970s. Users using batch operating systems do not interact directly with the
computer. Jobs with the similar needs are batched together and executed through the processor as a group. Each user
prepares their job using an offline device like a punch card and submitting it to the computer operator.
Multiprogramming operating system:
When more than one program is available in the main memory of single processor computer, this concept is called multi
programming. Multi programming means more than one program process in main memory which are ready to execute.
Process generally requires CPU time and input/output time so if running process perform input/output or some other
event which do not required CPU then instead of sitting idle CPU make context switching and pick some other process and
this idea will continue. Do not set idle unless there is a no process ready to execute or at a time of context switching in
main memory.
Multitasking/Time shearing operating system:
Multi-tasking is an extension of multi-programming. There is only a CPU but the context switching between the process
so quickly, they give the illusion that all are executing at the same time. It improves a better response time and execution
of multiple processes together. Fixed Time Quantum One processor but multiple processes, the processor is so fast that it
can complete all the process alone. Sometimes it is called multitasking with round robin.
Multi-Processing operating system:
If a system have more than one Processor or CPU it is called multi-processing system. Two or more CPU with single
computer in a close communication are sharing like system bus memory and other input and output devices. Different
process runs on different CPU (true parallel execution).
Real-Time Operating System:
A real-time operating system (RTOS) is an operating system that is used in computing systems that needs strict completion
deadlines for all the tasks that need to be performed on it.
Real Time Operating System Types:
Hard Real-Time Operating System (HRTOS): The hard real-time operating system is used when we need to complete tasks
by a given deadline. If the task is not completed on time then the system is considered to be failed. eg. Pacemaker requires
require a hard real-time operating system.
Soft Real Time Operating System (SRTOS): A soft real-time operating system is used where few delays in time duration
are acceptable. That is if the given task is taking a few seconds more than the specified time then also no critical damage
takes place. Eg, telephone switches, the sending or receiving of the call.
Interactive operating system :
An Interactive Operating System is a type of operating system that allows users to interact with it using a Graphical User
Interface (GUI) or Command Line Interface (CLI). It provides an interface to the user that allows them to communicate
with the computer and perform tasks such as file management, running applications, configuring settings, etc. Examples
of Interactive Operating Systems include: Microsoft Windows macOS Linux with graphical desktop environments such as
GNOME, KDE, or Xfce Android (for mobile devices) iOS (for Apple devices) These operating systems provide users with a
visually rich and intuitive interface, making it easier for them to perform tasks without the need for specialized technical
skills. They also often provide users with access to a wide range of software applications and tools that they can use to
enhance their productivity and creativity.
Distributed operating system:
A distributed operating system is a software over a collection of independent, networked, communicating, loosely coupled
nodes and physically separate computational nodes. The nodes communicate with one another through various networks,
such as high-speed buses and the Internet. They handle jobs which are serviced by multiple CPUs. Each individual node
holds a specific software subset of the global aggregate operating system. There are four major reasons for building
distributed systems: resource sharing, computation speedup, reliability, and communication.
Spooling:
In operating systems, spooling, which stands for Simultaneous Peripheral Operations On-Line, is a technique
that temporarily stores data (the "spool") in a buffer or secondary storage, allowing a program to continue its
execution without waiting for a slow peripheral device (like a printer) to complete its I/O operation.
Spooling acts as a buffer between a program and a slow peripheral device, enabling efficient use of system
resources.
When a program needs to send data to a peripheral, it doesn't wait for the device to be ready. Instead, it sends
the data to a temporary storage area (the spool).
A dedicated program (the spooler) manages the spool and transfers the data to the peripheral at its own pace.
This allows the program to continue processing other tasks while the peripheral device is busy.
Computer-System Operation:
A modern general-purpose computer system consists of one or more CPUs and a number of device controllers connected
through a common bus that provides access to shared memory. Each device controller is in charge of a specific type of
device (for example, disk drives, audio devices, or video displays). For a computer to start running—for instance, when it
is powered up or rebooted—it needs to have an initial program to run. This initial program, or bootstrap program, tends
to be simple. Typically, it is stored within the computer hardware in read-only memory (ROM) or electrically erasable
programmable read-only memory (EEPROM), known by the general term firmware. The bootstrap program must know
how to load the operating system and how to start executing that system. The bootstrap program must locate the
operating-system kernel and load it into memory. Once the kernel is loaded and executing, it can start providing services
to the system and its users. Some services are provided outside of the kernel, by system programs that are loaded into
memory at boot time to become system processes, or system daemons that run the entire time the kernel is running.
Once this phase is complete, the system is fully booted, and the system waits for some event to occur.
The occurrence of an event is usually signaled by an interrupt from either the hardware or the software. Hardware may
trigger an interrupt at any time by sending a signal to the CPU, usually by way of the system bus. Software may trigger an
interrupt by executing a special operation called a system call (also called a monitor call). When the CPU is interrupted, it
stops what it is doing and immediately transfers execution to a fixed location. The fixed location usually contains the
starting address where the service routine for the interrupt is located. The interrupt service routine executes; on
completion, the CPU resumes the interrupted computation.
What is Kernel and Shell in operating system?
A kernel is an important part of an OS that manages system resources. It also acts as a bridge between the software and
hardware of the computer. It is one of the first program which is loaded on start-up. The Kernel is also responsible for
offering secure access to the machine’s hardware for various programs. It also decides when and how long a certain
application uses specific hardware.
The kernel is the fundamental layer that exists between the computer hardware and the software.
It's responsible for interacting with hardware, managing resources like memory, processors, and file systems.
The kernel manages processes, scheduling them and ensuring they run efficiently.
The kernel handles system calls, which are requests from user programs to access hardware resources.
Shell:
The shell provides a user interface (either command-line or graphical) that allows users to interact with the
operating system.
It acts as a command-line interpreter, taking user input, interpreting it, and executing the corresponding
actions.
The shell acts as a bridge between the user and the kernel, translating user commands into system calls that
the kernel can understand and execute.
System Calls:
System calls provide the means for a user program to ask the operating system to perform tasks reserved for the operating
system on the user program’s behalf. System calls provide an interface to the services made available by an operating
system. For this need two separate modes of operation: user mode and kernel mode (also called supervisor mode, system
mode, or privileged mode). A bit, called the mode bit, is added to the hardware of the computer to indicate the current
mode: kernel (0) or user (1). With the mode bit, we can distinguish between a task that is executed on behalf of the
operating system and one that is executed on behalf of the user. e. However, when a user application requests a service
from the operating system (via a system call), the system must transition from user to kernel mode to fulfill the request.
Execution of system call
Process control
end, abort
load, execute
create process, terminate process
get process attributes, set process attributes
wait for time wait event, signal event
allocate and free memory
File management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
Device management
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Layered Structure of operating system:
There are six layers in the layered operating system. A diagram demonstrating these layers is as
follows
1. Hardware: This layer interacts with the system hardware and coordinates with all the
peripheral devices used, such as a printer, mouse, keyboard, scanner, etc. These types of
hardware devices are managed in the hardware layer.
The hardware layer is the lowest and most authoritative layer in the layered operating system
architecture. It is attached directly to the core of the system.
2. CPU Scheduling: This layer deals with scheduling the processes for the CPU. Many scheduling
queues are used to handle processes. When the processes enter the system, they are put into
the job queue.
The processes that are ready to execute in the main memory are kept in the ready queue. This
layer is responsible for managing how many processes will be allocated to the CPU and how
many will stay out of the CPU.
3. Memory Management: Memory management deals with memory and moving processes from
disk to primary memory for execution and back again. This is handled by the third layer of the
operating system. All memory management is associated with this layer. There are various
types of memories in the computer like RAM, ROM.
If you consider RAM, then it is concerned with swapping in and swapping out of memory.
When our computer runs, some processes move to the main memory (RAM) for execution, and
when programs, such as calculator, exit, it is removed from the main memory.
4. Process Management: This layer is responsible for managing the processes, i.e., assigning the
processor to a process and deciding how many processes will stay in the waiting schedule. The
priority of the processes is also managed in this layer. The different algorithms used for process
scheduling are FCFS (first come, first served), SJF (shortest job first), priority scheduling, round-
robin scheduling, etc.
5. I/O Buffer: I/O devices are very important in computer systems. They provide users with the
means of interacting with the system. This layer handles the buffers for the I/O devices and
makes sure that they work correctly.
Suppose you are typing from the keyboard. There is a keyboard buffer attached with the
keyboard, which stores data for a temporary time. Similarly, all input/output devices have some
buffer attached to them. This is because the input/output devices have slow processing or
storing speed. The computer uses buffers to maintain the good timing speed of the processor
and input/output devices.
6. User Programs: This is the highest layer in the layered operating system. This layer deals with
the many user programs and applications that run in an operating system, such as word
processors, games, browsers, etc. You can also call this an application layer because it is
concerned with application programs.
Monolithic Kernel system:
Monolithic Kernel runs all the basic system services like process management, Memory management, I/O
communication, and interrupt handling, file system, etc in kernel space. In this type of Kernel approach, the entire
operating system runs as a single program in kernel mode.
All OS related component integrate together as a single module in kernel space. Large in size, and execution is very
fast. Difficult to find error. If user want to add new service, user have to modify the entire OS. Security issues will
always exist, as there is no isolation among the various services of OS. eg. DOS, LINUX.
Microkernel system:
A Microkernel is the most important part for correct implementation of an operating system. All non essential
components are moved from kernel space to user space.
Only essential component such as IPC, memory management and scheduling are included in kernel space. If any one
of the service fails, rest of the OS will work fine. Small in size, execution is slow as compared to monolithic kernel.
New services can be added easily, and easy to debug. Eg. Mac, Windows.
Functions of Operating System:
Process Management
A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O
devices, to accomplish its task. The operating system is responsible for the following activities in connection with
process management. ✦ Process creation and deletion. ✦ process suspension and resumption. ✦ Provision of
mechanisms for: process synchronization process communication.
Main-Memory Management:
Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data
shared by the CPU and I/O devices. Main memory is a volatile storage device. It loses its contents in the case of
system failure. The operating system is responsible for the following activities in connections with memory
management: Keep track of which parts of memory are currently being used and by whom. Decide which
processes to load when memory space becomes available. Allocate and de-allocate memory space as needed.
File Management:
A file is a collection of related information defined by its creator. Commonly, files represent programs (both source
and object forms) and data. The operating system is responsible for the following activities in connections with file
management: ✦ File creation and deletion. ✦ Directory creation and deletion. ✦ Support of primitives for
manipulating files and directories. ✦ Mapping files onto secondary storage. ✦ File backup on stable (nonvolatile)
storage media.
I/O System Management:
The I/O system consists of: ✦ A buffer-caching system ✦ A general device-driver interface ✦ Drivers for specific
hardware devices.
Secondary-Storage Management:
Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently,
the computer system must provide secondary storage to back up main memory. Most modern computer systems
use disks as the principle on-line storage medium, for both programs and data. The operating system is responsible
for the following activities in connection with disk management: ✦ Free space management ✦ Storage allocation ✦
Disk scheduling.
Network Management: Manages network protocols and functions, enabling the OS to establish network
connections and transfer data.
Security & Protection: Ensures system protection against unauthorized access and other security threats through
authentication, authorization, and encryption.
Storage Structure:
The CPU can load instructions only from memory, so any programs to run must be stored there. General-purpose
computers run most of their programs from rewritable memory, called main memory (also called random-access memory,
or RAM). Main memory commonly is implemented in a semiconductor technology called dynamic random-access memory
(DRAM). Computers use other forms of memory as well. We have already mentioned read-only memory, ROM) and
electrically erasable programmable read-only memory, EEPROM). Because ROM cannot be changed, only static programs,
such as the bootstrap program described earlier, are stored there. The immutability of ROM is of use in game cartridges.
EEPROM can be changed but cannot be changed frequently and so contains mostly static programs. Ideally, we want the
programs and data to reside in main memory permanently. This arrangement usually is not possible for the following two
reasons:
1. Main memory is usually too small to store all needed programs and data permanently.
2. Main memory is a volatile storage device that loses its contents when power is turned off or otherwise lost.
Thus, most computer systems provide secondary storage as an extension of main memory. The main requirement for
secondary storage is that it be able to hold large quantities of data permanently. The most common secondary-storage
device is a magnetic disk, which provides storage for both programs and data. Most programs (system and application)
are stored on a disk until they are loaded into memory. The wide variety of storage systems can be organized in a hierarchy:
I/O Structure:
A large portion of operating system code is dedicated to managing I/O, both because of its importance to the reliability
and performance of a system and because of the varying nature of the devices. Recall from the beginning of this section
that a general-purpose computer system consists of multiple devices, all of which exchange data via a common bus.
Fig: Interrupt driven i/o
Operating System services:
Following are the five services provided by operating systems to the convenience of the users.
1. Program Execution The purpose of computer systems is to allow the user to execute programs. So the operating
system provides an environment where the user can conveniently run programs. Running a program involves the
allocating and deallocating memory, CPU scheduling in case of multiprocessing.
2. I/O Operations Each program requires an input and produces output. This involves the use of I/O. So the operating
systems are providing I/O makes it convenient for the users to run programs.
3. File System Manipulation The output of a program may need to be written into new files or input taken from
some files. The operating system provides this service.
4. Communications The processes need to communicate with each other to exchange information during execution.
It may be between processes running on the same computer or running on the different computers.
Communications can be occur in two ways: (i) shared memory or (ii) message passing.
5. Error Detection An error is one part of the system may cause malfunctioning of the complete system. To avoid
such a situation operating system constantly monitors the system for detecting the errors. This relieves the user
of the worry of errors propagating to various part of the system and causing malfunctioning. Following are the
three services provided by operating systems for ensuring the efficient operation of the system itself.
6. Resource allocation When multiple users are logged on the system or multiple jobs are running at the same time,
resources must be allocated to each of them. Many different types of resources are managed by the operating
system.
7. Accounting The operating systems keep track of which users use how many and which kinds of computer
resources. This record keeping may be used for accounting (so that users can be billed) or simply for accumulating
usage statistics.
8. Protection When several disjointed processes execute concurrently, it should not be possible for one process to
interfere with the others, or with the operating system itself. Protection involves ensuring that all access to system
resources is controlled. Security of the system from outsiders is also important. Such security starts with each user
having to authenticate him to the system, usually by means of a password, to be allowed access to the resources.
Resident Monitor:
In computing, a resident monitor is a type of system software program that was used in many early computers
from the 1950s to 1970s. It can be considered a precursor to the operating system. The name is derived from a
program which is always present in the computer's memory, thus being resident. Because memory was very
limited on those systems, the resident monitor was often little more than a stub that would gain control at the end
of a job and load a non-resident portion to perform required job cleanup and setup tasks.
On a general-use computer using punched card input, the resident monitor governed the machine before and
after each job control card was executed, loaded and interpreted each control card, and acted as a job sequencer
for batch processing operations. The resident monitor could clear memory from the last used program (with the
exception of itself), load programs, search for program data and maintain standard input-output routines in
memory. Resident monitor functionality is present in many embedded systems.
Bare Machine:
In operating systems, a "bare machine" (also called a bare-metal machine) refers to a
computer system without an operating system (OS) installed. This means that software,
including applications, runs directly on the hardware, interacting with it directly, without
any intermediary OS layer.
Elaboration:
Direct Hardware Interaction:
Bare metal programs bypass the abstraction layers of an OS, directly interacting with the
hardware (CPU, memory, peripherals, etc.).
No OS Overhead:
This direct interaction eliminates the overhead of an OS, which can improve performance
and reduce resource consumption.
Applications as Bootable Software:
In a bare machine setup, the application itself is often responsible for booting and
loading itself into memory, as there's no OS to handle those tasks.
Examples:
Commonly used in embedded Bare metal applications are codded systems, firmware,
and specialized applications where high performance and direct control over hardware
are essential, such as real-time systems.
Security:
Bare metal applications can be inherently more secure because they lack the potential
vulnerabilities associated with OS components.
Contrast with Virtual Machines:
Unlike virtual machines, which run an OS that manages the hardware, a bare machine
directly interfaces with the hardware.