Chater-1 Operating Systems Introduction
Chater-1 Operating Systems Introduction
Chater-1 Operating Systems Introduction
Operating System:
An operating system is a program which manages all the computer hardware’s.
It provides the base for application program and acts as an intermediary between a user and the computer
hardware.
The operating system has two objectives such as:
1. The prime objective of operating system is to manage & control the various hardware resources of a
computer system. These hardware resources include processer, memory, and disk space and so on.
2. The second objective is to provide an interactive interface to the user and interpret commands so that it
can communicate with the hardware.
The operating system is very important part of almost every computer system.
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. It initializes all aspects of the
1
system, from CPU registers to device controllers to memory contents. The bootstrap program must know
how to load the operating system and how to start executing that system.
VIEW OF OPERATING SYSTEM SERVICES
User interface. Almost all operating systems have a user interface (UI).This interface can take several
forms. One is a command-line interface (CLI), which uses text commands and a method for entering them
(say, a keyboard for typing in commands in a specific format with specific options). Another is a batch
interface, in which commands and directives to control those commands are entered into files, and those
files are executed. Most commonly, a graphical user interface (GUI) is used. Here, the interface is a
window system with a pointing device to direct I/O, choose from menus, and make selections and a keyboard
to enter text. Some systems provide two or all three of these variations.
Program execution. The system must be able to load a program into memory and to run that program. The
program must be able to end its execution, either normally or abnormally (indicating error).
I/O operations. A running program may require I/O, which may involve a file or an I/O device. For specific
devices, special functions may be desired (such as recording to a CD or DVD drive or blanking a display
screen). For efficiency and protection, users usually cannot control I/O devices directly. Therefore, the
operating system must provide a means to do I/O.
File-system manipulation. The file system is of particular interest. Obviously, programs need to read and
write files and directories. They also need to create and delete them by name, search for a given file, and
list file information. Finally, some operating systems include permissions management to allow or deny
access to files or directories based on file ownership. Many operating systems provide a variety of file
systems, sometimes to allow personal choice and sometimes to provide specific features or performance
characteristics.
Communications. There are many circumstances in which one process needs to exchange information with
another process. Such communication may occur between processes that are executing on the same
computer or between processes that are executing on different computer systems tied together by a computer
2
network. Communications may be implemented via shared memory, in which two or more processes read
and write to a shared section of memory, or message passing, in which packets of information in predefined
formats are moved between processes by the operating system.
Error detection. The operating system needs to be detecting and correcting errors constantly. Errors may
occur in the CPU and memory hardware (such as a memory error or a power failure), in I/O devices (such
as a parity error on disk, a connection failure on a network, or lack of paper in the printer), and in the user
program (such as an arithmetic overflow, an attempt to access an illegal memory location, or a too-great use
of CPU time). For each type of error, the operating system should take the appropriate action to ensure
correct and consistent computing. Sometimes, it has no choice but to halt the system. At other times, it might
terminate an error-causing process or return an error code to a process for the process to detect and possibly
correct. Another set of operating system functions exists not for helping the user but rather for ensuring the
efficient operation of the system itself. Systems with multiple users can gain efficiency by sharing the
computer resources among the users.
Resource allocation. When there are multiple users or multiple jobs running at the same time, resources
must be allocated to each of them. The operating system manages many different types of resources. Some
(such as CPU cycles, main memory, and file storage) may have special allocation code, whereas others
(such as I/O devices) may have much more general request and release code. For instance, in determining
how best to use the CPU, operating systems have CPU-scheduling routines that take into account the speed
of the CPU, the jobs that must be executed, the number of registers available, and other factors. There may
also be routines to allocate printers, USB storage drives, and other peripheral devices.
Accounting. We want to keep track of which users use how much and what kinds of computer resources.
This record keeping may be used for accounting (so that users can be billed) or simply for accumulating
usage statistics. Usage statistics may be a valuable tool for researchers who wish to reconfigure the system
to improve computing services.
Protection and security. The owners of information stored in a multiuser or networked computer system
may want to control use of that information.
When several separate 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
requiring each user to authenticate himself or herself to the system, usually by means of a password, to gain
access to system resources. It extends to defending external I/O devices, including network adapters, from
invalid access attempts and to recording all such connections for detection of break-ins. If a system is to be
protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest
link.
Types of User Interface
Command Line Interface (CLI)
3
A command line interface is a mechanism for interacting with a computer operating system or software
by typing commands to perform specific tasks. This method of instructing a computer to perform a given
task is referred to as "entering" a command. Accept input via keyboard only. Not suitable for beginners.
Examples of command:
Command Description
DIR To display list of files or folder
COPY To copy file or folder
MD To make new folder
CLS To clear screen
Quit To quit
Graphical User Interface (GUI)
•It is a type of user interface which allows people to interact with computer with images rather than text
commands.
•Accept input via keyboard and pointing devices.
•Easy to learn
Elements of Graphical
User Interface
1. Pointer
2. Icons
1. 2.
3. Desktop
4. Windows
5. Menus
Examples of Operating
System
1. MS-DOS 3. 4.
2. Windows
3. MacOS
4. Linux
5. Solaris
6. Android
2. Windows
A freely-distributable open source operating system that runs on a number of hardware platforms.
Linux has become an extremely popular alternative to proprietary operating systems.
First version: Linux (1992)
Latestversion:Linux3.9.6
5. Solaris
Solaris is a UNIX operating system originally developed by Sun Microsystems.
Solaris can be installed from physical media or a network for use on a desktop or server.
Used on server and workstation
Firstversion:Solaris1(1991)
Latestversion:SunOS11.1
6. Android
Android is a Linux-based operating system for mobile devices such as smart phones and tablet
,computers
ItisdevelopedbytheOpenHandsetAlliance,ledbyGoogle,andothercompanies
Firstversion:Android1.0(2008)
Latest version: Android 9
5
What is System Call in Operating System?
A system call is a mechanism that provides the interface between a process and the operating system. It is
a programmatic method in which a computer program requests a service from the kernel of the OS.
System call offers the services of the operating system to the user programs via API (Application
Programming Interface). System calls are the only entry points for the kernel system.
System calls provide an interface to the services made available by an operating system. These calls are
generally available as routines written in C and C++, although certain low-level tasks (for example, tasks
where hardware must be accessed directly) may have to be written using assembly-language instructions.
Let’s first use an example to illustrate how system calls are used: writing a simple program to read data
from one file and copy them to another file. The first input that the program will need is the names of the
two files: the input file and the output file. These names can be specified in many ways, depending on the
operating-system design. One approach is for the program to ask the user for the names. In an interactive
system, this approach will require a sequence of system calls, first to write a prompting message on the
screen and then to read from the keyboard the characters that define the two files. On mouse-based and icon-
based systems, a menu of file names is usually displayed in a window.
The user can then use the mouse to select the source name, and a window can be opened for the destination
name to be specified. This sequence requires many I/O system calls.
Step 1) the processes executed in the user mode till the time a system call interrupts it.
Step 2) after that, the system call is executed in the kernel-mode on a priority basis.
Step 3) Once system call execution is over, control returns to the user mode.,
7
Process Control
File Management
Device Management
Information Maintenance
Communications and
protection
Process Control
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
8
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:
Parameters should be pushed on or popped off the stack by the operating system.
Parameters can be passed in registers.
When there are more parameters than registers, it should be stored in a block, and the block
address should be passed as a parameter to a register.
EXAMPLES OF WINDOWS AND UNIX SYSTEM CALLS
VIRTUAL MACHINES
9
The fundamental idea behind a virtual machine is to abstract the hardware of a single computer (the CPU,
memory, disk drives, network interface cards, and so forth) into several different execution environments,
thereby creating the illusion that each separate environment is running on its own private computer.
Virtual machine implementations involve several components. At the base is the host, the underlying
hardware system that runs the virtual machines. The virtual machine manager (VMM) (also known as a
hypervisor) creates and runs virtual machines by providing an interface that is identical to the host (except
in the case of para virtualization, discussed later). Each guest process is provided with a virtual copy of the
host usually, the guest process is in fact an operating system. A single physical machine can thus run
multiple operating systems concurrently, each in its own virtual machine
10
2. Each of the operating systems that we virtualize is completely independent of the other operating
systems. In this way, in the case that one of the virtual machines stops working, the rest will continue
working without any type of problem.
3. A virtual machine has all the elements available to a real computer. It has a hard disk, RAM, CD-ROM
drive, network card, video card, etc., but unlike a real computer, these elements, instead of being
physical, are virtual.
UTILITIES PROVIDED BY VM
To test operating systems. If all your life you have used Windows and want to try another operating
system, such as Linux Mint, you can do it through a virtual machine. Also the process of an installation in the
virtual machine is extremely easy since we will not have to worry about creating additional partitions in our
hard disk, etc.
To use software that is not available in our operating system. So for example if we are Linux users and
we want to use Photoshop, we can do it through a virtual machine.
Sometimes we have to use software that can only be run on operating systems that are obsolete. So
therefore if we have a program that can only be used in Windows 98, we can create a virtual machine with
Windows 98 and run and use the software without any problem.
We can use virtual machines as a sandbox in order to, for example, execute malicious applications or
open suspicious emails in a controlled and secure environment.
The main drawback with the virtual-machine approach involves disk systems. Let us suppose that the
physical machine has only three disk drives but wants to support seven virtual machines. Obviously, it
cannot allocate a disk drive to each virtual machine, because virtual-machine software itself will need
substantial disk space to provide virtual memory and spooling. The solution is to provide virtual disks.
Advantages:
1. There are no protection problems because each virtual machine is completely isolated from all other
virtual machines.
2. Virtual machine can provide an instruction set architecture that differs from real computers.
3. Easy maintenance, availability and convenient recovery.
Disadvantages:
1. When multiple virtual machines are simultaneously running on a host computer, one virtual machine
can be affected by other running virtual machines, depending on the workload.
2. Virtual machines are not as efficient as a real one when accessing the hardware.
A hypervisor is also known as a Virtual Machine Manager (VMM) and its sole purpose is to allow
multiple “machines” to share a single hardware platform.
11
Some popular hypervisors are VMware ESXi, Xen, Microsoft Hyper-V, VMware Workstation, Oracle
Virtualbox, and Microsoft VirtualPC. All of these allow a user to virtualize one or more operating systems
on a single piece of hardware.
The hypervisor separates the operating system (OS) from the hardware by taking the responsibility of allowing
each running OS time with the underlying hardware. It acts as a traffic cop to allow time to use the CPU,
memory, GPU, and other hardware. Each operating system controlled by the hypervisor is called a guest OS,
and the hypervisor’s operating system, if any, is called the host OS. Because it stands between the guest OS
and hardware you can have as many different guest OSs as your system can handle; you can even have different
types (e.g. Windows, OS X, Linux).
WHAT IS A KERNEL?
The kernel is the central component of a computer operating systems. The only job performed by the kernel
is to the manage the communication between the software and the hardware. A Kernel is at the nucleus of a
computer. It makes the communication between the hardware and software possible. While the Kernel is
the innermost part of an operating system, a shell is the outermost one.
The kernel is a computer program at the core of a computer's operating system with complete control over
everything in the system. It is the "portion of the operating system code that is always resident in memory". It
facilitates interactions between hardware and software components. On most systems, it is one of the first
programs loaded on startup (after the boot loader). It handles the rest of startup as well as input/output requests
from software, translating them into data-processing instructions for the central processing unit. It handles
memory and peripherals like keyboards, monitors, printers, and speakers.
In computing, a shell is a user interface for access to an operating system's services. In general, operating
system shells use either a command-line interface (CLI) or graphical user interface (GUI), depending on a
computer's role and particular operation.
12
Features of Kennel
Types of Kernels
There are many types of kernels that exists, but among them, the two most popular kernels are:
1. Monolithic
A monolithic kernel is a single code or block of the program. It provides all the required services offered by
the operating system. It is a simplistic design which creates a distinct communication layer between the
hardware and software.
2. Microkernels
Microkernel manages all system resources. In this type of kernel, services are implemented in different
address space. The user services are stored in user address space, and kernel services are stored under kernel
address space. So, it helps to reduce the size of both the kernel and operating system.
TYPES OF OPERATING SYSTEMS
An Operating System performs all the basic tasks like managing file, process, and memory. Thus operating
system acts as manager of all the resources, i.e. resource manager. Thus operating system becomes an
interface between user and machine.
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 same requirement and group them into batches. It is the
responsibility of operator to sort the jobs with similar needs.
Advantages of Batch Operating System:
It is very difficult to guess or know the time required by any job to complete. Processors of the batch
systems know how long the job would be when it is in queue
Multiple users can share the batch systems
13
The idle time for batch system is very less
It is easy to manage large work repeatedly in batch systems
14
Examples of Time-Sharing OSs are: Multics, Unix etc.
2. Distributed Operating System
These types of operating system is a recent advancement in the world of computer technology and
are being widely accepted all-over the world and, that too, with a great pace. Various autonomous
interconnected computers communicate each other using a shared communication network. Independent
systems possess their own memory unit and CPU. These are referred as loosely coupled systems or distributed
systems. These system’s processors differ in size and function. The major benefit of working with these types
of 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 on some other system connected within this network i.e., remote access is
enabled within the devices connected in that network.
15
Electronic mail increases the data exchange speed
Since resources are being shared, computation is highly fast and durable
Load on host computer reduces
These systems are easily scalable as many systems can be easily added to the network
Delay in data processing reduces
Disadvantages of Distributed Operating System:
Failure of the main network will stop the entire communication
To establish distributed systems the language which are used are not well defined yet
These types of systems are not readily available as they are very expensive. Not only that the
underlying software is highly complex and not understood well yet
Examples of Distributed Operating System are- LOCUS etc.
4. NETWORK OPERATING SYSTEMS
These systems run on a server and provide the capability to manage data, users, groups, security,
applications, and other networking functions. These type of operating systems allow shared access of files,
printers, security, applications, and other networking functions over a small private network. One more
important aspect of Network Operating Systems is that all the users are well aware of the underlying
configuration, of all other users within the network, their individual connections etc. and that’s why these
computers are popularly known as tightly coupled systems.
Advantages of Network Operating System:
Highly stable centralized servers
Security concerns are handled through servers
New technologies and hardware up-gradation are easily integrated to the system
Server access are possible remotely from different locations and types of systems
Disadvantages of Network Operating System:
Servers are costly
User has to depend on central location for most operations
Maintenance and updates are required regularly
Examples of Network Operating System are: Microsoft Windows Server 2003, Microsoft Windows
Server 2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD etc.
16
5. Real Time Operating System
these types of OSs serves the real-time systems. The time interval required to process and respond to
inputs is very small. This time interval is called response time.
Real-time systems are used when there are time requirements are very strict like missile systems, air traffic
control systems, robots etc.
Two types of Real-Time Operating System which are as follows:
Hard Real Time System
These OSs are meant for the applications where time constraints are very strict and even the shortest
possible delay is not acceptable. These systems are built for saving life like automatic parachutes or
air bags which are required to be readily available in case of any accident. Virtual memory is almost
never found in these systems.
Soft Real-Time Systems:
These OSs are for applications where for time-constraint is less strict.
Advantages of RTOS:
Maximum Consumption: Maximum utilization of devices and system,thus more output from all
the resources
Task Shifting: Time assigned for shifting tasks in these systems are very less. For example in older
systems it takes about 10 micro seconds in shifting one task to another and in latest systems it takes
3 micro seconds.
Focus on Application: Focus on running applications and less importance to applications which are
in queue.
17
Real time operating system in embedded system: Since size of programs are small, RTOS can
also be used in embedded systems like in transport and others.
Error Free: These types of systems are error free.
Memory Allocation: Memory allocation is best managed in these type of systems.
Disadvantages of RTOS:
Limited Tasks: Very few tasks run at the same time and their concentration is very less on few
applications to avoid errors.
Use heavy system resources: Sometimes the system resources are not so good and they are expensive
as well.
Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.
Device driver and interrupt signals: It needs specific device drivers and interrupt signals to response
earliest to interrupts.
Thread Priority: It is not good to set thread priority as these systems are very less prone to switching
tasks.
Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging systems,
industrial control systems, weapon systems, robots, air traffic control systems, etc.
Debian, RedHat (Fedora, RHEL) and Canonical (Ubuntu) are some of the most popular ones today.
18
ICs and multiprogramming
Fourth generation 1980 – present
personal computers
19
Fourth generation 1980 – present
Large Scale Integrated chips
Operating systems for personal computers and work stations were introduced
Ms DOS (Microsoft ) and UNIX (Motorola ) got popularity
Early 1980s: IBM designed IBM PC. Bill Gates had BASIC interpreter and recommended DR as
an OS. Kildall sent subordinate to meeting and refused to sign non-disclosure. Gates was asked for
an OS, bought DOS from Seattle Computer Products and offered IBM DOS/BASIC package.
Renamed it MS -DOS
Network Operating Systems (user sees multiple computers)
Distributed Operating Systems (user sees one processor)
Advantages of Linux over Windows
20