Os Notes
Os Notes
UNIT 1
1.1Introduction of Operating System
An operating system acts as an intermediary between the user of a computer and
computer hardware. The purpose of an operating system is to provide an
environment in which a user can execute programs conveniently and efficiently.
An operating system is a software that manages computer hardware. The hardware
must provide appropriate mechanisms to ensure the correct operation of the
computer system and to prevent user programs from interfering with the proper
operation of the system.
Operating System – Definition:
An operating system is a program that controls the execution of application programs
and acts as an interface between the user of a computer and the computer
hardware.
A more common definition is that the operating system is the one program running
at all times on the computer (usually called the kernel), with all else being application
programs.
An operating system is concerned with the allocation of resources and services, such
as memory, processors, devices, and information. The operating system
correspondingly includes programs to manage these resources, such as a traffic
controller, a scheduler, a memory management module, I/O programs, and a file
system.
Functions of Operating system :
Convenience: An OS makes a computer more convenient to use.
Efficiency: An OS allows the computer system resources to be used efficiently.
Ability to Evolve: An OS should be constructed in such a way as to permit the
effective development, testing, and introduction of new system functions at the
same time without interfering with service.
Throughput: An OS should be constructed so that It can give maximum
throughput(Number of tasks per unit time).
Components of Operating System:
2
keyboard, keeping track of files and directories on the disk, sending output to the
display screen, and controlling peripheral devices.
OS is designed to serve two basic purposes:
It controls the allocation and use of the computing System’s resources among the
various user and tasks.
It provides an interface between the computer hardware and the programmer that
simplifies and makes it feasible for coding, creation, debugging of application
programs.
The Operating system must support the following tasks. The tasks are:
Provides the facilities to create, modification of programs and data files using an
editor.
Access to the compiler for translating the user program from high-level language to
machine language.
Provide a loader program to move the compiled program code to the computer’s
memory for execution.
Provide routines that handle the details of I/O programming.
I/O System Management –
The module that keeps track of the status of devices is called the I/O traffic
controller. Each I/O device has a device handler that resides in a separate process
associated with that device.
The I/O subsystem consists of
A memory Management component that includes buffering caching and spooling.
A general device driver interface.
Drivers for specific hardware devices.
Assembler –
The input to an assembler is an assembly language program. The output is an object
program plus information that enables the loader to prepare the object program for
execution. At one time, the computer programmer had at his disposal a basic
machine that interpreted, through hardware, certain fundamental instructions. He
5
would program this computer by writing a series of ones and Zeros (Machine
language), place them into the memory of the machine.
Compiler –
The High-level languages- examples are FORTRAN, COBOL, ALGOL, and PL/I are
processed by compilers and interpreters. A compiler is a program that accepts a
source program in a “high-level language “and produces a corresponding object
program. An interpreter is a program that appears to execute a source program as if
it was machine language. The same name (FORTRAN, COBOL, etc.) is often used to
designate both a compiler and its associated language.
Loader –
A Loader is a routine that loads an object program and prepares it for execution.
There are various loading schemes: absolute, relocating, and direct-linking. In
general, the loader must load, relocate and link the object program. The loader is a
program that places programs into memory and prepares them for execution. In a
simple loading scheme, the assembler outputs the machine language translation of a
program on a secondary device and a loader places it in the core. The loader places
into memory the machine language version of the user’s program and transfers
control to it. Since the loader program is much smaller than the assembler, those
make more core available to the user’s program.
-----------------------------------------------------------------------------------------------------------------
------------------------------
1.2 Views of os : User view and System view
User View
The user view depends on the system interface that is used by the users. The
different types of user view experiences can be explained as follows −
System View
According to the computer system, the operating system is the bridge between
applications and hardware. It is most intimate with the hardware and is used to
control it as required.The different types of system view for operating system can be
explained as follows:
The system views the operating system as a resource allocator. There are many
resources such as CPU time, memory space, file storage space, I/O devices etc.
that are required by processes for execution. It is the duty of the operating
system to allocate these resources judiciously to the processes so that the
computer system can run as smoothly as possible.
The operating system can also work as a control program. It manages all the
processes and I/O devices so that the computer system works smoothly and
there are no errors. It makes sure that the I/O devices work in a proper
manner without creating problems.
Operating systems can also be viewed as a way to make using hardware easier.
Computers were required to easily solve user problems. However it is not easy
to work directly with the computer hardware. So, operating systems were
developed to easily communicate with the hardware.
An operating system can also be considered as a program running at all times
in the background of a computer system (known as the kernel) and handling all
7
the application programs. This is the definition of the operating system that is
generally followed.
1.3 Operating system Operation
Dual mode
An error in one program can adversely effect many processes, it might modify data of
another program, or also can effect the operating system. For example, if a process
stuck in infinite loop then this infinite loop could effect correct operation of other
processes. So to ensure the proper execution of the operating system there are two
modes of operation:
User mode –
When the computer system run user application like creating a text document or
using any application program, then the system is in user mode. When the user
application requests for a service from the operating system or an interrupt occurs or
system call, then there there will be a transition from user to kernel mode to fulfill
the requests.
Note: To switch from kernel mode to user mode, mode bit should be 1.
Given below image describes what happen interrupt occurs:
Kernel Mode –
When system boots then hardware starts in kernel mode and when operating system
is loaded then it start user application in user mode. To provide protection to the
hardware, we have privileged instructions which execute only in kernel mode. If user
attempt to run privileged instruction in user mode then it will treat instruction as
illegal and traps to OS. Some of the privileged instructions are:
1.Handling Interrupt
8
Timer
We must ensure that the operating system maintains control over the CPU. We must
prevent a user program from getting stuck in an infinite loop or not calling system
services and never returning control to the operating system. To accomplish this goal,
we can use a timer. A timer can be set to interrupt the computer after a specified
period. The period may be fixed (for example, 1/60 second) or variable (for example,
from 1 millisecond to 1 second). A variable timer is generally implemented by a fixed-
rate clock and a counter.
The operating system sets the counter. Every time the clock ticks, the counter is
decremented. When the counter reaches 0, an interrupt occurs. For instance, a 10-bit
counter with a 1-millisecond clock allows interrupts at intervals from 1 millisecond to
1,024 milliseconds, in steps of 1 millisecond. Before turning over control to the user,
the operating system ensures that the timer is set to interrupt. If the timer interrupts,
control transfers automatically to the operating system, which may treat the
interrupt as a fatal error or may give the program more time. Clearly, instructions
that modify the content of the timer are privileged. Thus, we can use the timer to
prevent a user program from running too long. A simple technique is to initialize a
9
counter with the amount of time that a program is allowed to run. A program with a
7-minute time limit, for example, would have its counter initialized to 420.
Every second, the timer interrupts and the counter is decremented by 1. As long as
the counter is positive, control is returned to the user program. When the counter
becomes negative, the operating system terminates the program for exceeding the
assigned time limit.
1.4 Special Purpose system
1. Batch Operating System –
This type of operating system does not interact with the computer directly. There is
an operator which takes similar jobs having the same requirement and group them
into batches. It is the responsibility of the operator to sort jobs with similar needs.
The major benefit of working with these types of the operating system is that it is
always possible that one user can access the files or software which are not actually
present on his system but some other system connected within this network i.e.,
remote access is enabled within the devices connected in that network.
Advantages of RTOS:
Maximum Consumption: Maximum utilization of devices and system, thus
more output from all the resources
Task Shifting: The time assigned for shifting tasks in these systems are very
less. For example, in older systems, it takes about 10 microseconds in shifting
one task to another, and in the latest systems, it takes 3 microseconds.
Focus on Application: Focus on running applications and less importance to
applications which are in the queue.
13
Android. It is basically designed for iPhone, iPad, and iPod Touch. In terms of security,
iOS is more secure than Android. The iOS interface depends upon the direct
manipulation by using touch gestures. Evolution of iOS: The concept of iPhone was
innovated by the Steve Jobs in 2005The latest version of iOS is 11 and it is available
for iPhone 5S, iPad Pro, iPad Mini2 and sixth generation iPod Touch.
Examples
iPhone OS 1:Year-2007
iPhone OS 2:Year-2008
iPhone OS 3:Year-2009
iOS 4:Year-2010
iOS 5:Year-2011
iOS 10:Year-2016
iOS 11:Year-2017
Features Of iOS: iOS contains home screen, touchID for apps, icloud drive, health,
Siri(personal assistant), Safari(browser), multitasking, message, interactive
notification, camera, icloud photo library, game center, bluetooth, calls, accessibility,
voice recognition, face recognition, battery usage indicator, Wi-Fi etc.
Advantages Of iOS:
In terms of performance iOS is magnificent and smooth.
iOS generate less heat while processing as compare to Android.
iOS are best for gaming and business purposes.
iOS provides excellent security.
It provides Jailbreaking for customization.
It provides good face recognition security.
Disadvantages of iOS:
iOS is depends upon iOS devices.
iOS is not an open source.
The price of iOS devices are very high.
The cost of iOS apps are very high.
iOS devices supports only single SIM.
iOS applications are larger in size as compared to other mobile platforms.
16
Linux architecture:
Advantages of Linux
The main advantage of Linux, is it is an open-source operating system. This
means the source code is easily available for everyone and you are allowed to
contribute, modify and distribute the code to anyone without any permissions.
In terms of security, Linux is more secure than any other operating system. It
does not mean that Linux is 100 percent secure it has some malware for it but
is less vulnerable than any other operating system. So, it does not require any
anti-virus software.
The software updates in Linux are easy and frequent.
17
Various Linux distributions are available so that you can use them according to
your requirements or according to your taste.
Linux is freely available to use on the internet.
It has large community support.
It provides high stability. It rarely slows down or freezes and there is no need
to reboot it after a short time.
It maintain the privacy of the user.
The performance of the Linux system is much higher than other operating
systems. It allows a large number of people to work at the same time and it
handles them efficiently.
It is network friendly.
The flexibility of Linux is high. There is no need to install a complete Linux suit;
you are allowed to install only required components.
Linux is compatible with a large number of file formats.
It is fast and easy to install from the web. It can also install on any hardware
even on your old computer system.
It performs all tasks properly even if it has limited space on the hard disk.
Disadvantages of Linux
It is not very user-friendly. So, it may be confusing for beginners.
It has small peripheral hardware drivers as compared to windows.
BSD
BSD refers to the Berkeley Software Distribution OS. The BSD OS is a Unix-based OS.
The pure BSD OS was officially supported from 1977 to 1995. It passed through four
major forms and various revisions of each over that time. Although the original BSD
operating system is no longer in use, the underlying BSD model lives on in various
forms. Later versions of BSD and any operating systems based on it no longer adhere
to the basic UNIX standards, and they are officially classified as Unix-like operating
systems.
Here, you will learn about all BSD-based operating systems. These BSD based
operating systems are as follows
FreeBSD Operating System
OpenBSD Operating System
NetBSD Operating System
18
Unix
UNIX is a powerful Operating System initially developed by Ken Thompson, Dennis
Ritchie at AT&T Bell laboratories in 1970. It is prevalent among scientific, engineering,
and academic institutions due to its most appreciative features like multitasking,
flexibility, and many more. In UNIX, the file system is a hierarchical structure of files
and directories where users can store and retrieve information using the files.
19
Architecture of unix
================================================================
==================
UNIT2
3. I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver
software. Drivers hide the peculiarities of specific hardware devices from the
users.
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.
A file system is normally organized into directories for easy navigation and usage.
These directories may contain files and other directions. Following are the major
activities of an operating system with respect to file management −
services of the operating system. System calls are the only entry points into the
kernel system. All programs needing resources must use system calls.
Windows Unix
2.3 OS components
24
1. Process Management
The process management component is a procedure for managing many processes
running simultaneously on the operating system. Every running software application
program has one or more processes associated with them.
For example, when you use a search engine like Chrome, there is a process running
for that browser program.
Process management keeps processes running efficiently. It also uses memory
allocated to them and shutting them down when needed.
The execution of a process must be sequential so, at least one instruction should be
executed on behalf of the process.
2. File Management
25
The operating system has the following important activities in connection with file
management:
File and directory creation and deletion.
Give permissions For manipulating files and directories.
Mapping files onto secondary storage.
Backup files on stable storage media.
be accessed directly by the CPU. It is costly and hence has a lower storage capacity.
However, for a program to be executed, it must be in the main memory.
4. Secondary-Storage Management
The most important task of a computer system is to execute programs. These
programs help you to access the data from the main memory during execution. This
memory of the computer is very small to store all data and programs permanently.
The computer system offers secondary storage to back up the main memory.
Today modern computers use hard drives/SSD as the primary storage of both
programs and data. However, the secondary storage management also works with
storage devices, such as USB flash drives and CD/DVD drives. Programs like
assemblers and compilers are stored on the disk until it is loaded into memory, and
then use the disk is used as a source and destination for processing.
27
User management
There are three types of accounts on a Unix system −
Root account
This is also called superuser and would have complete and unfettered control of the
system. A superuser can run any commands without any restriction. This user should
be assumed as a system administrator.
System accounts
System accounts are those needed for the operation of system-specific components
for example mail accounts and the sshd accounts. These accounts are usually needed
for some specific function on your system, and any modifications to them could
adversely affect the system.
User accounts
User accounts provide interactive access to the system for users and groups of users.
General users are typically assigned to these accounts and usually have limited access
to critical system files and directories.
Unix supports a concept of Group Account which logically groups a number of
accounts. Every account would be a part of another group account. A Unix group
plays important role in handling file permissions and process management.
Managing Users and Groups
There are four main user administration files −
/etc/passwd − Keeps the user account and password information. This file holds the
majority of information about accounts on the Unix system.
/etc/shadow − Holds the encrypted password of the corresponding account. Not all
the systems support this file.
/etc/group − This file contains the group information for each account.
/etc/gshadow − This file contains secure group account information.
Check all the above files using the cat command.
The following table lists out commands that are available on majority of Unix systems
to create and manage accounts and groups −
29
Sr.No.Command Description
1 useradd Adds accounts to the system