Os Unit-1
Os Unit-1
UNIT-1
Overview of operating Systems
1
OPERATING SYSTEM FUNCTIONS or Operating systems operations
Process Management
Storage Management
OS provides uniform, logical view of information
storage Abstracts physical properties to logical storage
unit - file
Each medium is controlled by device (i.e., disk drive, tape drive)
Varying properties include access speed, capacity, data-transfer rate, access method(sequential
or random)
File-System management
Files usually organized into directories
Access control on most systems to determine who can access what
I/O Subsystem
One purpose of OS is to hide peculiarities of hardware devices from the
user I/O subsystem responsible for
Memory management of I/O including buffering (storing data temporarily while it is being
transferred), caching (storing parts of data in faster storage for performance), spooling (the
overlapping of output of one job with input of other jobs)
General device-driver interface
Drivers for specific hardware devices
Protection – any mechanism for controlling access of processes or users to resources definedby the OS.
Security – defense of the system against internal and external attacks
Huge range, including denial-of-service, worms, viruses, identity theft, theft of
service Systems generally first distinguish among users, to determine who can do
what
User identities (user IDs, security IDs) include name and associated number, one
peruser 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, thenalso
associated with each process, file.
Types of Operating Sysem or Computing environments:
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.
Types of Operating Systems: Some of the widely used operating systems are as follows-
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.
4
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 The idle time for batch system is
very less
It is easy to manage large work repeatedly in batch
systems Disadvantages of Batch Operating System:
The computer operators should be well known with batch
systems Batch systems are hard to debug
It is sometime costly
The other jobs will have to wait for an unknown time if any job fails
Examples of Batch based Operating System: Payroll System, Bank Statements etc.
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.
1. Single-Processor System
2. Multiprocessor System
3. Clustered System
8
1. Single-Processor System:-
Most systems use a single processor.
On a single-processor system, there is one main CPU capable of executing a general-purpose instruction
set, including instructions from user processes.
Almost all systems have other special-purpose processors as well. They may come in the form of
device-specific processors, such as disk, keyboard, and graphics controllers;
On mainframes, they may come in the form of more general-purpose processors, such as I/O processors
that move data rapidly among the components of the system.
All of these special-purpose processors run a limited instruction set and do not run user processes.
Sometimes they are managed by the operating system, in that the operating system sends them
information about their next task and monitors their status.
For example, a disk-controller microprocessor receives a sequence of requests from the main CPU
and implements its own disk queue and scheduling algorithm.
This arrangement relieves the main CPU of the overhead of disk scheduling.
PCs contain a microprocessor in the keyboard to convert the keystrokes into codes to be sent to the CPU.
In other systems or circumstances, special-purpose processors are low-level components built into the hardware.
The operating system cannot communicate with these processors; they do their jobs autonomously.
The use of special-purpose microprocessors is common and does not turn a single-processor system into
a multiprocessor.
If there is only one general-purpose CPU, then the system is a single-processor system.
2. Multiprocessor System:-
Although single-processor systems are most common, 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.
Multiprocessor systems have three main advantages:
1. Increased throughput. Throughput is increased by increasing the number of processors, we expect to get
more work done in less time. The speed-up ratio with N processors is not N, however; rather, it is less than N.
When multiple processors cooperate on a task, a certain amount of overhead is incurred in keeping all the parts
working correctly.
2. Economy of scale. Multiprocessor systems can cost less than equivalent multiple single-processor
systems, because they can share peripherals, mass storage, and power supplies. If several programs operate on
the same set of data, it is cheaper to store those data on one disk and to have all the processors share them than
to have many computers with local disks and many copies of the data.
3. Increased reliability. If functions can be distributed properly among several processors, then the failure of
one processor will not halt the system, only slow it down. If we have ten processors and one fails, then each
of the remaining nine processors can pick up a share of the work of the failed processor. Thus, the entire
system runs only 10 percent slower, rather than failing altogether.
The multiple-processor systems in use today are of two types.
i. Asymmetric multiprocessing
ii. Symmetric multiprocessing (SMP)
Asymmetric multiprocessing:-
In asymmetric multiprocessing which each processor is assigned a specific task.
A master processor controls the system; the other processors either look to the master for instruction or
have predefined tasks. This scheme defines a master-slave relationship.
The master processor schedules and allocates work to the slave processors.
9
Each processor has its own memory address space. Symmetric multiprocessing
(SMP) Each processor runs an identical copy of OS. These copies communicate with
each other.
Each processor performs all tasks within the operating system. SMP means that all processors are peers;
no master-slave relationship exists between processors.
The benefit of this model is that many processes can run simultaneously—N processes can run if there are
N CPUs—without causing a significant deterioration of performance.
3. Clustered System
Another type of multiple-CPU system is the clustered system. Like multiprocessor systems, clustered
systems gather together multiple CPUs to accomplish computational work.
Clustered systems differ from multiprocessor systems, however, in that they are composed of two or
more individual systems coupled together
The generally accepted definition is that clustered computers share storage and are closely linked via a local-
area network (LAN) or a faster interconnect such as InfiniBand.
Clustering is usually used to provide high-availability service; that is, service will continue even if one or
more systems in the cluster fail. High availability is generally obtained by adding a level of redundancy in the
system. A layer of cluster software runs on the cluster nodes. Each node can monitor one or more of the
others (over the LAN). If the monitored machine fails, the monitoring machine can take ownership of its
storage and restart the applications that were running on the failed machine. The users and clients of the
applications see only a brief interruption of service.
Clustering can be structured asymmetrically or symmetrically.
In asymmetric clustering, one machine is in hot-standby mode while the other is running the applications.
The hot-standby host machine does nothing but monitor the active server. If that server fails, the hot-
standby host becomes the active server.
In symmetric mode, two or more hosts are running applications, and are monitoring each other. This mode
is obviously more efficient, as it uses all of the available hardware. It does require that more than one
application be available to run.
10
\
advantages
Control. Many people prefer open source software because they have more control over that
kind of software. They can examine the code to make sure it's not doing anything they don't
want it to do, and they can change parts of it they don't like. Users who aren't programmers
also benefit from open source software, because they can use this software for any purpose
they wish—not merely the way someone else thinks they should.
Training. Other people like open source software because it helps them become
better progra mmers. Because open source code is publicly accessible, students can easily
study it as they learn to make better software. Students can also share their work with
others, inviting comment and critique, as they develop their skills. When people discover
mistakes in programs' source code, they can share those mistakes with others to help them
avoid making those same mistakes themselves.
Security. Some people prefer open source software because they consider it more secure
and stable than proprietary software. Because anyone can view and modify open source
software, someone might spot and correct errors or omissions that a program's original authors
might have missed. And because so many programmers can work on a piece of open source
software without asking for permission from original authors, they can fix, update, and
upgrade open source software more quickly than they can proprietary software.
11
Stability. Many users prefer open source software to proprietary software for important, long-
term projects. Because programmers publicly distribute the source code for open source software,
users relying on that software for critical tasks can be sure their tools won't disappear or fall into
disrepair if their original creators stop working on them. Additionally, open source software tends
to both incorporate and operate according to open standards.
Community. Open source software often inspires a community of users and developers to
form around it. That's not unique to open source; many popular applications are the subject of
meetups and user groups. But in the case of open source, the community isn't just a fanbase
that buys in (emotionally or financially) to an elite user group; it's the people who produce, test,
use, promote, and ultimately affect the software they love
GNU/Linux (various versions or distributions include Debian, Fedora, Gentoo, Ubuntu and Red Hat)
-operating system
FreeBSD - operating system
Android - mobile phone platform
Operating-System Services
An operating system provides an environment for the execution of programs. It provides certain services
to programs and to the users of those programs. The specific services provided, of course, differ from one
operating system to Another. These operating-system services are provided for the convenience of the
programmer, to make the programming task easier.
One set of operating-system services provides functions that are helpful to the user.
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 program to allow entering and editing of commands). 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).
12
• 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 . 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 programs include permissions management to allow or deny
access to files or directories based on file ownership.
• 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 network. Communications may be implemented via shared memory or through message
passing, in which packets of information are moved between processes by the operating system.
• Error detection. The operating system needs to be constantly aware of possible errors. 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 tape, 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).
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. Many different types of resources are managed by the operating
system. 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, modems, 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 modems and network adapters, from invalid access attempts
and to recording all such connections for detection of break-ins.
13
User and Operating-System 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.
User interface
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.
The OS on most computers and smart phones 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 touch screen.
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.
The standard C library provides a portion of the system-call interface for many versions of UNIX and
Linux. As an example, lot's assume a C program invokes the printf () statement. The C library intercepts
this call and invokes the necessary system call(s) in the operating system—in this instance, the write ()
system call. The C library takes the value returned by write () and passes it back to the user program. This
is shown in above Figure.
File Management
We first need to be able to create and delete files. Either system call requires the name of the file and
perhaps some of the file's attributes. Once the file is created, we need to open it and to use it. We may
also read, write, or reposition (rewinding or skipping to the end of the file, for example). Finally, we need
to close the file, indicating that we are no longer using it.
System calls in File management
create file, delete file
open, close
read, write, reposition
get file attributes, set file attributes
File attributes include the file name, a file type, protection codes, accounting information, and so on. At
least two system calls, get file attribute and set file attribute, are required for this function.
16
Device Management
A process may need several resources to execute—main memory, disk drives, access to files, and so on.
If the resources are available, they can be granted, and controlcan be returned to the user process.
Otherwise, the process will have to wait until sufficient resources are available. The various resources
controlled by the operating system can be thought of as devices. Some of these devices are physical
devices (for example, tapes), while others can be thought of as abstract or virtual devices (for example,
files). If there are multiple users of the system, the system may require us to first request the device, to
ensure exclusive use of it. After we are finished with the device, we release it. These functions
are similar to the open and close system calls for files.
Some System calls are:
request device, release device
read, write, reposition
get device attributes, set device attributes
logically attach or detach devices
Once the device has been requested (and allocated to us), we can read, write, and (possibly) reposition the
device, just as we can with files.
Information Maintenance
Many system calls exist simply for the purpose of transferring information between the user program and
the operating system. For example, most systems have a system call to return the current time and date .
Other system calls may return information about the system, such as the number of current users, the
version number of the operating system, the amount of free memory or disk space, and so on.
Communication
There are two common models of inter process communication:
The message passing model and the shared-memory model.
In the message-passing model, the communicating processes exchange messages with one another to
transfer information. Messages can be exchanged between the processes either directly or indirectly
through a common mailbox. Before communication can take place, a connection must be opened.
In the shared-memory model, processes use shared memory creates and shared memory attaches system
calls to create and gain access to regions of memory owned by other processes. Recall that, normally, the
operating system tries to prevent one process from accessing another process's memory. Shared memory
requires that two or more processes agree to remove this restriction. They can then exchange information
by reading and writing data in the shared areas.
Some System calls are
create, delete communication connection
send, receive messages
transfer status information
attach or detach remote devices
17
System Programs in Operating System
System Programming can be defined as the act of building Systems Software using System
Programming Languages.
1. File Management
2. Status Information
3. File Modification
4. Programming-Language support
5. Program Loading and Execution
Simple Structure
Layered Structure
18
Micro kernel Structure
Modules Structure
Simple Structure
Layered Structure
Systems programs
The kernel
19
20
Micro kernel Structure
The user services and kernel services are implemented in different address space.
Modules Structure
Eg:- Solaris
21
Operating System Debugging
Debugging is the process of finding the problems in a computer system and solving
them. There are many different ways in which operating systems perform debugging.
Log Files
Trace Listings
Profiling
Log Files
The log files record all the events that occur in an operating system.
Event Logs These stores the records of all the events that occur in the execution of a
system.
Transaction Logs store the changes to the data so that the system can recover from
crashes and other errors.
Message Logs These logs store both the public and private messages between the users.
They are mostly plain text files, but in some cases they may be HTML files.
The core dump files contain the memory address space of a process that
terminates unexpectedly.
In the event of a total system failure, the information about the state of the operating
system is captured in crash dump files.
Trace Listings
The trace listing record information about a program execution using logging.
This information is used by programmers for debugging.
Profiling
Profiling is done by monitoring the source code of the required system program using a
code profiler.
22
System Boot
Booting the system is done by loading the kernel into main memory, and starting
its execution.
23
24