OS - Module 1
OS - Module 1
MODULE-1
BCS303
OPERATING SYSTEMS MODULE 1
Hardware provides basic computing resources such as CPU, memory, I/O devices
System & Application programs define the ways in which the system resources are used
to solve the computing problems of the users / systems. Word processors, compilers, web
browsers, database systems, video games.
Operating system controls and coordinates use of hardware among various applications
and users
Users: People, machines, other computers.
COMPUTER-SYSTEM ORGANIZATION
1. Computer-system operation
a. One or more CPUs, device controllers connect through common bus providing
access to shared memory.
b. Concurrent execution of CPUs and devices competing for memory cycles.
Interrupt
The occurrence of event is signaled by interrupt from either hardware(signal to CPU) or
software (system call)
Interrupt transfers control to the interrupt service routine generally, through the interrupt
vector, which contains the addresses of all the service routines.
Interrupt architecture must save the address of the interrupted instruction.
Incoming interrupts are disabled while another interrupt is being processed to prevent a
lost interrupt.
A trap is a software-generated interrupt caused either by an error or a user request.
An operating system is interrupt driven.
After the interrupt is serviced, the saved return address is loaded into the program
counter, and the interrupted computation resumes as though the interrupt is not occurred.
2. Storage Structure:
Main Memory:
Computer programs must be in main memory (also called random-access memory or
RAM) to be executed. Main memory is the only large storage area (millions to billions of
bytes) that the processor can access directly. It commonly is implemented in a semiconductor
technology called Dynamic Random Access Memory (DRAM). Other memory devices are
ROM, EEPROM etc. Load and store instructions are used to read and write data/instructions
between memory & processor.
Secondary storage
Extension of main memory that provides large nonvolatile storage capacity.
• Magnetic disks
Rigid metal or glass platters covered with magnetic recording material
Disk surface is logically divided into tracks, which are subdivided into sectors.
The disk controller determines the logical interaction between the device and the
computer.
Other storages include cache, CD-ROM, magnetic tapes and so on. The main differences among
the storage systems lie in speed, cost, size and volatility. The storage system can be organized in
a hierarchy according to speed and cost. Higher levels are expensive but they are fast. Down in
the hierarchy cost decreases and the access time increases.
Explain storage device hierarchy, with neat diagram.
The wide variety of storage systems in a computer system can be organized in a hierarchy as
shown above, is according to speed and cost. The higher levels are expensive, but they are fast.
As we move down the hierarchy, the cost per bit generally decreases, whereas the access time
generally increases.
CACHING
• Information in use copied from slower to faster storage device temporarily
• Faster storage (cache) checked first to determine if information is there in main memory
– If it is, information used directly from the cache (fast)
– If not, data copied to cache and used there.
I/O STRUCTURE
Storage is only one of many types of I/O devices within a computer. A large portion of operating
system code is dedicated to managing I/O, both because of its importance to the reliability and
performance of a system and because of the varying nature of the devices. A general-purpose
computer system consists of CPUs and multiple device contr ollers that are connected through a
common bus. Each device controller is in charge of a specific type of device. Depending on the
controller, there may be more than one attached device. The device controller is responsible for
moving the data between the peripheral devices that it controls and its local buffer storage.
Typically, operating systems have a device driver for each device controller. This device driver
understands the device controller and presents a uniform interface to the device to the rest of the
operating system.
COMPUTER-SYSTEM ARCHITECTURE
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.
Single processor systems
Multiprocessor system
Clustered system
SINGLE-PROCESSOR SYSTEM
One main CPU capable of executing a general-purpose instruction set, including
instructions from user processes.
All systems have special purpose processors. i.e device specific processors such as disk,
keyboard, and graphics controller
Mainframes- general purpose processors such as I/O processors
Run limited set of instruction does not run user processes.
Use of special purpose processor does not turn a single processor system into
multiprocessor system
MULTI-PROCESSOR SYSTEMS
Also known as parallel systems or tightly coupled systems
Two or more processors in close communication sharing the computer bus and
sometimes the clock, memory and peripheral devices
***List the three main advantages of multi-processor systems
Advantages
1. Increased throughput: By increasing the number of processors, we expect to get more work
done in less time
2. Economy of scale: Multiprocessor systems can cost less than equivalent multiple single-
processor systems.
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.
CLUSTERED SYSTEMS
****Explain the types of clustered system
Clustered system gather together multiple CPUs to accomplish computational work
Clustered systems are composed of two or more individual systems or nodes joined
together.
Clustered system share storage and are closely linked via local area network.
Clustering provide high availability.
Types of clustering systems
i. Asymmetric clustering
ii. Symmetric clustering
iii. Parallel clustering
iv. Clustering over wide area network
Asymmetric clustering
One machine is in hot-standby mode while other is running the applications.
The hot standby host machine does nothing but monitor the active server.
If server fails, the hot standby host machine becomes the active server.
Symmetric clustering
Two or more hosts are running applications and are monitoring each other.
This mode of system is more efficient, as it uses all of the available hardware.
Parallel clustering
Parallel clusters allow multiple hosts to access the shared data.
Clustering over wide area network
It is a collection of physically separate computer systems that are networked (WAN) to
provide the users with access to the various resources that the system maintains.
OPERATING-SYSTEM STRUCTURE
The various types of general purpose OS is
1. Batch Systems
1. Multiprogramming
2. Time sharing or Multitasking
Define the essential features of Batch operating system (Batch file system)
BATCH SYSTEM
The user of batch OS 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
At some later time (after minutes, hours or days) the output is generated.
To speed up processing, jobs with similar needs are batched together and run as a group
As several jobs are given to computer system and unless it completes the first job it is not
possible to process the next job. Therefore it is an in-efficient OS. Also the CPU is often
idle because the speed of the mechanical I/O devices.
Define the essential features of Multiprogramming operating system
MULTIPROGRAMMING
Multiprogramming increases CPU utilization by organizing jobs (code and data) so that the
CPU always has one to execute.
OS keeps several jobs in memory simultaneously.
One job selected and run via job scheduling
In a multi-programmed system, the operating system simply switches to, and executes,
another job. When that job needs to wait, the CPU is switched to another job, and so on.
As long as at least one job needs to execute, the CPU is never idle.
Multiprogramming provides an environment in which various system resources are
utilized effectively but they do not provide user interaction with the computer system.
A mode bit is added to the computer hardware to indicate the current mode; ie: mode bit = 0 for
kernel mode and 1 for user mode.
Working Principle:
At system Boot time, the hardware starts in kernel mode
The OS is then loaded and starts user application in user mode
Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel
mode
The system always switches to user mode (setting mode bit = 1), before passing control
to user program
Dual mode operation protects OS from errant users and errant user from one another
Privileged instruction is executed only in kernel mode
If an attempt is made to execute privileged instruction in user mode, the hardware treats it
as illegal and traps it to the OS
A system calls are called by user program to ask the OS to perform the tasks on behalf of
the user program.
TIMER
PROCESS MANAGEMENT
A process is a program in execution. It is a unit of work within the system. Program is a passive
entity, process is an active entity. Process needs resources to accomplish its task like CPU,
memory, I/O, files. Process termination requires reclaim of any reusable resources. Single -
threaded process has one program counter specifying location of next instruction to execute.
Process executes instructions sequentially, one at a time, until completion. Multi-threaded
process has one program counter per thread. Typically system has many processes, some user,
some operating system running concurrently on one or more CPUs. All processes can execute
concurrently by multiplexing the single CPUs.
*****What are the operating System activities connected with Process management
1. Creating and deleting both user and system processes
2. Suspending and resuming processes
3. Providing mechanisms for process synchronization
4. Providing mechanisms for process communication
5. Providing mechanisms for deadlock handling
MEMORY MANAGEMENT
*****What are the operating System activities connected with Memory management
Memory management activities
1. Keeping track of which parts of memory are currently being used and by whom
2. Deciding which processes (or parts thereof) and data to move into and out of memory
3. Allocating and de-allocating memory space as needed
STORAGE MANAGEMENT
1. Storage management
2. Mass-Storage management
3. Caching
FILE MANAGEMENT
*****What are the operating System activities connected with File management
OS activities include
1. Creating and deleting files and directories
2. Supporting Primitives to manipulate files and directories
*****What are the operating System activities connected with Mass storage management
OS activities
1. Free-space management
2. Storage allocation
3. Disk scheduling
CACHING
DISTRIBUTED SYSTEM
**List the essential properties of Distributed OS
The use of embedded devices continues to expand. Embedded system always run on real-time
operating 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.
*********List and explain the services provided by OS for the user and efficient operation
of system.
Services provided by the OS that are helpful to the user:
1. User Interface : Almost all operating systems have a user interface (UI), such as
Command-Line (CLI) uses text commands, Graphics User Interface (GUI) is window
system, Batch Interface uses commands and directives.
2. Program execution: The system must be able to load a program into memory and to run
that program, end execution, either normally or abnormally (indicating error)
3. I/O operations: A running program may require I/O, which may involve a file or an I/O
device.
Write the system call sequence to copy a file from source to destination
SYSTEM PROGRAM
***What are the different categories of system program
The separation of mechanism and policy is important for flexibility. Policies are likely to change
across places or time. A general mechanism insensitive to changes in policy would be more
desirable. A change in policy would then require redefinition of only certain parameters of the
system. Thus mechanisms determine how to do something and policies decide what will be
done.
Example: Timer construct.
Mechanism: CPU protection
Policy: How long the timer is to be set for particular user.
Timer to prevent infinite loop / process hogging resources
Before turning over control to the user, the operating system ensures that the timer
is set to interrupt.
Set interrupt after specific period
Operating system decrements counter
When counter zero generate an interrupt
Set up before scheduling process to regain control or terminate program
that exceeds allotted time.
IMPLEMENTATION
Once an OS is designed it must be implemented. Traditionally OS is implemented in assembly
language and now it is written in c or c++ .
Example: MS-DOS written in intel 8088 assembly language. Linux OS written in C is available
to number of CPUs
Modern operating system is designed so as to function properly and be modified easily. Common
approach is to partition the task into small components rather than having one monolithic system.
The various structures of operating systems are:
1. Simple structured OS
2. Layered Approach
3. Micro-kernels
4. Modules
SIMPLE STRUCTURED OS
Explain the simple structured operating system with neat diagram
These OS are simple, small and limited systems
MS-DOS and UNIX is the examples for simple OS
MS-DOS which is written to provide the most functionality in the least space
Disadvantages:
It was not divided into modules carefully
The interfaces and levels of functionality are not well separated
LAYERED APPROACH
Explain the advantages of layered approach OS with neat diagram
Disadvantages:
1) Less efficient than other types.
MICRO-KERNEL APPROACH
Explain the advantages of Micro-kernel approach OS with neat diagram
Main function:
To provide a communication facility between
client program and
various services running in user-space.
Advantages:
1) Ease of extending the OS. (New services are added to user space w/o modification of
kernel).
2) Easier to port from one hardware design to another.
3) Provides more security & reliability.(If a service fails, rest of the OS remains
untouched.).
4) Provides minimal process and memory management.
Disadvantage:
1. Performance decreases due to increased system function overhead
2. Performance overhead of user space to kernel space communication.
→ BSD kernel.
Mach provides
→ memory management;
→ support for RPCs & IPC and
→ thread scheduling.
BSD component provides
→ BSD command line interface
→ support for networking and file systems and
→ implementation of POSIX APIs
The kernel environment provides an I/O kit for development of
→ device drivers and
→ dynamic loadable modules (which Mac OS X refers to as kernel extensions).
VIRTUAL MACHINES
******What are Virtual Machines? With neat diagram explain the concept of
virtualization and its advantages.
A virtual machine (VM) is a software program or operating system that not only exhibits the
behavior of a, separate computer hardware, but is also capable of performing tasks such as
running applications and programs like a separate computer.
• The fundamental idea behind the virtual machine is to abstract the hardware of a single
computer (CPU, memory, disk drives, network interface cards) into several execution
environments thereby creating an illusion that each separate execution environment is
running its own private computer.
• The operating system creates the illusion of multiple processes, each executing on its own
processor with its own (virtual) memory.
• Major difficulty is disk systems.
Problem:
Virtual-machine software itself will need substantial disk space to provide
virtual memory.
Solution: provide virtual disks that are identical in all respects except size.
Advantages:
1) Complete protection of the various system resources.
2) It is a perfect vehicle for OS‟s R&D.
Disadvantage:
1. Difficult to implement due to effort required to provide an exact duplicate to
underlying machine.
Key Idea: This virtualization tool run in user mode as an application on top of the operating
system such as Windows or Linux and allows this host system to concurrently execute several
different guest operating systems as independent virtual machines.
• VM-WARE abstracts intel 8086 and compatible hardware into isolated virtual machines
• Linux OS is running as the host OS: FreeBSD, Windows NT and Windows XP are
running as guest OS
• The virtualization layer is the heart of VM-WARE, as it abstracts the physical hardware
into isolated virtual machines running as guest operating systems.
• Each virtual machine has its own virtual CPU, memory, disk drives, network interface
and so forth.
• An application could be tested concurrently in one physical computer with different OS
using VMware.
• Programmer could test the application on a host operating system and on three guest
operating systems with each system running as a separate virtual machine by using
VMware
JAVA VIRTUAL MACHINE
Explain VM-WARE architecture of virtual machine with neat diagram