Os Unit1
Os Unit1
Os Unit1
UNIT-1
Introduction
An Operating System (OS) is an interface between a computer user and
computer hardware.
An operating system is a software which 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.
Examples of Operating System are –
• Windows (GUI based, PC)
• GNU/Linux (Personal, Workstations, ISP, File and print server, Three-tier client/Server)
• macOS (Macintosh), used for Apple’s personal computers and work stations (MacBook,
iMac).
• Android (Google’s Operating System for smartphones/tablets/smartwatches)
• iOS (Apple’s OS for iPhone, iPad and iPod Touch)
Definitions
An operating system is a program that acts as an interface between the user and the
computer hardware and controls the execution of all kinds of programs.
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,
memory management module, I/O programs, and a file system.
Operating systems are there from the very first computer generation and they
keep evolving with time. In this chapter, we will discuss some of the important
types of operating systems which are most commonly used.
Batch operating system
The users of a batch operating system do not interact with the computer
directly. Each user prepares his job on an off-line device like punch cards and
submits it to the computer operator. To speed up processing, jobs with similar
needs are batched together and run as a group. The programmers leave their
programs with the operator and the operator then sorts the programs with
similar requirements into batches.
The problems with Batch Systems are as follows −
• Problem of reliability.
• Question of security and integrity of user programs and data.
• Problem of data communication.
Distributed operating System
Distributed systems use multiple central processors to serve multiple realtime
applications and multiple users. Data processing jobs are distributed among
the processors accordingly.
The processors communicate with one another through various
communication lines (such as high-speed buses or telephone lines). These are
referred as loosely coupled systems or distributed systems. Processors in a
distributed system may vary in size and function. These processors are
referred as sites, nodes, computers, and so on.
The advantages of distributed systems are as follows −
• With resource sharing facility, a user at one site may be able to use the
resources available at another.
• Speedup the exchange of data with one another via electronic mail.
• If one site fails in a distributed system, the remaining sites can
potentially continue operating.
• Better service to the customers.
• Reduction of the load on the host computer.
• Reduction of delays in data processing.
Network operating System
A Network Operating System runs on a server and provides the server the
capability to manage data, users, groups, security, applications, and other
networking functions. The primary purpose of the network operating system
is to allow shared file and printer access among multiple computers in a
network, typically a local area network (LAN), a private network or to other
networks.
Examples of network operating systems include Microsoft Windows Server
2003, Microsoft Windows Server 2008, UNIX, Linux, Mac OS X, Novell
NetWare, and BSD.
The advantages of network operating systems are as follows −
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.
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 Interrupts
2. To switch from user mode to kernel mode.
3. Input Output management.
Advantages
• Batch processing takes much of the work of the operator to the
computer.
• Increased performance as a new job get started as soon as the previous
job is finished, without any manual intervention.
Disadvantages
Advantages
An Operating System provides services to both the users and to the programs.
• Program execution
• I/O operations
• File System manipulation
• Communication
• Error Detection
• Resource Allocation
• Protection
Program execution
Operating systems handle many kinds of activities from user programs to
system programs like printer spooler, name servers, file server, etc. Each of
these activities is encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use). Following are the major activities
of an operating system with respect to program management −
• 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
A file represents a collection of related information. Computers can store files
on the disk (secondary storage), for long-term storage purpose. Examples of
storage media include magnetic tape, magnetic disk and optical disk drives
like CD, DVD. Each of these media has its own properties like speed, capacity,
data transfer rate and data access methods.
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 −
System Call
1) Process Control:
• A running program needs to be able to stop execution either normally or
abnormally.
• When execution is stopped abnormally, often a dump of memory is
taken and can be examined with a debugger.
• Following are functions of process control:
i. end, abort ii.
load, execute
iii. create process, terminate process iv. get
process attributes, set process attributes v. wait for
time vi. wait event, signal event vii. allocate and free
memory 2) 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. Finally, we need to close the file, indicating
that we are no longer using it.
• We may need these same sets of operations for directories if we have a
directory structure for organizing files in the file system.
• In addition, for either files or directories, we need to be able to
determine the values of various attributes and perhaps to reset them if
necessary. File attributes include the file name, a file type, protection
codes, accounting information, and so on Functions:
o create file, delete file o
CreateProcess() fork()
exit()
ExitProcess() wait()
WaitForSingleObject()
Process Control
CreateFile() open()
read()
ReadFile() write()
close()
WriteFile()
CloseHandle()
File Manipulation
SetConsoleMode() ioctl()
read()
ReadConsole() write()
WriteConsole()
Device Manipulation
GetCurrentProcessID() getpid()
alarm()
SetTimer() sleep()
Sleep()
Information Maintenance
CreatePipe() pipe()
shmget()
CreateFileMapping() mmap()
MapViewOfFile()
Communication
Protection
SetFileSecurity() chmod()
InitlializeSecurityDescriptor() umask()
SetSecurityDescriptorGroup() chown()
Structure
Simple Structure
• Operating systems such as MS-DOS and the original UNIX did not have well-defined
structures.
• There was no CPU Execution Mode (user and kernel), and so errors in applications
could cause the whole system to crash.
Monolithic Approach
• Functionality of the OS is invoked with simple function calls within the kernel, which is
one large program.
• Device drivers are loaded into the running kernel and become part of the kernel.
A monolithic kernel, such as Linux and other Unix systems.
Layer Approach:
This structures the operating system by removing all nonessential portions of the
kernel and implementing them as system and user level programs.