0% found this document useful (0 votes)
25 views79 pages

OS Process

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 79

Computer System Structure

Computer system can be divided into four components


Hardware – provides basic computing resources
CPU, memory, I/O devices
Operating system
Controls and coordinates use of hardware among various applications
and users
Application programs – define the ways in which the system resources
are used to solve the computing problems of the users
Word processors, compilers, web browsers, database systems, video
games
Users
People, machines, other computers
User Views and System views of OS
Operating System can be viewed from two viewpoints– User views & System views

User Views: -The user’s view of the operating system depends on the type of user.
 If the user is using standalone system, then OS is designed for ease of use and
high performances.
 If the users are at different terminals connected to a mainframe or
minicomputers, by sharing information and resources, then the OS is designed
to maximize resource utilization .
 If the users are in workstations, connected to networks and servers, then the
user have a system unit of their own the OS is designed for both ease of use
and resource availability (files).
 Users of hand-held systems, expects the OS to be designed for ease of use and
performance per amount of battery life
System Views: - Operating system can be viewed as a resource
allocator and control program
 OS is a resource allocator
Manages all resources
Decides between conflicting requests for efficient and fair resource
use
 OS is a control program
Controls execution of programs to prevent errors and improper use
of the computer
Computer System Organization
 Computer-system operation
 One or more CPUs, device controllers connect through
common bus providing access to shared memory.
 Each device controller is in-charge of a specific type of
device
 The CPU and other devices execute concurrently
competing for memory cycles.
 When system is switched on, ‘Bootstrap’ program is executed. It is the
initial program to run in the system. This program is stored in read-only
memory (ROM) or in electrically erasable programmable read-only
memory (EEPROM).
Switch on ‘Bootstrap’ program

• Initializes the registers, memory and I/O devices


• Locates & loads kernel into memory
• Starts with ‘init’ process
• Waits for interrupt from user.
Interrupt handling
•The occurrence of an event is usually signaled by an
interrupt
• The interrupt can either be from the hardware or the
software. Hardware may trigger an interrupt at any time
by sending a signal to the CPU.
• Software triggers an interrupt by executing a special
operation called a system call (also called a monitor
call).
• When the CPU is interrupted, it stops what it is doing
and immediately transfers execution to a fixed location.
Storage
StorageStructure
Structure
 Computer programs must be in main memory (RAM) to
be executed.

 Main memory is the large memory that the processor can access
directly.

 It commonly is implemented in a semiconductor technology called


dynamic random-access memory (DRAM).

 Computers provide Read Only Memory (ROM), whose data cannot


be changed.
 A typical instruction-execution cycle, as executed on a
system with a Von Neumann architecture.
 first fetches an instruction from memory and stores that
instruction in the instruction register.
 After the instruction on the operands has been executed,
the result may be stored back in memory.
 most computer systems provide secondary storage as an
extension of main memory.
 The most common secondary-storage device is a
magnetic disk, which provides storage for both
programs and data.
An electronic disk can be designed to be either volatile or nonvolatile
I/O Structure
 After I/O starts, control returns to user

program only upon I/O completion.


 Wait instruction idles the CPU until
the next interrupt
 Wait loop (contention for memory
access).
 At most one I/O request is
outstanding at a time, no
simultaneous I/O processing.
 After I/O starts, control returns to user program without
waiting for I/O completion.
 System call – request to the operating system to allow user
to wait for I/O completion.
 Device-status table contains entry for each I/O device
indicating its type, address, and state.
 Operating system indexes into I/O device table to
determine device status and to modify table entry to
include interrupt.
Computer System Architecture
Single-Processor Systems
The variety of single-processor systems range from
PDAs through mainframes.
On a single processor system, there is one main
CPU capable of executing instructions from user
processes.
 It contains special-purpose processors
Multi -Processor Systems (parallel systems or tightly coupled systems)

 Systems that have two or more processors in


close communication, sharing the computer bus,
the clock, memory, and peripheral devices are
the multiprocessor systems.
 Multiprocessor systems have three main
advantages:
 Increased throughput - In multiprocessor system,
as there are multiple processors execution of
different programs take place simultaneously
 Economy of scale - Multiprocessor systems can cost less
than equivalent number of many single-processor
systems.
 Increased reliability- In multiprocessor systems functions
are shared among several processors.
 Two techniques to maintain ‘Increased Reliability’ -
graceful degradation & fault tolerant
Different types of multiprocessor systems
1)Asymmetric multiprocessing – (Master/Slave architecture)
Here each processor is assigned a specific task, by the master
processor.
 A master processor controls the other processors in the system.
 It schedules and allocates work to the slave processors.
2)Symmetric multiprocessing (SMP) – All the processors are
considered peers.
 There is no master-slave relationship.
 All the processors have their own registers and CPU, only
memory is shared.
Clustered Systems
 Clustered systems are two or more individual systems connected
together via a network and sharing software resources.
 Clustering provides high availability of resources and services.
There are two types of Clustered systems – asymmetric and symmetric
1. Asymmetric clustering – one system is in hot-standby mode
while the others are running the applications. If that server
fails, the hot-standby host becomes the active server.
2. Symmetric clustering – two or more systems are running
applications, and are monitoring each other. This mode is
more efficient.
Operating System Structure
 Multi programming: One of the most important aspects of operating
systems is the ability to multiprogram.
 Single user cannot keep CPU and I/O devices busy at all times.
 Multiprogramming increases CPU utilization by organizing jobs, so
that the CPU always has one to execute.
 The number of jobs that can be kept simultaneously in
memory.
 The operating system picks and begins to execute one of
the jobs in memory.
 the job may have to wait for some tasks, such as an I/O
operation to complete.
 In a non-multiprogram system, the CPU would sit idle.
 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.
Multitasking Systems
In Time sharing (or multitasking) systems, a single CPU
executes multiple jobs by switching among them.
Time sharing requires an interactive (or hands-on)
computer system, which provides direct communication
between the user and the system.
A time-shared operating system allows many users to
share the computer simultaneously.
A multiprocessor system is a computer system having two
or more CPUs within a single computer system, each
sharing main memory and peripherals.
Operating-System Operations

 Modern operating systems are interrupt driven.


 If there are no processes to execute, no I/O
devices to service, and no users to whom to
respond.
 An operating system will sit quietly, waiting for
something to happen.
Dual-Mode Operation
the operating system and the user programs share the
hardware and software resources of the computer system.
 The system can be assumed to work in two separate modes of
operation: 1. User mode 2. Kernel mode (supervisor mode, system
mode, or privileged mode)
 A hardware bit of the computer, called the mode bit, is
used to indicate the current mode: kernel (0) or user
(1).
 When the computer system is executing a user
application, the system is in user mode.
 At system boot time, the hardware starts in kernel
mode. The operating system is then loaded and starts
user applications in user mode.
 The dual mode of operation provides us with the
means for protecting the operating system .
Process Management
 A program under execution is a process.
 A process needs resources like CPU time, memory, files, and I/O
devices for its execution.
 These resources are given to the process when it is created or at
run time.
 When the process terminates, the operating system reclaims the
resources.
 The program stored on a disk is a passive entity.
 the program under execution is an active entity.
 y. A single-threaded process has one program counter specifying
the next instruction to execute.
 The CPU executes one instruction of the process after another, until
the process completes.
 A multithreaded process has multiple program counters, each
pointing to the next instruction to execute for a given thread.
The operating system is responsible for the following
activities in connection with process management:
 Scheduling process and threads on the CPU
 Creating and deleting both user and system processes
 Suspending and resuming processes
 Providing mechanisms for process synchronization
 Providing mechanisms for process communication
Memory Management
• Main memory is a large array of words or bytes.
• Each word or byte has its own address.
• Main memory is the storage device which can be easily
and directly accessed by the CPU.
• program executes, the central processor reads
instructions and also reads and writes data from main
memory.
• To improve both the utilization of the CPU and the speed
of the computer's response to its users.
• general-purpose computers must keep several programs
• The operating system is responsible for the
following activities in connection with memory
management
• Keeping track of which parts of memory are
currently being used by user.
• Deciding which processes and data to move into
and out of memory.
• Allocating and deallocating memory space as
needed
Storage Management

There are three types of storage management .


i) File system management.
ii) Mass-storage management.
iii) Cache management.
File-System Management

 File management is one of the most visible components of an operating


system.
 Computers can store information on several different types of physical
media.
 Magnetic disk, optical disk, and magnetic tape are the most common.
 Each of these media has its own characteristics and physical
organization.
 A file is a collection of related information defined by its creator.
 files represent programs and data.
 Data files may be numeric, alphabetic, alphanumeric, or binary.
 Files may be free-form (for example, text files), or they may be
formatted rigidly (for example, fixed fields).
Mass-Storage Management

 As the main memory is too small to accommodate all data


and programs.
 As the data that it holds are erased when power is lost,
the computer system must provide secondary storage to
back up main memory.
 Most modern computer systems use disks as the storage
medium for both programs and data.
Mass-Storage Management
Most programs—including compilers, assemblers, word
processors, editors, and formatters— are stored on a disk
until loaded into memory.
then use the disk as both the source and destination of their
processing.
The operating system is responsible for the following
activities in connection with disk management:
• Free-space management
• Storage allocation
• Disk scheduling
Caching
Caching is an important principle of computer systems
PROCESS MANAGEMENT

 A process is a program under execution.


• Its current activity is indicated by PC (Program Counter) and
the contents of the processor's registers.
The Process
Process memory is divided into four sections as shown in the figure
 The stack is used to store temporary data such as local variables,
function parameters, function return values, return address etc.
 The heap which is memory that is dynamically allocated during
process run time
 The data section stores global variables.
• The text section comprises the compiled program code
Process State
A Process has 5 states. Each process may be in one of the following states
1.New - The process is in the stage of being
created.
2.Ready - The process has all the
resources it needs to run. It is waiting to
be assigned to the processor.
3.Running – Instructions are being executed.
4.Waiting - The process is waiting for some event to
occur. For example, the process may be waiting for
keyboard input, disk access request, inter-process
messages, a timer to go off, or a child process to
finish.
5.Terminated - The process has completed its
execution.
Process Control Block

For each process there is a Process Control Block (PCB), which


stores the process-specific information as shown.
 Process State – The state of the process may be new, ready,
running, waiting, and so on.
 Program counter – The counter indicates the address of the
next instruction to be executed for this process.
• CPU registers - The registers vary in number and type,
depending on the computer architecture. They include
accumulators, index registers, stack pointers, and general-purpose
registers.
•CPU scheduling information- This information includes a
process priority, pointers to scheduling queues, and any other
scheduling parameters
 Memory-management information – This includes information
such as the value of the base and limit registers, the page tables,
or the segment tables.
 Accounting information – This information includes the amount
of CPU and real time used, time limits, account numbers, job or
process numbers, and so on.
 I/O status information – This information includes the list of I/O
devices allocated to the process, a list of open files, and so on.
Process Scheduling

Process Scheduling Queues


Job queue – set of all processes in the system
Ready queue – set of all processes residing in main
memory, ready and waiting to execute
Device queues – set of processes waiting for an I/O device
Processes migrate among the various queues
Ready Queue and Various I/O Device Queues
Queueing-diagram representation of process scheduling

A new process is initially put in the ready queue. It waits in the


ready queue until it is selected for execution and is given the
CPU. Once the process is allocated the CPU and is executing, one
of several events could occur:
 The process could issue an I/O request, and then be placed in
an I/O queue.
 The process could create a new subprocess and wait for its
termination.
 The process could be removed forcibly from the CPU, as a
result of an interrupt, and be put back in the ready queue.
Schedulers
Schedulers are software which selects an available program to be assigned to CPU..
Processes can be described as either:

 I/O-bound process – spends more time doing I/O than


computations,

 CPU-bound process – spends more time doing


computations and few I/O operations.
Advantages of medium-term scheduler

 To remove process from memory and thus reduce the degree of


multiprogramming (number of processes in memory).
 To make a proper mix of processes (CPU bound and I/O bound)
Inter process Communication

Interprocess Communication- Processes executing may be either co-


operative or independent processes.
 Independent Processes – processes that cannot affect other processes or
be affected by other processes executing in the system.
 Cooperating Processes – processes that can affect other processes or be
affected by other processes executing in the system.
Co-operation among processes are allowed for following reasons
 Information Sharing - There may be several processes which need to access the
same file. So the information must be accessible at the same time to all users..
 • Computation speedup - Often a solution to a problem can be solved faster if the
problem can be broken down into sub-tasks, which are solved simultaneously

 Modularity - A system can be divided into cooperating modules and


executed by sending information among one another.
 Convenience - Even a single user can work on multiple tasks by information
sharing.
Cooperating processes require some type of inter-process
communication. This is allowed by two models:
1. Shared Memory systems
2. Message passing systems.
Sl No Shared Memory Message passing

A region of memory is shared by Message exchange is done among


1. communicating processes, into
which the information is written the processes by using objects.
and read

2. Useful for sending large block of data Useful for sending small data.

3. System call is used only to create System call is used during every
shared memory read and write operation.

4. Message is sent faster, as there are no Message is communicated slowly.


system calls
Virtual Machines

1. idea behind a virtual machine is to abstract the hardware of a


single computer into several different execution environments.

2.A virtual machine provides an interface identical to the


underlying bare hardware.

3.The operating system host creates the illusion that a process


has its own processor and (virtual memory)

4.Host OS is the main OS installed in system and the other OS


installed in the system are called guest OS.
Virtual Machines History and Benefits
 First appeared commercially in IBM mainframes in 1972.

 Fundamentally, multiple execution environments (different


operating systems) can share the same hardware
 Protect from each other.

 the virtual machines are separated from one another,


software resources can be shared among them.
 The operating system runs on and controls the entire
machine.
 Multiple OS can be running on the developer’s system
concurrently.
 System consolidation – two or more systems are made to run
in a single system.
Simulation – Here the host system has one system architecture and
the guest system is compiled in different architecture.

Para-Virtualization This presents the guest with a system that is


similar but not identical to the guest’s preferred system.
The guest must be modified to run on the para-virtualized hardware.
Types of System Calls

The system calls can be categorized into six major categories:


1. Process Control
2. File management
3. Device management
4. Information management
5. Communications
6. Protection
Protection
Protection provides mechanisms for controlling which users / processes have
access to which system resources.
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

User Interfaces - Means by which users can issue commands to the


system. Depending on the operating system these may be a
command-line interface, Graphical User Interface (e.g. Windows,
etc.), or a batch command systems.
• Program Execution - The OS must be able to load a program into
RAM, run the program, and terminate the program, either
normally or abnormally.

• I/O Operations - The OS is responsible for transferring data to and


from I/O devices, including keyboards, terminals, printers, and
files. For specific devices, special functions are provided (device
drivers) by OS

• File-System Manipulation – Programs need to read and write files


or directories. The services required to create or delete files,
search for a file.
Communications - Inter-process communications, IPC, either
between processes running on the same processor, or between
processes running on separate processors or separate machines.

Error Detection - Both hardware and software errors must be


detected and handled appropriately by the OS. Errors may occur in
the CPU and memory hardware
OS provide services for the efficient operation of the system

Resource Allocation – Resources like CPU cycles, main memory,


storage space, and I/O devices must be allocated to multiple users
and multiple jobs at the same time

Accounting – There are services in OS to keep track of system activity and


resource usage.

Protection and Security – The owners of information (file) in multiuser or


networked computer system may want to control the use of that information.
Protection involves ensuring that all access to system resources is
controlled. Security of the system from outsiders must also be
done, by means of a password
User Operating-System Interface
There are several ways for users to interface with the operating system.
• Command-line interface, or command interpreter, allows users to directly
enter commands to be performed by the operating system.

• Graphical user interface (GUI), allows users to interface with the operating
system using pointer device and menu system
System Programs
“A collection of programs that provide a convenient
environment for program development and execution are called
system programs or system utilities.”
System programs may be divided into five categories
1. File management - programs to create, delete, copy, rename, print, list, and
generally manipulate files and directories.
2. Status information - Utilities to check on the date, time, number of users,
processes running, data logging,
File modification - e.g. text editors and other tools which can change file contents.
Programming-language support - E.g. Compilers, linkers, debuggers, profilers,
assemblers, library archive management, interpreters for common languages, and
support for make.

Program loading and execution - loaders, dynamic loaders, overlay loaders, etc., as

well as interactive debuggers.


Communications - Programs for providing connectivity between processes and users,
including mail, web browsers, remote logins, file transfers, and remote command
execution.
Operating-System Structure

Simple Structure
 Many operating systems do not have well-defined structures. They started as
small, simple, and limited systems and then grew beyond their original scope.
Eg: MS-DOS.
 In MS-DOS, the interfaces and levels of functionality are not well separated
UNIX OS consists of two separable parts: the kernel and the system programs. The
kernel is further separated into a series of interfaces and device drivers

You might also like