0% found this document useful (0 votes)
25 views

Operating System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Operating System

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Unit-1

Chapter-1: Introduction to Operating Systems


What is Operating System?
An operating system is a software program that acts as an intermediary between a user of a
computer and the computer hardware.
The purpose of an operating system is to provide an environment in which a user can
execute programs.
Ex: Windows, Linux, Unix, Macintosh, MS-DOS.
Goals of an Operating system:

 Ability to Evolve: Execute user programs and make solving user problems easier.
 Convenience: Make the computer system convenient to user.
 Efficiency: Use the computer hardware in an efficient manner.

Components of Computer:
An operating system is an important part of almost every computer system. A computer system
can be divided roughly into four components: the hardware, the operating system, the
application programs, and the users.
1. Hardware – provides basic computing resources (CPU, memory, I/O devices).
2. Operating system – controls and coordinates the use of the hardware among the various
application programs for the various users.
3. Application programs – define the ways in which the system resources are used to solve the
computing problems of the users (compilers, database systems, video games, business
programs).
4. Users (people, machines, other computers).

B.V.Raju college, Vishnupur, Bhimavaram 1


Unit-1

Basic Operating System functions and services


Operating System Functions:
 Memory Management
 Processor Management
 Device Management
 File Management
 Security
 Job accounting
 Error detection
 Coordination between other software and users

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 track 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.

B.V.Raju college, Vishnupur, Bhimavaram 2


Unit-1

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.

Other Important Activities


Following are some of the important activities that an Operating System performs −
 Security − By means of password and similar other techniques, it prevents unauthorized
access to programs and data.
 Control over system performance − Recording delays between request for a service
and response from the system.
 Job accounting − Keeping track of time and resources used by various jobs and users.
 Error detecting aids − Production of error messages, and other debugging and error
detecting aids.
 Coordination between other software and users − Coordination and assignment of
compilers, interpreters, assemblers and other software to the various users of the
computer systems.

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. These operating system services
are provided for the convenience of the programmer, to make the programming task easier.

The list of Operating system services that are helpful to the user:

1. Program Execution
2. I/O Operation
3. File system manipulation
4. Communication
5. Error Detection
6. Resource allocation
7. Accounting
8. Protection and Security

B.V.Raju college, Vishnupur, Bhimavaram 3


Unit-1

Services of operating systems are:


1. 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).

2. I/O operations:

 A running program may require I/O, which may involve a file or an I/O device.
 For efficiency and protection, users usually cannot control I/O devices directly.
 Therefore, the operating system must provide a means to do I/O.

3. File-system manipulation:

 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.

B.V.Raju college, Vishnupur, Bhimavaram 4


Unit-1

4. Communications:

 There are many circumstances in which one process needs to exchange information
with another process.
 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.

5. 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 connection failure on a network, or lack of paper in the
printer), and in the user program.
 For each type of error, the operating system should take the appropriate action to ensure
correct and consistent computing.

6. 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.
 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.

7. 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.

8. 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.

B.V.Raju college, Vishnupur, Bhimavaram 5


Unit-1

 Security of the system from outsiders is also important. Such security starts with
requiring each user to authentication.

Types of Operating Systems

1. Batch Systems
2. Multiprogramming System
3. Time Sharing System
4. Parallel Systems
5. Real time Systems
6. Distributed Systems
7. PDA (Personal Digital Assistant)

1. Batch Systems:
 In this type of system, there is no direct interaction between user and the computer.
 The user has to submit a job (written on cards or tape) to a computer operator.
 Then computer operator places a batch of several jobs on an input device.
 Jobs are batched together by type of languages and requirement.
 Then a special program, the monitor, manages the execution of each program in the
batch.
 The monitor is always in the main memory and available for execution

Advantages of Batch Operating System:


 Multiple users can share the batch systems
 The idle time for the batch system is very less

Disadvantages of Batch Operating System:


 The computer operators should be well known with batch systems
 Batch systems are hard to debug
B.V.Raju college, Vishnupur, Bhimavaram 6
Unit-1

 The other jobs will have to wait for an unknown time if any job fails

2. Multiprogramming Systems:
 In this, the operating system picks up and begins to execute one of the jobs from memory.
 Once this job needs an I/O operation operating system switches to another job (CPU and
OS always busy).
 Jobs in the memory are always less than the number of jobs on disk(Job Pool).
 If several jobs are ready to run at the same time, then the system chooses which one to
run through the process of CPU Scheduling.
 In Non-multiprogrammed system, there are moments when CPU sits idle and does not do
any work.
 In Multiprogramming system, CPU will never be idle and keeps on processing.

Main Memory layout for a multiprogramming system.

3. Time-Sharing Operating Systems:

Each task is given some time to execute so that all the tasks work smoothly.
Each user gets the time of CPU as they use a single system. These systems are also
known as Multitasking Systems. The task can be from a single user or different users
also. The time that each task gets to execute is called quantum. After this time interval
is over OS switches over to the next task.

B.V.Raju college, Vishnupur, Bhimavaram 7


Unit-1

Advantages of Time-Sharing OS:

 Each task gets an equal opportunity


 CPU idle time can be reduced

Disadvantages of Time-Sharing OS:


 Reliability problem
 One must have to take care of the security and integrity of user programs and data

4.Parallel Systems:
Many systems are single processor systems i.e., they have only one CPU. However,
Multiprocessor Systems (also known as Parallel Systems) have more than one processor in
close communication, sharing bus, the clock and sometimes memory and peripheral
devices. Hence, these systems can also be called “Tightly Coupled Systems”. The
advantages of parallel systems are

 Increased throughput: The execution of the processes will be completed very fast
when compare with single processor system.
 Economy of scale: Multiprocessor systems save money while compare to the
multiple single processor systems because sharing peripheral devices, memory,
secondary storage, common bus etc.,
 Increased reliability: If we have ten processors and one fails, then each of the
remaining nine processors must pick up the share of a job and complete it. So the
system works with less speed.

B.V.Raju college, Vishnupur, Bhimavaram 8


Unit-1

Fig. Parallel Execution

5.Real-Time Operating Systems


Real time systems are used when there is a fixed time constraint on the
processor operation on data. These systems are used in scientific applications i.e.,
engineering, medicine etc., Here sensors bring the data to the computer. The computer
analyzes the data and applying some process on it. So they can control the application. There
are two types of real time systems. They are hard and soft real time systems.
a) Hard Real time System: In this system, we have well defined fixed time constraints and
processing must be done in these constraints.
b) Soft Real time System: In this system, we have less strength and time constraints. Here
we don’t have any deadlines.
Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging
systems, industrial control systems, weapon systems, robots, air traffic control systems, etc.

6.Distributed System:
Various autonomous interconnected computers communicate with each other using a
shared communication network. Independent systems possess their own memory unit and
CPU. These are referred to 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 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.

B.V.Raju college, Vishnupur, Bhimavaram 9


Unit-1

Advantages of Distributed Operating System:


 Failure of one will not affect the other network communication, as all systems are
independent from each other
 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

Disadvantages of Distributed Operating System:

Failure of the main network will stop the entire communication

8.PDA (Hand-held Devicces):

1. Continuing on down to smaller and smaller systems, we come to handheld


computers. A handheld computer or PDA (personal digital assistant) is a small
computer that fits in a pocket and performs a small number of functions, such as
electronics address book and memo pad.
2. One major difference between handhelds and personal computer OS is that the
former do not have multi gigabyte hard disks.
3. Two of the most popular operating systems for handhelds are Symbian OS and
Palm OS.

Processor and User Modes: (Dual-Mode or Multimode Operation)

 In order to ensure the proper execution of the operating system, we must be able to
distinguish between the execution of operating-system code and user defined code.
 At the very least, we need two separate modes of operation: user mode and kernel mode
B.V.Raju college, Vishnupur, Bhimavaram 10
Unit-1

(also called supervisor mode, system mode, or privileged mode).


 A bit, called the mode bit, is added to the hardware of the computer to indicate the
current mode: kernel (0) or user (1).

 With the mode bit, we can distinguish between a task that is executed on behalf of the
operating system and one that is executed on behalf of the user.
 When the computer system is executing on behalf of a user application, the system is in
under user mode.
 However, when a user application requests a service from the operating system (via a
system call), the system must transition from user to kernel mode to fulfill the request.

 At system boot time, the hardware starts in kernel mode.


 The operating system is then loaded and starts user applications in user mode.
 Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel
mode (that is, changes the state of the mode bit to 0). Thus, whenever the operating
system gains control of the computer, it is in kernel mode.
 The system always switches to user mode (by setting the mode bit to 1) before passing
control to a user program.
 The dual mode of operation provides us with the means for protecting the operating
system from errant users— and errant users from one another.
B.V.Raju college, Vishnupur, Bhimavaram 11
Unit-1

 The hardware allows privileged instructions to be executed only in kernel mode.


 If an attempt is made to execute a privileged instruction in user mode, the hardware
does not execute the instruction but rather treats it as illegal and traps it to the operating
system.

Kernel Mode:
 When CPU is in kernel mode, the code being executed can access any memory address
and any hardware resource.
 Hence kernel mode is a very privileged and powerful mode.
 If a program crashes in kernel mode, the entire system will be halted.

User Mode:
 When CPU is in user mode, the programs don’t have direct access to memory and
hardware resources.
 In user mode, if any program crashes, only that particular program is halted.
 That means the system will be in a safe state even if a program in user mode crashes.
 Hence, most programs in an OS run in user mode.
Kernel:

Kernel is the part of the operating system, it interacts directly with the hardware of a
computer, through device that is build into the kernel. The main functions of the kernel are to
manage computer memory, to control access to the computer, to maintain the file system, to
handle interrupts, to handle errors, to perform input and output services, and to allocate the
resources of the computer among users.

USERR

SYSTEM CALLS:
System call: When a program in user mode requires access to RAM or a hardware resource,
it must ask the kernel to provide access to that resource. This is done via something called
a system call. System calls provide an interface between a process and the operating system.
B.V.Raju college, Vishnupur, Bhimavaram 12
Unit-1

When a program makes a system call, the mode is switched from user mode to kernel mode. This
is called a context switch. These calls are generally available as routines written in C and C++.

Generally, system calls are made by the user level programs in the following situations:
 Creating, opening, closing and deleting files in the file system.
 Creating and managing new processes.
 Creating a connection in the network, sending and receiving packets.
 Requesting access to a hardware device, like a mouse or a printer.

fig. The handling of a user application invoking the open() system call
Types of System Calls:
There are mainly five types of system calls. They are:
1. Process control
2. File manipulation
3. Device manipulation
4. Information maintenance

B.V.Raju college, Vishnupur, Bhimavaram 13


Unit-1

5. Communications

1. Process Control:

The list of process control system calls are:

 create process( ) is used to create a new process.


 terminate process( ) is used to terminate the process that have already created.
 load( ) and execute( ): A process or job executing one program may want to
load( ) and execute( ) another program.
 end( ): It is used when a running program needs to be able to halt its execution
normally.
 abort( ): It is used when a running program needs to be able to halt its execution
abnormally.

 wait event( ) After creating new processes, it may need to wait for a certain
amount of time to pass to finish its execution.
 signal event( ): The jobs or processes signals when an event has occurred.
 get process attributes( ) and set process attributes( ) are used to control execution
of a process.
2. File Management:

 We first need to be able to create() and delete() files.

B.V.Raju college, Vishnupur, Bhimavaram 14


Unit-1

 Once the file is created, we need to open() it and to use it.


 We may also read(), write(), or reposition() (rewind or skip to the end of the file,
for example).
 Finally, we need to close() the file, indicating that we are no longer using it.

3. 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 control can be returned to
the user process. Otherwise, the process will have to wait until sufficient
resources are available.
4. Information Maintenance:

 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 of the operating system, the amount of free memory
or disk space, and so on.
5. Communication:

 There are two common models of inter process communication:


1. The message passing model and
2. 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.
 In the shared-memory model, processes use shared memory create() and
shared memory attach() system calls to create and gain access to regions of
memory owned by other processes.

B.V.Raju college, Vishnupur, Bhimavaram 15


Unit-1

System Programs:

System programs are also known as system utilities provide a more convenient environment
for program development and execution. The system programs can be divided into several
categories:
1. File Manipulation: These programs create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories.
2. Status information: Some programs simply ask the system for the date, time, amount of
available memory or disk space, number of users, or similar status information. That
information is then formatted, and is printed to the terminal or other output device or file.

3. File modification: Several text editors may be available to create and modify the content
of files stored on disk or tape.

4. Programming-language support: Compilers, assemblers and interpreters for common


programming languages (such as FORTRAN, COBOL, Pascal, BASIC, C and LISP) are
often provided to the user with the operating system.
5. Program loading and execution: Once a program is assembled or compiled, it must be
loaded into memory to be executed. The system may provide absolute loaders,
relocatable loaders, linkage editors.
6. Communications: These programs provide the mechanism for creating virtual
connections among processes, users, and different computer systems. They allow users to
send messages to each other’s screens, to send larger messages as electronic mail, or to
transfer files from one machine to another.
7. Application programs: Most operating systems are supplied with programs that are
useful to solve common problems, or to perform common operations. Such programs
include web browsers, word processors and text formatters, spread sheets, database
systems and games.

OPERATING SYSTEM STRUCTURES:

1. Simple Structure:
 There are several commercial systems that don‘t have a well- defined structure such
operating systems begin as small, simple & limited systems and then grow beyond
their original scope.
 MS-DOS (Microsoft Disk Operating System) is an example of such system. It was
not divided into modules carefully. In MS-DOS, the interfaces and levels of
functionality are not well separated.
 So MS-DOS was vulnerable to malicious programs, causing the entire system to
crash when user programs fail.
 Another example of limited structuring is the UNIX operating system.

B.V.Raju college, Vishnupur, Bhimavaram 16


Unit-1

The following diagram shows MS-DOS layer structure:

2. Layered Approach:
In the layered approach, the OS is broken into a number of layers (levels) each built on
top of lower layers. The bottom layer (layer 0) is the hardware & top most layer
(layer N) is the user interface.
 The main advantage of the layered approach is modularity.
 The layers are selected such that each uses functions (or operations) & services of
only lower layer.
 This approach simplifies debugging & system verification, i.e. the first layer can be
debugged without concerning the rest of the system. Once the first layer is
debugged, its correct functioning is assumed while the 2nd layer is debugged & so
on.

 If an error is found during the debugging of a particular layer, the error must be on
that layer because the layers below it are already debugged. Thus the design &
implementation of the system are simplified when the system is broken down into
layers.
 The layer approach was first used in the operating system. It was defined in six layers.
 The major difficulty with the layered approach involves appropriately defining the
various layers. Because a layer can use only lower-level layers, careful planning is
necessary.

B.V.Raju college, Vishnupur, Bhimavaram 17


Unit-1

Layers Functions
5 User Program
4 I/O Management
3 Process Communication
2 Memory Management
1 CPU Scheduling
0 Hardware
3. Micro-kernel Approach:
In the UNIX operating system, the kernel became large and it is difficult to manage.
But in the microkernel approach, all non essential components are removed from
kernel and implementing them as system and user-level programs that creates a smaller
kernel. The benefits of microkernel is
 easier to extend a microkernel
 easier to port the operating system to new architectures
 more reliable (less code is running in kernel mode)

Widows NT uses layered structure. Windows NT is designed to run various


applications including native Win32 (native Windows applications), OS/2 and POSIX. It
provides a server that runs in user space for each application type. Client programs for each
application type also run in user space. The kernel coordinates message passing between
client applications and application servers. The client-server structure of Windows NT is
described in the following diagram:

B.V.Raju college, Vishnupur, Bhimavaram 18


Unit-1

B.V.Raju college, Vishnupur, Bhimavaram 19

You might also like