BCS303 - Module 1 (Sessionwise)
BCS303 - Module 1 (Sessionwise)
OPERATING SYSTEMS
MODULE-1
BCS303
SESSION 1
INTRODUCTION TO OPERATING SYSTEMS
What is an Operating System?
An operating system is a program that manages the computer hardware, and acts as an
intermediary between the computer user and the computer hardware. It also provides a basis for
application programs.
WHAT OPERATING SYSTEMS DO
The operating system's role in the overall computer system is studied, by considering a computer
system which can be divided roughly into four components: the hardware, the operating system,
the application programs, and the users.
• 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.
VIEWS OF OPERATING SYSTEMS
Canara Engineering College, Mangaluru Page 3
OPERATING SYSTEMS MODULE 1
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 controllers 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.
Review Questions:
6. What is an interrupt?
7. What is caching?
SESSION 2
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
2. Multiprogramming
3. 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
Review Questions:
1. What is single processor system?
2. What is multi-processor system?
3. What are the advantages of multi-processor systems?
4. What is graceful degradation?
5. What are the two types of multi-processor systems?
6. What is asymmetric multi-processing system?
7. What is clustered system?
8. What are batch systems?
9. What is multiprogramming?
10. What are time sharing or multitasking system?
11. What is user mode?
12. What is kernel mode?
13. What is the main reason to have two modes of operation of OS?
SESSION 3
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
3. Mapping files onto secondary storage
4. Backup files onto stable (non-volatile) storage media
MASS-STORAGE MANAGEMENT
*****What are the operating System activities connected with Mass storage management
OS activities
1. Free-space management
2. Storage allocation
3. Disk scheduling
Canara Engineering College, Mangaluru Page 19
OPERATING SYSTEMS MODULE 1
CACHING
Review Questions:
1. What is a process?
2. What is process management of OS?
3. What is memory management of OS?
4. What is caching?
5. What is storage management?
6. What is file management?
7. What are I/O systems?
8. Why protection need to be provided to processes in OS?
SESSION 4
DISTRIBUTED SYSTEM
**List the essential properties of Distributed OS
Review Questions:
SESSION 5
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.
4. File -system manipulation: The file system is of particular interest. Obviously, programs
need to read and write files and directories, create and delete them, search them, list file
Information, permission management.
5. 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)
6. Error detection – OS needs to be constantly aware of possible errors. Errors may occur
in CPU and memory, in I/O devices and in user program.
Services provided by the OS that are helpful to the efficient operation of system.
1. Resource allocation - When multiple users or multiple jobs running concurrently,
resources must be allocated to each of them
2. Accounting - To keep track of which users use how much and what kinds of computer
resources
3. Protection and security – When several separate processes execute concurrently, it
should not be possible for one process to interfere with the others or with the OS itself.
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
COMMAND-LINE INTERFACE OR COMMAND INTERPRETER
CLI 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
• Sometimes commands built-in, sometimes just names of programs
GRAPHICAL USER INTERFACE
• 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)
Review Questions:
1. List the different services provided by OS that are helpful to the user.
2. List the different services provided by OS that are helpful to the efficient operation of the
system.
3. What is CLI?
4. What are the main features of GUI?
5. What are system calls?
6. What is API?
7. What are the benefits of API?
SESSION 6
Write the system call sequence to copy a file from source to destination
SYSTEM PROGRAM
***What are the different categories of system program
Six categories of system program are:
1. File management: These programs manipulate files. Create, delete, copy, rename, print,
dump, list etc
2. Status information: Some programs ask the system for Date(time), amount of memory,
number of users etc.
3. File modification: text editors can be used to create and modify the content of files stored
on the disk.
4. Programming Language support: Compilers, assemblers and interpreters for common
programming languages are provided to the user
5. Program loading and Execution: the system may provide absolute loader, re-locatable
loaders, linkage editors, overlay loaders, Debugger etc.
6. Communications: These programs are used for creating virtual connections between
processes, users and computer systems. They allow user to browse web pages, send email
or log-in remotely
Review Questions:
SESSION 7
OPERATING SYSTEM DESIGN AND IMPLEMENTATION
Affected by choice of hardware, type of system-batch system, time shared 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. The wide variety of systems in existence shows
different requirements can result in variety of solutions for different environments.
✓ Specifying and designing an OS is a highly creative task.
✓ Software engineering provide general principles.
MECHANISM AND POILCIES
One important principle is the separation of policy and mechanism.
✓ Policy: What will be done?
✓ Mechanism: How to do it?
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
Canara Engineering College, Mangaluru Page 33
OPERATING SYSTEMS MODULE 1
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.
LAYERED APPROACH
Explain the advantages of layered approach OS with neat diagram
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).
Review Questions:
1. What are user goals of OS?
2. What is system goal?
3. What is policy?
4. What is mechanism?
5. What is the main drawback of simple structured OS?
6. List the features of non-simple traditional Unix OS?
7. List the characteristics of layered approach.
8. What is micro-kernel structure?
9. What is the main advantage of modular structure?
SESSION 8
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.
communication network
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
System Boot
• The procedure of starting a computer by loading the kernel is known as booting the system.
• Bootstrap program or Bootstrap loader locates the kernel, loads it into main memory and
start its execution.
• Bootstrap program is in the form of read only memory (ROM) because the RAM is in
unknown state at a system startup. All forms of ROM are knowing as firmware.
• For large OS like Windows, Mac OS, the Bootstrap loaders is stored in firmware and the
OS is on disk.
• Bootstrap has a bit code to read a single block at a fixed location from disk into the memory
and execute the code from that boot block.
• A disk that has a boot partition is called a boot disk or system disk.
Review Questions:
1. What is a virtual machine?
2. What is the main disadvantage of virtual machine?
3. List the benefits of creating virtual machines?
4. What is VM-WARE?
5. List the features of VM-WARE.
6. What is booting?
7. What is Bootstrap program?