0% found this document useful (0 votes)
29 views25 pages

OS Unit-1 Notes

The document provides an overview of operating systems, detailing their purpose as an interface between users and computer hardware, and outlining various types such as batch, multiprogramming, and real-time operating systems. It explains the dual-mode operation of user and kernel modes, emphasizing their roles in protecting the operating system and managing resources. Additionally, it describes the main components of an operating system, including process, memory, file, and I/O device management, along with their respective functions.

Uploaded by

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

OS Unit-1 Notes

The document provides an overview of operating systems, detailing their purpose as an interface between users and computer hardware, and outlining various types such as batch, multiprogramming, and real-time operating systems. It explains the dual-mode operation of user and kernel modes, emphasizing their roles in protecting the operating system and managing resources. Additionally, it describes the main components of an operating system, including process, memory, file, and I/O device management, along with their respective functions.

Uploaded by

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

CMR Technical Campus

UNIT-I
Operating System - Introduction, Structures - Simple Batch, Multiprogrammed,
Time-shared,PersonalComputer,Parallel,DistributedSystems,Real-TimeSystems,
Systemcomponents, OperatingSystem services, System Calls.

1. INTRODUCTION TO OPERATING SYSTEMS

Operating Systems is the interface between the user and the computer hardware.

Operating system goals:

• Convenience:An OS makes acomputer more convenient to use.

• Efficiency:An OS allows the computer resources to be used in an efficient


manner.

• Abilitytoevolve:An OS is designed to permit new system functions.

Fig : Abstract view of the components of a computer system

Computer system can be divided into four components:

Syeda Sumaiya Afreen pg. 1


CMR Technical Campus

• Hardware : Provides basic computing resources such as CPU, memory, I/O

devices.

• Operating system: Controls and coordinates use of hardware among various

applications and users.

• Application programs : Define the ways in which the system resources are

used to solve the computing problems of the users such as Word processors,
compilers, web browsers, database systems, video games

• Users: People, machines, other computers

Dual-Mode 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. The approach taken by most computer systems is to provide
hardware support that allows us to differentiate among various modes of
execution.

At the very least, we need two separate modes of operation: user mode and
kernel mode (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 are able to 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 user mode. However, when a user
application requests a service from the operating system (via a system call), it
must transition from user to kernel mode to fulfill the request. This is shown in
Figure 1.8.

Syeda Sumaiya Afreen pg. 2


CMR Technical Campus

Fig: Transition from User mode to Kernel mode

KernelMode:

• AllOSrelatedfunctionsgetexecutedin kernelmode.Themode bit=0.

• WhenCPUisinkernelmode,thecodebeingexecutedcanaccessanymemor
yaddressand anyhardwareresource.
• Hencekernelmodeisaveryprivilegedandpowerfulmode.

• If aprogramcrashesinkernelmode, the entiresystemwillbehalted.

UserMode
• Alluserapplicationsgetexecutedinusermode only.Themodebit= 1.
• WhenCPUisinusermode,theprogramsdon'thavedirectaccesstomemory
andhardwareresources.
• Inuser mode, ifanyprogram crashes, onlythatparticular program is
halted.
• Thatmeansthesystem willbeinasafestate evenifaprogramin
usermodecrashes.

As we shall see, this architectural enhancement is useful for many other


Syeda Sumaiya Afreen pg. 3
CMR Technical Campus

aspects of system operation as well. 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. We
accomplish this protection by designating some of the machine instructions that
may cause harm as privileged instructions. 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. The
instruction to switch to user mode is an example of a privileged instruction.
Some other examples include I/O control, timer management, and interrupt
management.

2. TYPES OF OPERATING SYSTEMS

Following are some of the most widely used types of Operating system.

• SimpleBatchSystem
• MultiprogrammingSystem
• TimeSharingSystems
• MultiprocessorSystem
• DistributedOperatingSystem
• ParallelProcessingSystem

Syeda Sumaiya Afreen pg. 4


CMR Technical Campus

• Real-timeOperatingSystem

• PersonalComputerOS

• HandheldSystem

i. Batch Operating System: In this type of system, there is no direct interaction


betweenuser and the computer. The user has to submit a job (written on cards or
tape) to a computeroperator. Then computer operatorgroup similar jobsinto
batches and gives toan inputdevice. Then a special program called the monitor,
manages the execution of each program inthe batch. It follows serial processing.
When the current job execution completes, then onlynext job is assigned to the
CPU for execution. After executing all the jobs in a batch one aftertheother, then
select other batch of jobs forexecution.
PROCESSA PROCESSB PROCESSC

RUN WAI RUN RU WA RU WA RU RU WA RUN


T N IT N IT N N IT

0 3 5 7 11 13 15 17 19 21 23 27

Syeda Sumaiya Afreen pg. 5


CMR Technical Campus

ii. Multiprogramming OS: The processes ready for execution are loaded into the
mainmemory. The OS selects one of these processes and assigns it to the CPU.
Whenever theexecuting process needs to wait for any operation like I/O, the OS
selects another processfrom the job queue and assigns it to the CPU. Latter, when
a partially executed process gets achance to execute, it resumes the execution
from where it stopped previously. This is showninthebelow diagram. This way,
theCPU is kept busyand thethroughput increases.

iii. Time-Sharing Operating Systems: This was introduced in the 1960s when
computerwas too expensive. The solution was to allow many users to use one
computer by providingeach user one time-slot. Each user sit in front of one
terminal and all the terminals are connected to one computer.The time sharing
operating system executes each user task in a given fixed time slot and then
switch to next user task execution. This process is repeated until all tasks are
executed.

Syeda Sumaiya Afreen pg. 6


CMR Technical Campus

iv. Multiprocessor System: A Multiprocessor system consists of several


processors that’s has a common physical memory.In this system all process or
operate under single operating system and provide higher computing power.
Each processor can execute oneprocess simultaneously. If possible, system

divides a single task into many subtasks and thenthesesubtasks can beexecuted
in parallelon different processors.
v. Distributed Operating System: A collection of physically separated
independent computers linked together using the network and works as single
system is called distributed system. All the nodes(computers) in this system
communicate with each other and controlled by the distributed operating system
software.
There are two types of distributed operatingsystems:
a) Client-ServerSystems

b) Peer-to-PeerSystems

Client-Server Systems:Centralized system act as server which takes requests


from theclients and sends back the response to the client systems. The general

Syeda Sumaiya Afreen pg. 7


CMR Technical Campus

structure of a client-serversystem is depictedin thefigurebelow:

Peer-to-Peer Systems: In this model, clients and servers are not distinguished
from oneanother; instead, all nodes (computers) within the system are considered
peers. Each nodemay act as either a client or a server, depending on whether it is
requesting or providing aservice. Peer-to-peer systems offer an advantage over
traditional client-server systems. In aclient-server system, the server is a
bottleneck; but in a peer-to-peer system, all the nodes canacts as a server.
Therefore the load of the server is distributed among all the nodes. This
typeofsystem is also knownas looselycoupled system.

vi. Parallel Processing Systems:Parallel processing systems are designed to speed


up theexecution of programs by dividing the program into multiple parts and
processing these parts simultaneously .Parallel systems can be designed in three
ways:
1. Single computer with multiple processors (also known as Multi processor

system).

2. A set of computers connected by a network to form a parallel processing

cluster(also known as Distributed system).


3. A combination of both(1) and (2).

Parallel systems are more difficult to program than computers with a single

Syeda Sumaiya Afreen pg. 8


CMR Technical Campus

processor because the processes of multiple CPUs must be coordinated and


synchronized. Several models for connecting processors and memory modules
exist, and each topology requires a different programming model.Flynn has
classified the computer systems based on parallelism in the instructions and in
the data streams into four types.These are:
1. Single instruction stream,single data stream(SISD).

2. Single instruction stream,multiple data stream(SIMD).

3. Multiple instruction streams,single data stream(MISD).

4. Multipleinstructionstream,multipledatastream(MIMD).

The above classification of parallel computing system is focused in terms of


two independent factors: the number of data streams that can be simultaneously
processed, and the number of instruction streams that can be simultaneously
processed. Out of the four types of Flynn classifications, only two of them are
relevant to parallel computers. These are SIMD and MIMD computers. A
parallel computer may be a supercomputer with hundreds or thousands of
processors or may be a network of workstations.

vii. Real Time Operating System: A real-time operating system (RTOS) is an OS


thatguarantees applications to be executed within a specified time bound. There
are two types ofReal-TimeOperatingSystem. Theyare:
1. Hard Real-Time Operating System: A process should be executed in given
deadline.The deadline should not be crossed.In this type of OS,maximum
process or time is allocated to critical operations and completes them on time.
Preemption time for HardReal-Time Operating System is almost less than few
microseconds.
Examples are Airbagcontrol in cars,anti-lock brake, engine control system,etc.

Syeda Sumaiya Afreen pg. 9


CMR Technical Campus

2. SoftReal-TimeOperatingSystem:A process might not be executed in the


given deadline. The execution may be completed even after the deadline
without harming the system.In this type of RTOS, the critical task will get
priority over other tasks,but no guarantee of completing it in a defined time.

Examples are a digital camera, automatic washing machines,etc.

viii. Personal computer operating system:Personal computer operating system is


madeonly for personal. Personal computers are intended to be operated directly
by an end user,rather than by a computer expert or technician. Only single user
can use the computer at anytime. The laptops, computer systems, tablets etc. are
personal computers and the operating system such as
windows,Linux,android,etc.are personal computer operating system.Personal
computer operating system can be used for your personal purposes, for example,
tochat with friends, reading some articles from internet, designing your website,
programming something,watching some videos and movies,listening to some
songs and many more.
ix. Handheld Systems: Handheld systems include Personal Digital Assistants
(PDAs), suchas tablets, palmtops or Cellular mobiles with Internet connection.
Most of the handheld devices have a small amount of memory, slow processors,
small display screens and battery.Faster processors require more power.To
include a faster process or in a handheld device would require a larger battery
that would have to be replaced more frequently.Some handheld devices may use
wireless technology such as BlueTooth or wifi allowing remotea ccessto e-mail
and web browsing.

3. SYSTEMCOMPONENTS
Syeda Sumaiya Afreen pg. 10
CMR Technical Campus

The operating system comprises a set of software components that can be used to
manage interactions with the hardware. Theyare:

Process
management

File Memory
management management

Operating
Systems

I/O device Secondary


management storagemana
gement
Protection
andsecurity

Process management: The process management component manages all the


processes that are running simultaneously on the operating system.When any
software application program executes, one or more processes associated with it
runs. For example, when you use a browserlike Google Chrome, there is a process
running for that browser program. Similarly, the OS runsmany processes to perform
various functions. All these processes should be managed by process
management.The following are the main functions of process management.

Syeda Sumaiya Afreen pg. 11


CMR Technical Campus

• Process creation and deletion.

• Process suspension and resumption.

• Process synchronization

• Communication among process

Main Memory Management: It deals with main memory also called as RAM. Any
programexecution starts only after loading it in to RAM. The following are the main
functions of main memory management.
• Keep track ofwhich parts of memory are currently being used and by
whom.

• Decide which processes to load when memory space becomes


available.

• Allocate and deallocate memory space as needed.

Secondary storage management: Since main memory (RAM) is volatile and too
small toaccommodate all data and programs permanently, the computer system must
provide secondarystorage to back up main memory. The secondary storage
management component manages thestorage devices, like a hard drive, USB flash
drive (pen drive), DVD drive, or floppy disk drive.The following are the main
functions of secondary storage management.
• Freespacemanagement

• Storageallocation

• Diskscheduling

Filemanagement:It deals with management of files in a computer system.It helps

Syeda Sumaiya Afreen pg. 12


CMR Technical Campus

with creating and manipulating files. The following are the main functions of file
management.
• File and directory creation and deletion.

• Manipulating files andd irectories.

• Mapping files on to secondary storage.

• Backup files on stable storage media.

I/ODeviceManagement:It deals with managing the I/O device sconnected to


computer system. It helps to hide the variations of specific hardware devices from
the user. The following are the main functions ofI/O device management.
• It offers buffer caching system.

• It provides device drivers to run the basic I/O devices such as keyboard
and mouse.

• It provides interface to connect and run any I/O device.

ProtectionandSecurity Management: The various processes inan operating


systemneed tobe secured from each other's activities. For that purpose, various
mechanisms can be used toensure that those processes which want to operate files,
memory CPU, and other hardwareresources should have proper authorization from
the operating system. The following are themain functions ofprotection and
securitymanagement.
• Itprotectsthefilesfromunauthorizedusage.

• It providesecuritymechanisms

• Itprovidecontrolaccess mechanism

Syeda Sumaiya Afreen pg. 13


CMR Technical Campus

4. OPERATINGSYSTEMFUNCTIONS /SERVICES/TASKS

Theservices provided byoperatingsystem softwareare:

• Process management: Process management helps Os to create and delete


processes.It alsoprovides mechanisms for synchronization and
communication among processes.
• Memorymanagement:Memory management module performs the task of
allocation and de-allocation of memory space to programs.
• Filemanagement:It manages all the file-related activities such as creating,
deleting, accessing, sharing, and protection of files.
• DeviceManagement:Device management keeps tracks of all input/output
devices.It also performs the task of allocation and de-allocation of the
devices.
• Security:Security module protects the files of a computer system against
malware threat and unauthorized access.
• UserInterface:It provides a user interface.It may be command line or
graphical user interface(GUI). A user can very easily use computer system
with the help of the GUI.
• Program development: The OS provides a variety of facilities and services,
such as editor and debuggers, to assist the programmer in creating programs.
• Program execution: A number of steps need to be performed to execute a
program.Instructions and data must be loaded into main memory, I/O devices
and files must beinitialized, and other resources must be prepared. The OS
handles the CPU scheduling duties for the user.
• Error detection and response: A variety of errors can occur while a
computer system isrunning.These include internal and external hardware
errors,such as amemory error,or a device failure or malfunction; and various
Syeda Sumaiya Afreen pg. 14
CMR Technical Campus

software errors, such as division by zero,attempt to access forbidden memory


location, and inability of the OS to grant the requestof an application. In each
case, the OS must provide a response that clears the error condition with the
least impact on running applications.The response may range from ending the
program that caused the error, to retrying the operation, to simply reporting
the error to the application.
• Accounting: A good OS will collect usage statistics for various resources and
monitor performance parameters such as response time. On any system, this
information is usefulin anticipating the need for future enhancements and in
tuning the system to improve performance.On a multiuser system,the
information can be used for billing purposes.

5. SYSTEMCALLS
A system call is a programmatic interface between user process and OS kernel.
It isamechanism in whichuser program make a request to get service form
kernel.System call provides the services to the user programs via Application
Program Interface(API).The common APIs available for most operating systems or
virtual machine sare:
API OperatingSystem
Win32 API Windows
POSIXAPI Unix,Linux, MacOS X
Java API JavaVirtualMachine(JVM)

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.
In order to do this work first we need to take the two file names as input.
The total operation is expressed below. Though it is a simple task itself it needs so
Syeda Sumaiya Afreen pg. 15
CMR Technical Campus

many system calls.

Before the system call enters into kernel mode, the user application pauses and the
control istransferred tothe kernelby setting mode bit = 0. If the request is allowed,
the kernel processesthe request, for example creating or deleting a file. When the
operation is complete, the kernelpasses the output back to the application and set the
mode bit =1. The application receives

the output from the kernel as parameter value.Once the input is received, the
application resumes the process.The interaction between user mode and kernel mode
is shown in the below figure.

Syeda Sumaiya Afreen pg. 16


CMR Technical Campus

The run-time support system (a set of functions built into libraries included
with a compiler) for most programming languages provides a system-call interface
that serves as the link to system calls made available by the operating system. The
system-call interface intercepts function calls in the API and invokes the necessary
system call within the operating system. Typically, a number is associated with each
system call, and the system-call interface maintains a table indexed according to
these numbers. The system call interface then invokes the intended system call in
the operating system kernel and returns the status of the system call and any return
values.

The relationship between an API, the system-call interface, and the operating
system is shown in Figure 2.3, which illustrates how the operating system handles a
user application invoking the open() system call.

For example, when a user application needs a file, a system call called open() is
generated. Theuser application passes the parameters such as file name, path name
to the kernel by changing themode bit to 0. If the requested file exists (request is
valid), the file is opened by the kernel andchanges the mode bit to 1. Later, the
Syeda Sumaiya Afreen pg. 17
CMR Technical Campus

address of the opened file is passed back as a return value totheuser application. This
is shown in thebelow figure.

Generally user application executes in user mode and when it needs support from
OS, a systemcall is generated.When an application makes a system call, it passes the
required parameters to the kernel. The three general methods for passing parameters
to the OS kernel are:
1. Parameters can be passed in registers.

2. When there are more parameters than number of registers, parameters can be

stored in a block and the block addres scan be passed as a parameter in a


register.
3. Parameters can also be pushed on or popped off the stack by the operating

system.

Figure:Passing parameters as a table

Syeda Sumaiya Afreen pg. 18


CMR Technical Campus

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.

The system calls can be categorized broadly into five types. They are:

i. ProcessControl:These system calls deal with process management and


control.Some of the important system call under this category are:
CreateProcess(): It used to create a new process.

ExitProcess(): It is used to stop executing a process.

WaitForSingleObject():It is used to block the current executing


process.

ii. FileManagement:These system calls deals with file manipulation and


management.Some of the important system call under this categoryare:
CreateFile():It is used to create a new file.

ReadFile():It is used to open an existing file to read.

Syeda Sumaiya Afreen pg. 19


CMR Technical Campus

WriteFile():It is used to open an existing file or create a file to write.

CloseHandle():It is used to close the file currently in use.

iii. DeviceManagement:These system calls deals with device manipulation


and management. Some of the important system call under this category are:

SetConsoleMode():It is used to Set the input mode of a console's input


buffer or the output mode of a console screen buffer.
ReadConsole():It is used to read input character from the input console
buffer.

WriteConsole():It is used to write character into the output console buffer.

iv. InformationMaintenance:Thesesystemcallshandleinformationanditstransfe
rbetween the operating system and the user program. Some of the important
system callunderthis categoryare:
GetCurrentProcessID( ): It is used to get the curren texecuting
process ID.
SetTimer(): It is used to create a timer with the specified time
out value.
Sleep():It is used to make a process to sleep,which places it into an inactive
state.

v. Communication:These system calls are useful for inter-process


communication. Some of the important system call under this category are:
CreatePipe(): It creates an anonymous pipe to perform read and write
operations.

MapViewOfFile() It maps a file or device to a memory location.

Syeda Sumaiya Afreen pg. 20


CMR Technical Campus

6.OPERATINGSYSTEMSTRUCTURE

i. Simple Structure: Operating systems such as MS-DOS and the original UNIX
did nothave well-defined structures. Frequently, such operating systems started
as small, simple, and limited systems and then grew beyond their original scope.
MS-DOS is an example ofsuch a system. It was originally designed and
implemented by a few people who had no ideathat it would become so popular.
It was written to provide the most functionality in the least space,so it was not
designed carefully. InMS-DOS, the interfaces and levels of functionality are not
well separated. So, errors in applications could cause the whole systemtocrash.

Advantages of Simple structure:

• It delivers better application performance because of the few interfaces between


the application program and the hardware.
• Easy for kernel developers to develop such an operating system.

Disadvantages of Simple structure:

• The structure is very complicated as no clear boundaries exists between modules.


• It does not enforce data hiding in the operating system.
Syeda Sumaiya Afreen pg. 21
CMR Technical Campus

ii. Layered Approach: The operating system is divided into a number of layers
(levels),each built on top of lower layers. The bottom layer (layer 0), is the
hardware; the highest(layer N) is the user interface. The lower layer provides
service to its next higher layer. Themain advantage of the layered approach is
simplicity of construction and debugging.It iseasier to create, maintain and
update the operating system. Change in one layer does notaffecttherest of
thelayers.

Advantages of Layered structure:

• Layering makes it easier to enhance the operating system as implementation of a


layer can be changed easily without affecting the other layers.
• It is very easy to perform debugging and system verification.

Disadvantages of Layered structure:

• In this structure the application performance is degraded as compared to simple


structure.

Syeda Sumaiya Afreen pg. 22


CMR Technical Campus

• It requires careful planning for designing the layers as higher layers use the
functionalities of only the lower layers.

iii. Microkernel: This method structures the operating system by removing all non-
essential components from the kernel and implementing them as system or user-
level programs. The result is a smaller kernel. Kernel is the core part of an OS
which manages system resources.It also acts like a bridge between application
and hardware of the computer. The client programand service neve interact
directly. Rather,they communicate indirectly by exchanging messages with the
microkernel. All new services are added to user space and as a result there is no
need to modify the kernel.As most of the services are running as user Processes
rather than kernel processes, the microkernel provides more security and
reliability.

Application File Device user


Program System Driver mode

messages messages

Interprocess memory CPU kernel


Communication managment scheduling mode

microkernel

hardware

Advantages of Micro-kernel structure:

• It makes the operating system portable to various platforms.


• As microkernels are small so these can be tested effectively.

Disadvantages of Micro-kernel structure:


Syeda Sumaiya Afreen pg. 23
CMR Technical Campus

• Increased level of inter module communication degrades system performance.

iv. Modules: The best methodology for operating system design involves using
modular kernel. In this,the kernel has a set of core components and additional
services are dynamically linked either during boot time or during run time.It is
used in modern implementations of UNIX, such as Solaris, Linux, and Mac OS
X. For example, the Solarisoperating system structure is organized around a core
kernel with seven types of loadable kernel modules:

Even though this structure resembles a layered system, it is more flexible than a
layeredsystem because any module can call any other module. Furthermore, this
approach is like the micro kernel approach but it is more efficient, because
modules do not need to invoke message passing in order to communicate.
Advantages −

• Efficient
• Easy to maintained
• Easy to debug and update

Syeda Sumaiya Afreen pg. 24


CMR Technical Campus

Disadvantages −

• It may lose stability


• Less security

*************************** ALL THE BEST *************************

Syeda Sumaiya Afreen pg. 25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy