You are on page 1of 45

Module 1

Operating system objectives and functions


An OS is a program that controls the execution of application programs and acts as
an interface between applications and the computer hardware. It can be thought of
as having three objectives:
1) Convenience: An OS makes a computer more convenient to use
2) Efficiency: An OS allows the computer system resources to be used in an

efficient manner.
3) Ability to evolve: An OS should be constructed in such a way as to permit

the effective development, testing, and introduction of new system functions


without interfering with service
The Operating System as a User/Computer Interface
1. The hardware and software used in providing applications to a user can be
viewed in a layered or hierarchical fashion as mentioned in below
diagram.
2. Explain with diagram. Explain how end users are using utilities, system
calls to develop the applications, user unware of hw).

3. OS provides following services for the end user.


1) Program development(Provides editors,debuggers)
2) Program Execution (Compilation, loading,executing)
3) Access IO device
4) Controlled access to files
5) System access
6) Error detection and responses.

7) Accounting
The Operating System as Resource Manager
1. A computer is a set of resources for the movement, storage, and processing
of data and for the control of these functions. The OS is responsible for
managing these resources
2. Following figure suggests the main resources that are managed by the OS.
3. Key points(the OS provides instructions for the processor, loading, scheduling
etc.)

Ease of Evolution of operating system


A major operating system will evolve over time for a number of reasons
1. Hardware upgrades plus new types of hardware(Adding paging
facilities, scheduler etc )
2. New services(Based on user demands)
3. Fixes
Evolution of Operating systems
(How operating system have evolved over the years.)
1. Serial Processing

a) With the earliest computers, from the late 1940s to the mid-1950s,
the programmer interacted directly with the computer hardware;
there was no OS.
b) These computers were run from a console consisting of display
lights, toggle switches, some form of input device, and a printer.
c) These early systems presented two main problems
I.
Scheduling(No scheduler manually had to reserve
computer)
II.
Setup time(takes lot of time like loading, linking , setting for
exe)
d) Users have to access computer in series so the name.
2. Simple Batch Systems
1. Early computers were very expensive, and therefore it was
important to maximize processor utilization. The wasted time due to
scheduling and setup time was unacceptable.
2. To improve utilization, the concept of a batch operating system was
developed.
3. It appears that the first batch operating system (and the first OS of
any kind) was developed in the mid-1950s by General Motors for
use on an IBM 701.
4. The central idea behind the simple batch-processing scheme is the
use of a piece of software known as the monitor
5. With this type of OS, the user no longer has direct access to the
processor. Instead, the user submits the job on cards or tape to a
computer operator, who batches the jobs together sequentially and
places the entire batch on an input device, for use by the monitor.
6. Each program is constructed to branch back to the monitor when it
completes processing, at which point the monitor automatically
begins loading the next program.
7. Monitor pint of view (Figure below
a. The monitor controls the sequence of events)
b. For this to be so, much of the monitor must always be in
main memory and available for execution that portion is
referred to as the resident monitor.
c. The rest of the monitor consists of utilities and common
functions that are loaded as subroutines to the user program
at the beginning of any job that requires them
8. Processor point of view
At a certain point, the processor is executing instructions from the
portion of main memory containing the monitor. These instructions
cause the next job to be read into another portion of main memory.

1.
2.
3.
4.

Hardware Features of monitors or Batch operating system:


Memory Protection.(Must not later monitor memory )
Timer(timer for each job, timer expires job will be stopped)
Privileged instructions
Interrupts

3. Multiprogrammed Batch Systems:


4. Time shared systems :
a. Using multiprogramming to handle multiple interactive jobs
b. Processors time is shared among multiple users
c. Multiple users simultaneously access the system through
terminals

Major Achievements
1.

Operating systems are among the most complex pieces of software ever
developed.
2. This reflects the challenge of trying to meet the difficult and in some cases
competing objectives of convenience, efficiency, and ability to evolve.
3. There are five major theoretical advances in the development of operating
systems.
a. Processes
A program in execution
An instance of a program running on a computer
Main causes of error in process synchronization
1. Improper synchronization(One routine hangs for I/O
and other is waiting for this response)
2. Failed mutual exclusion(Accessing same resource by
more processes)

3. Nondetermnied program situation(When other


processes modified address space)
4. Deadlocks
What is needed to tackle these problems is a systematic way to
monitor and control the various programs executing on the
processor. Good implementation is required. Figure shows way
in which processes are managed.(Explain with diagram)

b. Memory Management
The needs of users can be met best by a computing environment that
supports modular programming and the flexible use of data. System
managers need efficient and orderly control of storage allocation. The
OS, to satisfy these requirements, has five
principal storage management responsibilities:
1. Process isolation(prevent interfering)
2. Automatic allocation and management(dynamic
allocation)

3. Support of modular programming


4. Protection and access control
5. Long-term storage
(Write about virtual memory concept with following
diagram)
Virtual memory is a facility that allows programs
to address memory from a logical point of view,
without regard to the amount of main memory
physically available.
Virtual memory was conceived to meet the
requirement of having multiple user jobs reside in
main memory concurrently
Write following figures and explain(Both)

c. Information protection and security


The growth in the use of time-sharing systems and, more
recently, computer networks has brought with it a growth
in concern for the protection of information
Much of the work in security and protection as it relates to
operating systems can be roughly grouped into four
categories
1. Availability
2. Confidentiality
3. Data integrity(protection from
unauthorized modif..)
4. Authenticity(using credentials)
d. Scheduling and Resource management
OS should manage resource available to it and schedule their
use by various active processes
Any resource allocation and scheduling policy must consider
three factors.
1. Fairness (Equal preference to same priority processes)
2. Differential responsiveness
3. Efficiency (maximize throughput and minimize response
time)

Figure suggests the major elements of the OS involved in


the scheduling of processes and the allocation of resources
in a multiprogramming environment.(Explain with diagram)

e. System structure
We can view the system as a series of levels
Each level performs a related subset of the functions
required of the OS. It relies on the next lower level to
perform more primitive functions and to conceal the details
of those functions It provides services to the next higher
layer.
Ideally, the levels should be defined so that changes in one
level do not
require changes in other levels.
Following table shows different layer.(Explain in detail)

Development Leadings to Modern Operating Systems

The rate of change in the demands on operating systems requires not just
modifications and enhancements to existing architectures but new ways of
organizing the OS. A wide range of different approaches and design elements has
been tried in both experimental and commercial operating systems, but much of the
work fits into the following categories:
Microkernel architecture: (earlier there was monolithic kernel everything in
single proceses)
The microkernel approach simplifies implementation, provides
flexibility, and is well suited to a distributed environment.
This approach decouples kernel and server development. Servers may
be customized to specific application or environment requirements.
A microkernel architecture assigns only a few essential functions to
the kernel, including address spaces, interprocess communication
(IPC), and basic scheduling. Other OS services are provided by
processes, sometimes called servers, that run in user mode and are
treated like any other application by the microkernel
Multithreading: Explain on own words about thread and process

Symmetric multiprocessing:
As demands for performance increase and as the cost of
microprocessors continues to drop, vendors have introduced
computers with multiple microprocessors. To achieve greater efficiency
and reliability, one technique is to employ symmetric
multiprocessing (SMP).
A symmetric multiprocessor can be defined as a standalone computer
system with the following characteristics
i. There are multiple processors.
ii. These processors share the same main memory and I/O
facilities, interconnected by a communications bus or other
internal connection scheme.
iii. All processors can perform the same functions (hence the term
symmetric).
SMP has a number of potential advantages over uniprocessor
architecture, including the following: i) Performance ii) Availability
iii) Incremental growth iv) Scaling
Explain the following diagram

Distributed operating systems: Write in general


Object-oriented design: At the OS level, an object-based structure enables
programmers to
customize an OS without disrupting system integrity

Microsoft windows overview

Modular structure for flexibility


Executes on a variety of hardware platforms
Supports application written for other operating system
Architecture: Figure 2.13 illustrates the overall structure of Windows 2000

Window OS Organization

Windows has a highly modular architecture. Each system function is managed


by just one component of the OS
The kernel-mode components of Windows are the following:

o
o
o
o

Executive(Contains base OS services)


Different Executive modules are below
I/O Manager
Cache Manager
Plug-and-Play Manager
Power Manager
Security Reference Monitor
Virtual Memory Manager
Process/thread Manager
Configuration Manager
Local Procedure Call Facility(LPC)
Kernel
Hardware Abstraction Layer(HUL)
Device Driver
Windowing and Graphics System

User-Mode Processes of Windows


Four basic types of user-mode processes are supported by Windows
1. Special System Processes
2. Service Processes
3. Environment Subsystem
4. User Applications
Windows Client-Server Model

The Windows operating system services, the protected subsystems, and the
applications are structured using the client/server computing model.
Advantages of a client/server architecture include the following
o It simplifies the Executive.
o It improves reliability.
o Easy communication using RPC
o Provides suitable for Distributed computing

Threads and SMP


Two important characteristics of Windows are its support for threads and
for symmetric multiprocessing (SMP)
Write on own words about thread and SMP.
Window Objects:

Windows draws heavily on the concepts of object-oriented design.This


approach facilitates the sharing of resources and data among
processes and the protection of resources from unauthorized access.
Among the key object-oriented concepts used by Windows are the
following:

o Encapsulation
o Object class and instance
o Inheritance
o Polymorphism
There are two categories of objects used by Windows for synchronizing
the use of the processor i) Dispatcher Objects and ii) Control
Objects

Traditional UNIX System

Explain following diagram

Traditional UNIX architecture

Modern UNIX Systems

System V Release 4 (SVR4)


Solaris 9
4.4BSD
Linux

Linux

Linux started out as a UNIX variant for the IBM PC (Intel 80386)
architecture

What is Process

A program in execution
An instance of a program running on a computer
The entity that can be assigned to and executed on a processor
A unit of activity characterized by the execution of a sequence of
instructions, current state, and an associated set of system resources
process can be uniquely characterized by a number of elements,
including the following
o Identifier
o State
o Priority
o Program Counter
o Memory Pointers
o Context Data
o I/O Status Information
o Accounting Information
o All the above information stored in data structure called PCB as
given below.

Process State
1. Figure 3.2 shows a memory layout of three processes

2. A Two-State Process Model(Along with also explain Process Creating and


Termination)

3. Five State Process Model

Figure 3.6 indicates the types of events that lead to each state transition for a
process; the possible transitions are as follows
o
o
o
o
o
o
o
o
o

Null->New
New->Ready
Ready->Running
Running->Exit
Running->Ready
Running->Blocked
Blocked->Ready
Ready->Exit
Bocked->Exit

Suspended Processes(Write state transition diagram for below figure)

Security Issues
UNIX SVR4 Process management

Write about system process and user process


A total of nine process states are recognized by the UNIX SVR4 operating
system these are listed in Table 3.9

Process Description:
A process in UNIX is a rather complex set of data structures that provide the
OS
with all of the information necessary to manage and dispatch processes. Table
3.10

summarizes the elements of the process image, which are organized into
three parts:
user-level context, register context, and system-level context.

Module 2
Process and Threads
Thread is light weight process
Two characteristics of process i) Resource ownership ii)
Scheduling/Execution

Multithreading: Multithreading refers to the ability of an OS to support


multiple, concurrent paths of execution within a single process.
Figure 4.2 illustrates the distinction between threads and processes from the
point of view of process management. In a single-threaded process model
(i.e., there
is no distinct concept of thread), the representation of a process includes its
process
control block and user address space, as well as user and kernel stacks to
manage
the call/return behavior of the execution of the process. While the process is
running,
it controls the processor registers.

Uses of Thread in single-user multiprocessing systems

Foreground and background work


Asynchronous processing
Speed of execution
Modular program structure

Thread Functionality
Like processes, threads have execution states and may synchronize with one
another.
We look at these two aspects of thread functionality in turn.
Thread States:
As with processes, the key states for a thread are Running, Ready, and
Blocked
There are four basic thread operations associated with a change in thread
state
o Spawn (If Process spawns thread also spawns)
o Block (waiting for an event)
o Unblock (Event occurs)
o Finish (complete execution)
If one thread blocks, it doesnt block entire process explain same following
RPC example.
Thread Synchronization:
Example - Adobe Pagemaker: An example of the use of threads is the Adobe
PageMaker application running under a shared system

User-Level and Kernel-Level Threads


In a pure ULT facility, all of the work of thread management is done by the
application and the kernel is not aware of the existence of threads.
In a pure KLT facility, all of the work of thread management is done by the
kernel. There is no thread management code in the application level, simply
an application programming interface (API) to the kernel thread facility.
Windows is an example of this approach
Some operating systems provide a combined ULT/KLT facility (Figure 4.6c). In
a combined system, thread creation is done completely in user space, as is
the bulk of the scheduling and synchronization of threads within an
application.
The multiple ULTs from a single application are mapped onto some (smaller or
equal) number of KLTs.

Relationship between Thread and Processes

Symmetric Multiprocessing (SM)

SMP and clusters are two most popular approaches to providing parallelism
by replicating processors.
These approaches are used to improve performance and, in some cases, to
improve reliability

SMP Architecture
Flynn proposed the following categories of computer systems.
Single instruction single data (SISD) stream: A single processor
executes a
single instruction stream to operate on data stored in a single memory.
Single instruction multiple data (SIMD) stream: A single machine
instruction

controls the simultaneous execution of a number of processing


elements on a
ch processing element has an associated data memory, so that each
instruction is executed on a different set of data by the different
processors. Vector and array processors fall into this category.
Multiple instruction single data (MISD) stream: A sequence of data is
transmitted
to a set of processors, each of which executes a different instruction
sequence. This structure has never been implemented.
Multiple instruction multiple data (MIMD) stream: A set of processors
simultaneously
execute different instruction sequences on different data sets.

In a symmetric multiprocessor (SMP), the kernel can execute on


any processor and typically each processor does self-scheduling from
the pool of available processes or threads.
The kernel can be constructed as multiple processes or multiple
threads, allowing portions of the kernel to execute in parallel.

SMP Organization
Figure 4.9 illustrates the general organization of an SMP.There are multiple
processors, each of which contains its own control unit, arithmetic-logic unit, and
registers. Each processor has access to a shared main memory and the I/O devices
through some form of interconnection mechanism; a shared bus is a common
facility.

Multiprocessor Operating System Design Considerations


An SMP operating system manages processor and other computer resources
so that the user may view the system in the same fashion as a
multiprogramming uniprocessor system
The key design issues include the following
i. Simultaneous concurrent processes or threads
ii. Scheduling
iii. Synchronization
iv. Memory management
v. Reliability and fault tolerance

Microkernels

Small operating system core


Contains only essential core operating systems functions
Many services traditionally included in the operating system are now
external subsystems
Device drivers
File systems
Virtual memory manager
Windowing system
Security services

Microkernel Architecture

Benefits of a Microkernel Organization


A number of advantages for the use of microkernels have been reported in the
literature
(e.g., [FINK04], [LIED96a], [WAYN94a]).These include

Uniform interfaces
Extensibility
Flexibility
Portability
Reliability
Distributed system support
Support for object-oriented operating systems (OOOSS)

Microkernel Performance: write on own


Microkrenel Design
a minimal set of microkernel functions and services, to give a feel for
microkernel design
These functions fall into the general categories of low-level memory
management, interprocess communication (IPC), and I/O and interrupt
management
Low-level memory management:Paging concept is there explain following
figure.

Interproocess communications: The basic form of communication


between processes or threads in a microkernel OS is messages. A message
includes a header that identifies the sending and receiving process and a
body that contains direct data, a pointer to a block of data, or some control
information about the process(in simple its IPC)
I/O and Interrupt management: With a microkernel architecture, it is
possible to handle hardware interrupts as messages and to include I/O ports
in address spaces. The microkernel can recognize interrupts but does not
handle them.
WINDOWS Thread and SMP Management.
Important characteristics of Windows processes are the following
Windows processes are implemented as objects.
An executable process may contain one or more threads.
Both process and thread objects have built-in synchronization capabilities.

Windows Process and Object Threads

Windows Thread States

Windows Symmetric Multiprocessing Support


Windows supports an SMP hardware configuration. The threads of any process,
including those of the executive, can run on any processor
Solaris Thread and SMP Management
Solaris implements multilevel thread support designed to provide considerable
flexibility
in exploiting processor resources.
Solaris Multithreaded Architecture
Process: This is the normal UNIX process and includes the users address
space, stack, and process control block.
User-level threads: Implemented through a threads library in the address
space of a process, these are invisible to the OS. A user-level thread (ULT)10
is a user-created unit of execution within a process.
Lightweight processes: A lightweight process (LWP) can be viewed as a
mapping
between ULTs and kernel threads. Each LWP supports ULT and maps to one
kernel thread. LWPs are scheduled by the kernel independently and may
execute in parallel on multiprocessors.
Kernel threads: These are the fundamental entities that can be scheduled
and

dispatched to run on one of the system processors.


Figure 4.15 illustrates the relationship among these four Note that there is always
exactly one kernel thread for each LWP. An LWP is visible within a process to the
application,

Process Structure

Solaris Thread State:

Linux Thread and Process Management

A process, or task, in Linux is represented by a task_struct data structure. The


task_struct data structure contains information in a number of categories:
<< List >>

Linux Threads

Windows and Linux Comparison

Hardware and control Structures


Paging and Segmentation
Process divided in pages, only few needs to be in main memory and
rest should be in disk.
Resident set of the process The portion of a process that is actually in
main memory at any time is defined to be the resident set of the
process
Paging and segmentation improves system utilization
o More processes may be maintained in main memory
o A process may be larger than all of main memory
Characteristics of paging and segmentation
Real memory and virtual memory.

Basic Algorithm: (Page Replacement Algorithm)

Optimal: The optimal policy selects for replacement that page for which the
time to the next reference is the longest.
Least recently used (LRU): The least recently used (LRU) policy
replaces the page in memory that has not been referenced for the longest
time
First-in-first-out (FIFO): The first-in-first-out (FIFO) policy treats the page
frames allocated to a
process as a circular buffer, and pages are removed in round-robin style

Clock:

Example for the page request in sequence 2 3 2 1 5 2 4 5 3 2 5 2

Load Control:
Load control is concerned with determining the number of processes that will
be
resident in main memory, which has been referred to as the
multiprogramming
level.The load control policy is critical in effective memory management. If
too few
processes are resident at any one time, then there will be many occasions
when all
processes are blocked, and much time will be spent in swapping. On the
other hand,
if too many processes are resident, then, on average, the size of the resident
set of
each process will be inadequate and frequent faulting will occur. The result is
thrashing.

Multiprogramming Level

Thrashing is illustrated in Figure 8.21. As the multiprogramming level


increases from a small value, one would expect to see processor utilization
rise, because there is less chance that all resident processes are blocked.
However, a point is reached at which the average resident set is inadequate.
At this point, the number of page faults rises dramatically, and processor
utilization
collapses.

Process Suspension

If the degree of multiprogramming is to be reduced, one or more of the currently


resident processes must be suspended (swapped out). [CARR84] lists six
possibilities:
Lowest-priority process
Faulting Process
Last Process activated
Process with smallest resident set
Largest Process
Process with largest execution remaining window.

Unix and Solaris Memory Management:


Linux Memory Management:

Linux shares many of the characteristics of the memory management schemes of


other UNIX implementations but has its own unique features.
Linux Virtual Memory Addressing: Linux makes use of a three-level page table
structure, consisting of the following types of tables
1. Page directory
2. Page middle directory
3. Page Table
Page Allocation: Uses Buddy system for page allocation.
Kernel Memory Allocation:

Windows Vista Memory Management

The Windows virtual memory manager controls how memory is allocated and
how paging is performed.
Figure shows Windows default 32 address space. It consists of four regions:
Windows Paging: When a process is created, it can in principle make use of
the entire user space of almost 2G Bytes. This space is divided into fixed-size
pages, any of which can be brought into main memory, but the operating
system manages them in contiguous regions allocated on 64-Kbyte
boundaries. A region can be in one of three states i) Available ii) Reserved
and Committed

You might also like