You are on page 1of 48

Operating System

An Operating System (OS) is an interface between a computer user and


computer hardware.
It manages the Computer's memory  and processes, as well as all of
its software and hardware.
It also allows you to communicate with the computer without knowing
how to speak the computer's language. Without an operating system, a
computer is useless.
An operating system performs all the basic tasks like file management,
memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers.
Some popular Operating Systems include Linux Operating System,
Windows Operating System, Apple macOS, Linux, Android and Apple iOS.
operating system's job

computer's operating system (OS) manages all of

the software and hardware on the computer.

Most of the time, there are several different computer programs running at

the same time, and they all need to access your computer's central

processing unit (CPU), memory, and storage.

The operating system coordinates all of this to make sure each program gets

what it needs.
What Operating Systems Do?
Computer system can be divided into four components:

Hardware – provides basic computing resources


CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various applications and
users
Application programs – define the ways in which the system resources are used
to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video games
Users
People, machines, other computers
Computer System Organization

Computer-system operation

One or more CPUs, device controllers connect through common bus


providing access to shared memory
Concurrent execution of CPUs and devices competing for memory
cycles
The operating system then starts executing the first process, such as "init,"

and 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 executing a special operation called a

System Call.
Computer-System Architecture

A computer system may be organized in a number of different ways, which


we can categorize roughly according to the number of general-purpose
processors used.
Single-Processor Systems
Multiprocessor Systems
Clustered Systems
Single-Processor Systems
A single-processor system, there is one main CPU capable of executing a
general-purpose instruction set, including instructions from user processes.

Multiprocessor Systems
Multiprocessor systems (also known as parallel systems or tightly
coupled systems) are growing in importance. Such systems have two or more
processors in close communication, sharing the computer bus and sometimes
the clock, memory, and peripheral devices.

Clustered Systems
Clustered system is an  another type of multiple-CPU system. Clustered
systems differ from multiprocessor systems, however, they are composed of
two or more individual systems coupled together. clustered computers share
storage and are closely linked via a local-area network (LAN).
Operating System Structure

An operating system provides the environment within which programs are


executed.
One of the most important aspects of operating systems is the ability
to multiprogram.
A single user cannot, keep either the CPU or the I/O devices busy at all
times.
Multiprogramming increases CPU utilization by organizing jobs. so that
the CPU always has one to execute.
The operating system keeps several jobs in memory simultaneously.
Time sharing (or multitasking) is a logical extension of
multiprogramming.
In time-sharing systems, the CPU executes multiple jobs by switching
among them, but the switches occur so frequently that the users can interact
with each program while it is running. 
Time sharing requires an interactive computer system, which provides
direct communication between the user and the system.
A time-shared operating system allows many users to share the computer
simultaneously.
A time-shared operating system uses CPU scheduling and
multiprogramming to provide each user with a small portion of a time-
shared computer.
Functions

Memory Management

Processor Management

Device Management

Storage Management

Protection and Security


Memory Management

Memory management refers to management of Primary Memory or Main

Memory.

Main memory is a large array of words or bytes where each word or byte

has its own address.

Main memory provides a fast storage that can be accessed directly by the

CPU.

For a program to be executed, it must in the main memory.


An Operating System does the following activities for memory
management −

Keeps tracks of primary memory, i.e., what part of it are in use by whom,
what part are not in use.

In multiprogramming, the OS decides which process will get memory when


and how much.

Allocates the memory when a process requests it to do so.

De-allocates the memory when a process no longer needs it or has been


terminated.
Processor Management
In multiprogramming environment, the OS decides which process gets the
processor when and for how much time.
This function is called process scheduling
An Operating System does the following activities for processor
management

Keeps tracks of processor and status of process. The program responsible


for this task is known as traffic controller.
Allocates the processor (CPU) to a process.
De-allocates processor when a process is no longer required.
Device Management

An Operating System manages device communication via their respective


drivers. It does the following activities for device management
Keeps tracks of all devices. Program responsible for this task is known as
the I/O controller.
Decides which process gets the device when and for how much time.
Allocates the device in the efficient way.
De-allocates devices.
Storage Management

the operating system provides a uniform, logical view of information

storage.

The operating system abstracts from the physical properties of its storage

devices to define a logical storage unit, the file.

The operating system maps files onto physical media and accesses these

files via the storage devices.


File Management
A file system is normally organized into directories for easy navigation and
usage.
These directories may contain files and other directions.
An Operating System does the following activities for file management

Keeps track of information, location, uses, status etc. The collective


facilities are often known as file system.
Decides who gets the resources.
Allocates the resources.
De-allocates the resources.
Mass-Storage Management
Main memory is too small to accommodate all data and programs, and the

data that it holds are lost when power is lost,

the computer system must provide secondary storage to back up main

memory.

Most modern computer systems use disks as the principal on-line storage

medium for both programs and data.

Most programs—including compilers, assemblers, word processors, editors,

and formatters—are stored on a disk until loaded into memory


The operating system is responsible for the following activities in connection

with disk management:

Free-space management

Storage allocation

Disk scheduling Because secondary storage is used frequently, it must be

used efficiently.
Caching
Caching is an important principle of computer systems.
Information is normally kept in some storage system (such as main
memory).
As it is used, it is copied into a faster storage system—the cache—on a
temporary basis.
When we need a particular piece of information, we first check whether it is
in the cache.
If it is, we use the information directly from the cache;
if it is not, we use the information from the source, putting a copy in the
cache under the assumption that we will need it again soon
I/O Systems
One of the purposes of an operating system is to hide the characteristics of
specific hardware devices from the user.
in UNIX, the characteristics of I/O devices are hidden from the bulk of the
operating system itself by the I/O subsystem.
The I/O subsystem consists of several components
A memory-management component that includes buffering(process of
preloading data into a reserved area of memory), caching, and
spooling(refers to putting data of various I/O jobs in a buffer)
 A general device-driver interface
Drivers for specific hardware devices
Protection and Security

If a computer system has multiple users and allows the concurrent


execution of multiple processes, then access to data must be regulated.
Protection refers to a mechanism which controls the access of programs,
processes, or users to the resources defined by a computer system
We can take protection as a helper to multi programming operating system,
so that many users might safely share a common logical directories or files.
A system can have adequate protection but still be prone to failure and
allow inappropriate.
Consider a user whose authentication information is stolen. His data could
be copied or deleted, even though file and memory protection are working
It is the job of Security to defend a system from external and internal
attacks.
Systems generally first distinguish among users, to determine who can do
what
User identities (user IDs, security IDs) include name and associated
number, one per user
User ID then associated with all files, processes of that user to
determine access control
Group identifier (group ID) allows set of users to be defined and
controls managed, then also associated with each process, file
Kernel data structures
Kernel is a computer program that is the heart and core of an Operating
System.
Since the Operating System has control over the system so,
the Kernel also has control over everything in the system.
It is the "portion of the operating system code that is always resident in
memory", and facilitates interactions between hardware and software
components.
kernel data structures are very important as they store data about the current
state of the system.
For example, if a new process is created in the system, a kernel data
structure is created that contains the details about the process.
Many standard programming data structures used to represent Kernal DS

Singly linked list

Doubly linked list

Circular linked list


Operating System - Services
An Operating System provides services to both the users and to the
programs.
It provides programs an environment to execute.
It provides users the services to execute the programs in a convenient
manner.

Following are a few common services provided by an operating system −

Program execution
I/O operations
File System manipulation
Communication
Error Detection
Resource Allocation
Protection
Program execution:

Loads a program into memory.


Executes the program.
Handles program's execution.
Provides a mechanism for process synchronization.
Provides a mechanism for process communication.
Provides a mechanism for deadlock handling.

I/O Operation:
An Operating System manages the communication between user and
device drivers.

I/O operation means read or write operation with any file or any
specific I/O device.
Operating system provides the access to the required I/O device when
required.
File system manipulation:

Program needs to read a file or write a file.


The operating system gives the permission to the program for operation
on file.
Permission varies from read-only, read-write, denied and so on.
Operating System provides an interface to the user to create/delete
files.
Operating System provides an interface to the user to create/delete
directories.
Operating System provides an interface to create the backup of file
system.
Communication:

Two processes often require data to be transferred between them


Both the processes can be on one computer or on different computers,
but are connected through a computer network.
Communication may be implemented by two methods, either by
Shared Memory or by Message Passing.
Error handling:

The OS constantly checks for possible errors.


The OS takes an appropriate action to ensure correct and consistent
computing.
Resource Management

The OS manages all kinds of resources using schedulers.


CPU scheduling algorithms are used for better utilization of CPU.
Protection:

The OS ensures that all access to system resources is controlled.


The OS ensures that external I/O devices are protected from invalid access
attempts.
The OS provides authentication features for each user by means of
passwords.
User and OS Interface

An operating system is software that manages computer hardware and

software.

It supplies an interface for the user and important utilities for managing the

computer.

The OS provides a user interface (UI), an environment for the user to

interact with the machine.

The UI is either graphical or text-based.


Graphical user interface (GUI)
The OS on most computers and smartphones provides an environment
with tiles, icons and/or menus.
This type of interface is called the graphical user interface (GUI) because
the user interacts with images through a mouse, keyboard or touchscreen.
Command line interface (CLI)
An OS also provides a method of interaction that is non-graphical, called
the command line interface (CLI).
This is a text-only service with feedback from the OS appearing in text.
Using a CLI requires knowledge of the commands available on a particular
machine.
Dual Mode operations in OS
There are two modes of operation in the operating system These are user
mode and kernel mode.
User Mode:
The system is in user mode when the operating system is running a user application
such as handling a text editor.
The transition from user mode to kernel mode occurs when the application requests
the help of operating system or an interrupt or a system call occurs.
The mode bit is set to 1 in the user mode. It is changed from 1 to 0 when switching
from user mode to kernel mode.
Kernel Mode:
The system starts in kernel mode when it boots and after the operating system is
loaded, it executes applications in user mode.
There are some privileged instructions that can only be executed in kernel mode.
These are interrupt instructions, input output management etc
system call

A system call is a mechanism that provides the interface between a process

and the operating system

A system call is a way for programs to interact with the operating system.

A computer program makes a system call when it makes a request to the

operating system’s kernel.

System call provides the services of the operating system to the user

programs via Application Program Interface(API)


Why do we need System Calls?
Following are situations which need system calls in OS:

Reading and writing from files demand system calls.

If a file system wants to create or delete files, system calls are required.

System calls are used for the creation and management of new processes.

Network connections need system calls for sending and receiving packets.

Access to hardware devices like scanner, printer, need a system call.


Types of System calls

Here are the five types of system calls used in OS:

Process Control

File Management

Device Management

Information Maintenance

Communications
Process Control

This system calls perform the task of process creation, process termination,

etc.

Functions:

End and Abort

Load and Execute

Create Process and Terminate Process

Wait and Signed Event

Allocate and free memory


File Management

File management system calls handle file manipulation jobs like creating

a file, reading, and writing, etc.

Functions:

Create a file

Delete file

Open and close file

Read, write, and reposition

Get and set file attributes


Device Management

Device management does the job of device manipulation like reading

from device buffers, writing into device buffers, etc.

Functions

Request and release device

Logically attach/ detach devices

Get and Set device attributes


Information Maintenance

It handles information and its transfer between the OS and the user

program.

Functions:

Get or set time and date

Get process and device attributes


Communication:

These types of system calls are specially used for interprocess

communications.

Functions:

Create, delete communications connections

Send, receive message

Help OS to transfer status information

Attach or detach remote devices


Operating System Structure

Simple Structure:
Many commercial operating systems do not have well-defined structures.

Frequently, such systems started as small, simple, and limited systems and

then grew beyond their original scope.

MS-DOS is an example of such a systems.

It was originally designed and implemented by a few people who had no

idea that it would become so popular.


Layered Approach

The operating system is divided into a number of layers (levels), each built

on top of lower layers.

The bottom layer (layer 0), is the hardware; the highest (layer N) is the user

interface.

With modularity, layers are selected such that each uses functions

(operations) and services of only lower-level layers


System Boot
When power initialized on system, execution starts at a fixed memory location
ROM used to hold initial boot code
Operating system must be made available to hardware so hardware can start it
Small piece of code – bootstrap loader, stored in ROM or EEPROM locates
the kernel, loads it into memory, and starts it
Sometimes two-step process where boot block at fixed location loaded by
ROM code, which loads bootstrap loader from disk
Common bootstrap loader, GRUB, allows selection of kernel from multiple disks,
versions, kernel options
Kernel loads and system is then running

You might also like