0% found this document useful (0 votes)
8 views29 pages

OS-1

The document provides an overview of operating systems, covering their evolution, functions, and structure, including memory management, process management, and device control. It discusses various types of computer systems such as single-processor, multiprocessor, and clustered systems, along with their operational modes and user interfaces. Additionally, it highlights the importance of system calls and APIs in facilitating communication between applications and the operating system.

Uploaded by

ITS SAURABH
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)
8 views29 pages

OS-1

The document provides an overview of operating systems, covering their evolution, functions, and structure, including memory management, process management, and device control. It discusses various types of computer systems such as single-processor, multiprocessor, and clustered systems, along with their operational modes and user interfaces. Additionally, it highlights the importance of system calls and APIs in facilitating communication between applications and the operating system.

Uploaded by

ITS SAURABH
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/ 29

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

UNIT-I
Introduction to OS: evolution of OS, basic hardware support necessary for modern operating systems,
Layered Structural of OS, process concept, process state transitions , Services provided by OS, system
calls, privileged instructions, Dual mode of operation, I/O bound and CPU bound processes, concept of
multiprogramming and multiprocessing.

1
2
Operating system performs the following functions:

1. Booting
Booting is a process of starting the computer operating system starts the computer to
work. It checks the computer and makes it ready to work.
2. Memory Management
It is also an important function of operating system. The memory cannot be managed
without operating system. Different programs and data execute in memory at one
time. if there is no operating system, the programs may mix with each other. The
system will not work properly.
3. Loading and Execution
A program is loaded in the memory before it can be executed. Operating system
provides the facility to load programs in memory easily and then execute it.
4. Data security
Data is an important part of computer system. The operating system protects the data stored
on the computer from illegal use, modification or deletion.
5. Disk Management
Operating system manages the disk space. It manages the stored files and folders in a proper way.
6. Process Management
CPU can perform one task at one time. if there are many tasks, operating system decides
which task should get the CPU.
7. Device Controlling
operating system also controls all devices attached to computer. The hardware
devices are controlled with the help of small software called device drivers..
8. Providing interface
It is used in order that user interface acts with a computer mutually. User interface controls
how you input data and instruction and how information is displayed on screen. The
operating system offers two types of the interface to the user:

a) Graphical-line interface: It interacts with of visual environment to communicate


with the computer. It uses windows, icons, menus and other graphical objects
to issues commands.
b) Command-line interface: it provides an interface to communicate with the
computer by typing commands.

3
Computer System Architecture
Computer system can be divided into four components Har dwar e – provides
basic computing resources
CPU, memory, I/O devices, Operat ing 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
Word processors, compilers, web browsers, database systems, video
games Users
People, machines, other computers Four
Components of a Computer System

Computer architecture means construction/design of a computer. A computer system may be


organized in different ways. Some computer systems have single processor and others have
multiprocessors. So based on the processors used in computer systems, they are categorized
into the following systems.

1. Single-processor system

2. Multiprocessor system

3. Clustered Systems:

1. Single-Processor Systems:

Some computers use only one processor such as microcomputers (or personal computers PCs).
On a single-processor system, there is only one CPU that performs all the activities in the
computer system. However, most of these systems have other special purpose processors, such
as I/O processors that move data quickly among different components of the computers. These
4
processors execute only a limited system programs and do not run the user program. Sometimes
they are managed by the operating system. Similarly, PCs contain a special purpose
microprocessor in the keyboard, which converts the keystrokes into computer codes to be sent to
the CPU. The use of special purpose microprocessors is common in microcomputer. But it does
not mean that this system is multiprocessor. A system that has only one general-purpose CPU,
is considered as single- processor system.

2. Multiprocessor Systems:

In multiprocessor system, two or more processors work together. In this system, multiple programs
(more than one program) are executed on different processors at the same time. This type of
processing is known as multiprocessing. Some operating systems have features of multiprocessing.
UNIX is an example of multiprocessing operating system. Some versions of Microsoft Windows
also support multiprocessing.

Multiprocessor system is also known as parallel system. Mostly the processors of


multiprocessor system share the common system bus, clock, memory and peripheral devices.
This system is very fast in data processing.

Types of Multiprocessor Systems:

The multiprocessor systems are further divided into two


types; (i). Asymmetric multiprocessing system
(ii). Symmetric multiprocessing system

(i) Asymmetric Multiprocessing System(AMS):

The multiprocessing system, in which each processor is assigned a specific task, is known as
Asymmetric Multiprocessing System. For example, one processor is dedicated for handling
user's requests, one processor is dedicated for running application program, and one processor
is dedicated for running image processing and so on. In this system, one processor works as
master processor, while other processors work as slave processors. The master processor
controls the operations of system. It also schedules and distributes tasks among the slave
processors. The slave processors perform the predefined tasks.

(ii) Symmetric Multiprocessing System(SMP):

The multiprocessing system, in which multiple processors work together on the same task, is
known as Symmetric Multiprocessing System. In this system, each processor can perform all
types of tasks. All processors are treated equally and no master-slave relationship exists
between the processors.

5
For example, different processors in the system can communicate with each other. Similarly, an
I/O can be processed on any processor. However, I/O must be controlled to ensure that the data
reaches the appropriate processor. Because all the processors share the same memory, so the
input data given to the processors and their results must be separately controlled. Today all
modern operating systems including Windows and Linux provide support for SMP.

It must be noted that in the same computer system, the asymmetric multiprocessing and
symmetric multiprocessing technique can be used through different operating systems.

A Dual-Core Design

3. Clustered Systems:

Clustered system is another form of multiprocessor system. This system also contains multiple
processors but it differs from multiprocessor system. The clustered system consists of two or
more individual systems that are coupled together. In clustered system, individual systems (or
clustered computers) share the same storage and are linked together ,via Local Area Network
(LAN).

A layer of cluster software runs on the cluster nodes. Each node can monitor one or more of
the other nodes over the LAN. If the monitored machine fails due to some technical fault (or
due to other reason), the monitoring machine can take ownership of its storage. The
monitoring machine can also restart the applications that were running on the failed machine.
The users of the applications see only an interruption of service.

Types of Clustered Systems:

Like multiprocessor systems, clustered system can also be of two


types (i). Asymmetric Clustered System
(ii). Symmetric Clustered System
(i). Asymmetric Clustered System:
In asymmetric clustered system, one machine is in hot-standby mode while the other

6
machine is running the application. The hot-standby host machine does nothing. It only
monitors the active server. If the server fails, the hot-standby machine becomes the active
server.
(ii). Symmetric Clustered System:
In symmetric clustered system, multiple hosts (machines) run the applications. They also
monitor each other. This mode is more efficient than asymmetric system, because it uses all
the available hardware. This mode is used only if more than one application be available to
run.

Operating System – Structure

Operating System Structure


Multiprogramming needed for efficiency
Single user cannot keep CPU and I/O devices busy at all times
Multiprogramming organizes jobs (code and data) so CPU always has one to
Execute A subset of total jobs in system is kept in memory

7
8
2) Multitasking

9
Operating-system Operations

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

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.
10
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 kernel mode is an example of a privileged instruction. Some other examples include
I/0 control timer management and interrupt management.

11
12
II YEAR/I SEM MRCET

13
14
Personal-Computer Systems(PCs)
A personal computer (PC) is a small, relatively inexpensive computer designed for an
individual user. In price, personal computers range anywhere from a few hundred dollars to
thousands of dollars. All are based on the microprocessor technology that enables
manufacturers to put an entire CPU on one chip.
At home, the most popular use for personal computers is for playing games. Businesses
use personal computers for word processing, accounting, desktop publishing, and for
running spreadsheet and database management applications.

15
Special purpose systems

a) Real-Time Embedded Systems


These devices are found everywhere, from car engines and manufacturing robots to DVDs
and microwave ovens. They tend to have very specific tasks.
They have little or no user interface, preferring to spend their time monitoring and
managing hardware devices, such as automobile engines and robotic arms.

16
b) Multimedia Systems
Most operating systems are designed to handle conventional data such as text files, programs,
word-processing documents, and spreadsheets. However, a recent trend in technology is the
incorporation of multimedia data into computer systems. Multimedia data consist of audio
and video files as well as conventional files. These data differ from conventional data in that
multimedia data-such as frames of video-must be delivered (streamed) according to certain
time restrictions (for example, 30 frames per second). Multimedia describes a wide range of
applications in popular use today. These include audio files such as MP3, DVD movies,
video conferencing, and short video clips of movie previews or news stories downloaded
over the Internet. Multimedia applications may also include live webcasts (broadcasting over
the World Wide Web)

c) Hand held Systems


Handheld Systems include personal digital assistants (PDAs, cellular telephones. Developers of
handheld systems and applications face many challenges, most of which are due to the limited
size of such devices. For example, a PDA is typically about 5 inches in height and 3 inches in
width, and it weighs less than one-half pound. Because of their size, most handheld devices
have small amounts of memory, slow processors, and small display screens.

17
Operating System Services

One set of operating-system services provides functions that are helpful to the user
Communications – Processes may exchange information, on the same computer or between computers
over a network Communications may be via shared memory or through message passing (packets moved
by the OS)
Error detection – OS needs to be constantly aware of possible errors May occur in the CPU and
memory hardware, in I/O devices, in user program For each type of error, OS should take the appropriate
action to ensure correct and consistent computing Debugging facilities can greatly enhance the user’s
and programmer’s abilities to efficiently use the system
Another set of OS functions exists for ensuring the efficient operation of the system itself via resource
Sharing

18
Resource allocation - When multiple users or multiple jobs running concurrently, resources must
be allocated to each of them
Many types of resources - Some (such as CPU cycles, main memory, and file storage) may have special
allocation code, others (such as I/O devices) may have general request and release code
Accounting - To keep track of which users use how much and what kinds of computer resources
Protection and security - The owners of information stored in a multiuser or networked computer
system may want to control use of that information, concurrent processes should not interfere with each
other
Protection involves ensuring that all access to system resources is controlled
Security of the system from outsiders requires user authentication, extends to defending external I/O
devices from invalid access attempts
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.
User Operating System Interface - CLI
Command Line Interface (CLI) or command interpreter allows direct command entry
Sometimes implemented in kernel, sometimes by systems program
sometimes multiple flavors implemented – shells
Primarily fetches a command from user and executes it

User Operating System Interface - GUI

User-friendly desktop metaphor interface


Usually mouse, keyboard, and monitor Icons
represent files, programs, actions, etc
Various mouse buttons over objects in the interface cause various actions (provide information,
options, execute function, open directory (known as a folder)
Invented at Xerox PARC
Many systems now include both CLI and GUI
interfaces Microsoft Windows is GUI with CLI
―command‖ shell
Apple Mac OS X as ―Aqua‖ GUI interface with UNIX kernel underneath and shells
available Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
System Calls

Programming interface to the services provided by the OS


Typically written in a high-level language (C or C++)
Mostly accessed by programs via a high-level Application Program Interface (API) rather than
direct system call usenThree most common APIs are Win32 API for Windows, POSIX API for POSIX-
based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the
Java virtual machine (JVM)
Why use APIs rather than system calls?

19
Example of System Calls

Example of Standard API


Consider the ReadFile() function in the
Win32 API—a function for reading from a file

A description of the parameters passed to ReadFile() HANDLE file—the file to be read


LPVOID buffer—a buffer where the data will be read into and written
from DWORD bytesToRead—the number of bytes to be read into the
buffer LPDWORD bytesRead—the number of bytes read during the
last read LPOVERLAPPED ovl—indicates if overlapped I/O is being
used
System Call Implementation
Typically, a number associated with each system call
System-call interface maintains a table indexed according to these Numbers
The system call interface invokes intended system call in OS kernel and returns status of the system
call and any return values
The caller need know nothing about how the system call is
20
implemented Just needs to obey API and understand what OS will
do as a result call Most details of OS interface hidden from
programmer by API
Managed by run-time support library (set of functions built into libraries included with compiler)
API – System Call – OS Relationship
Standard C Library Example

System Call Parameter Passing


Often, more information is required than simply identity of desired system
call Exact type and amount of information vary according to OS and call
Three general methods used to pass parameters to the
OS Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
Parameters stored in a block, or table, in memory, and address of block passed as a parameter
in a register
This approach taken by Linux and Solaris
Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating
21
system
Block and stack methods do not limit the number or length of parameters being passed
Parameter Passing via Table

Types of System Calls


1. Process control
2. File management
3. Device management
4. Information maintenance
5. Communications
Process control
A running needs to halt its execution either normally or abnormally.
If a system call is made to terminate the running program, a dump of memory is sometimes
taken and an error message generated which can be diagnosed by a debugger
o end, abort
o load, execute
o create process, terminate process
o get process attributes, set process attributes
o wait for time
o wait event, signal event
o allocate and free memory
File management
OS provides an API to make these system calls for managing files
o create file, delete file
o open, close file
o read, write, reposition
o get and set file attributes
Device management
Process requires several resources to execute, if these resources are available, they will be
granted and control retuned to user process. Some are physical such as video card and other
such as file. User program request the device and release when finished
o request device, release device
o read, write, reposition
22
o get device attributes, set device attributes
o logically attach or detach devices

Information maintenance
System calls exist purely for transferring information between the user
program and OS. It can 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.
o get time or date, set time or date
o get system data, set system data
o get and set process, file, or device attributes

Communications
Two common models of communication
Message-passing model, information is exchanged through an inter process-
communication facility provided by the OS.
Shared-memory model, processes use map memory system calls to gain access to regions of
memory owned by other processes.
o create, delete communication connection
o send, receive messages
o transfer status information
o attach and detach remote devices

Examples of Windows and Unix System Calls

23
MS-DOS execution

(a) At system startup (b) running a


program FreeBSD Running Multiple Programs

24
System Programs
System programs provide a convenient environment for program development and execution. The can
be divided into:
File manipulation
Status information
File modification
Programming language support
Program loading and execution
Communications
Application programs

Most users’ view of the operation system is defined by system programs, not the actual
system calls provide a convenient environment for program development and execution
Some of them are simply user interfaces to system calls; others are considerably more complex
File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and
directories
 Status information
Some ask the system for info - date, time, amount of available memory, disk space, number of users
Others provide detailed performance, logging, and debugging information
Typically, these programs format and print the output to the terminal or other output devices
Some systems implement a registry - used to store and retrieve configuration information
 File modification
Text editors to create and modify files
Special commands to search contents of files or perform transformations of the text
Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes
provided
Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-
loaders, debugging systems for higher-level and machine language

25
Communications - Provide the mechanism for creating virtual connections among processes, users, and
computer systems
Allow users to send messages to one another’s screens, browse web pages, send electronic-mail
messages, log in remotely, transfer files from one machine to another

Operating System Design and Implementation


Design and Implementation of OS not ―solvable‖, but some approaches have proven successful
Internal structure of different Operating Systems can vary widely
Start by defining goals and specifications Affected by
choice of hardware, type of system User goals and
System goals
User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
System goals – operating system should be easy to design, implement, and maintain, as well as flexible,
reliable, error-free, and efficient
Important principle to separate
Policy: What will be done?
Mechanism: How to do it?
Mechanisms determine how to do something, policies decide what will be done
The separation of policy from mechanism is a very important principle, it allows maximum flexibility if
policy decisions are to be changed later
Simple Structure
MS-DOS – written to provide the most functionality in the least space Not divided into
modules
Although MS-DOS has some structure, its interfaces and levels of Functionality are not well separated

26
OPERATING SYSTEMS NOTES II YEAR/I SEM MRCET

MS-DOS Layer Structure

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.
With modularity, layers are selected such that each uses functions (operations) and services of
only lower-level layers
Traditional UNIX System Structure

UNIX

UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring.
The UNIX OS consists of two separable parts

Systems programs
The kernel
Consists of everything below the system-call interface and above the physical hardware
Provides the file system, CPU scheduling, memory management, and other operating-system

27
functions; a large number of functions for one level
Layered Operating System

Micro kernel System Structure


Moves as much from the kernel into ―user‖ space
Communication takes place between user modules using message passing
Benefits:
Easier to extend a microkernel
Easier to port the operating system to new architectures More reliable (less code
is running in kernel mode)
More secure
Detriments:
Performance overhead of user space to kernel space communication
MacOS X Structure

28
Modules

Most modern operating systems implement kernel modules


Uses object-oriented approach
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel
Overall, similar to layers but with more flexible

Solaris Modular Approach

29

You might also like