Uploaded by SARAL RASTOGI (RA2211003030216)

Slides Unit 1

advertisement
Operating Systems
(21CSC202J)
UNIT -1
Contents
Introduction
Computer-System Organization, Computer-System Architecture
Operating-System Structure, Operating-System Operations
Process Management, Memory Management, Storage Management,
Protection and Security
 Kernel Data Structures, Computing Environments
 Open-Source Operating Systems, Operating-System Services
 User and Operating-System Interface
 System Calls, Types of System Calls, System Programs
 Operating-System Design and Implementation
 Operating-System Structure, Operating-System Debugging,
Operating-System Generation, System Boot




Introduction

An operating system acts as an intermediary between the user of a
computer and computer hardware.
User
OS
H/W

Objectives:

Convenience

Efficiency
Introduction

Definitions:

An operating system is a program that controls the execution of application
programs and acts as an interface between the user of a computer and the
computer hardware.

A more common definition is that the operating system is the one program
running at all times on the computer (usually called the kernel), with all else
being application programs.

An operating system is concerned with the allocation of resources and
services, such as memory, processors, devices and information. The operating
system correspondingly includes programs to manage these resources, such
as a traffic controller, a scheduler, a memory management module, I/O
programs, and a file system.
Computer-System Organization, Computer-System Architecture
Computer System organization & architecture
Computer-System Organization, Computer-System Architecture

The salient points are:

The I/O devices and the CPU both execute concurrently. Some of the
processes are scheduled for the CPU and at the same time, some are
undergoing input/output operations.

There are multiple device controllers, each in charge of a particular device
such as keyboard, mouse, printer etc.

There is buffer available for each of the devices. The input and output data
can be stored in these buffers.

The data is moved from memory to the respective device buffers by the
CPU for I/O operations and then this data is moved back from the buffers to
memory.

The device controllers use an interrupt to inform the CPU that I/O operation
is completed.
Computer-System Organization, Computer-System Architecture
Computer System organization & architecture
Computer-System Organization, Computer-System Architecture


Computer-System Organization

Computer organization refers to the operational units and their interconnections that
implement the architecture specification. It deals with how the components of a computer
system are arranged and how they interact to perform the required operations. Computer
organization is concerned with the physical implementation of the architecture design and
includes decisions about the interconnection and communication between components,
such as the bus structure, memory hierarchy, and input/output systems.

Computer organization is focused on the implementation of the architecture.

Computer organization deals with the low-level implementation details.
Computer Architecture

Computer architecture refers to the design of the internal workings of a computer system,
including the CPU, memory, and other hardware components. It involves decisions about the
organization of the hardware, such as the instruction set architecture, the data path design,
and the control unit design. Computer architecture is concerned with optimizing the
performance of a computer system and ensuring that it can execute instructions quickly and
efficiently.

Computer architecture is focused on the design of the internal workings of a computer
system.

Computer architecture is concerned with the high-level design decisions
Operating System Structure

Components

Kernel

Shell
User
Shell
Kernel
H/W
H/W
Basic Operating System Structure
Operating-System Operations

Process Management


Memory Management


Allocates a device to a process
Storage Management


keeps track of all information about files that how they are opened, updated
or closed
I/O Management


Finds free space in memory and allocate it to different processes
File Management


Allocates the processor to execute a chosen process
keeps track of disk scheduling, storage allocation and free space
management
Protection and Security

Controls the access of processes or users-to the resources
Process Management

A program does nothing unless its instructions are executed by a CPU. A
program in execution, is a process.

A process needs certain resources---including CPU time, memory, files,
and I/O devices to accomplish its task.

These resources are either given to the process when it is created or
allocated to it while it is running.

The operating system is responsible for the following activities in
connection with process management:

Scheduling processes and threads on the CPUs

Creating and deleting both user and system processes

Suspending and resuming processes

Providing mechanisms for process synchronization

Providing mechanisms for process communication
Memory Management

The main memory is central to the operation of a modern computer
system.

Main memory is a repository of quickly accessible data shared by the CPU
and I/0 devices.

The central processor reads instructions from main memory during the
instruction-fetch cycle and both reads and writes data from main
memory during the data-fetch cycle.

For a program to be executed, it must be mapped to absolute addresses
and loaded into memory. As the program executes, it accesses program
instructions and data from memory by generating these absolute
addresses. Eventually, the program terminates, its memory space is
declared available, and the next program can be loaded and executed.
Memory Management

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 and
by whom

Deciding which processes (or parts thereof) and data to move into
and out of memory

Allocating and de-allocating memory space as needed
Storage Management

Main memory is too small to accommodate all data and programs, and
because the data that it holds are lost when power is lost, the computer
system must provide secondary storage to back up main memory.

Most programs-including compilers, assemblers, word processors, editors,
and formatters-are stored on a disk until loaded into memory and 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
Protection and Security

If a computer system has multiple users and allows the concurrent
execution of multiple processes, then access to data must be regulated.

For that purpose, mechanisms ensure that files, memory segments, CPU,
and other resources can be operated on by only those processes that
have gained proper authorization from the operating system.

Protection, then, is any mechanism for controlling the access of processes
or users-to the resources defined by a computer system. This mechanism
must provide means to specify the controls to be imposed and means to
enforce the controls.

A system can have adequate protection but still be prone to failure and
allow inappropriate access. Consider a user whose authentication
information (her means of identifying herself Lo the system) is stolen. Her
data could be copied or deleted, even though file and memory
protection are working. It is the job of security ’to defend a system from
external and internal attacks.
Kernel Data Structures

The kernel data structures are very important as they store data about the
current state of the system. For example, if a new process is created in the
system, a kernel data structure is created that contains the details about
the process.

Most of the kernel data structures are only accessible by the kernel and its
subsystems. They may contain data as well as pointers to other data
structures.

The kernel stores and organizes a lot of information. So it has data about
which processes are running in the system, their memory requirements,
files in use etc.

Components:
1.
Process Table
2.
File Table
3.
V-Node and I-Node Tables
Kernel Data Structures
Kernel Data Structures


Process Table

The process table stores information about all the processes running in the
system. These include the storage information, execution status, file
information etc.

When a process forks a child, its entry in the process table is duplicated
including the file information and file pointers. So the parent and the child
process share a file.
V-Node and I-Node Tables

Both the v-node and i-node are references to the storage system of the file
and the storage mechanisms. They connect the hardware to the software.

The v-node is an abstract concept that defines the method to access file
data without worrying about the actual structure of the system. The i-node
specifies file access information like file storage device, read/write procedures
etc.
Kernel Data Structures

File Table

The file table contains entries about all the files in the system. If two or more
processes use the same file, then they contain the same file information and
the file descriptor number.

Each file table entry contains information about the file such as file status (file
read or file write), file offset etc. The file offset specifies the position for next
read or write into the file.

The file table also contains v-node and i-node pointers which point to the
virtual node and index node respectively. These nodes contain information on
how to read a file.
Computing Environments
Computing environments refer to the technology infrastructure and software
platforms that are used to develop, test, deploy, and run software applications.
Computing Environments

There are several types of computing environments, including:
1.
Mainframe: A large and powerful computer system used for critical applications
and large-scale data processing.
2.
Client-Server: A computing environment in which client devices access resources
and services from a central server. In this computing environment client requests
resource/service and server provides that respective resource/service. A server
can provide service to multiple clients at a time and here mainly communication
happens through computer network.
3.
Cloud Computing: A computing environment in which resources and services are
provided over the Internet and accessed through a web browser or client
software. This environment primarily comprised of three services i.e software-as-aservice (SaaS), infrastructure-as-a-service (IaaS), and platform-as-a-service (PaaS).
4.
Grid Computing: A computing environment in which resources and services are
shared across multiple computers to perform large-scale computations. multiple
computers from different locations works on single problem. In this system set of
computer nodes running in cluster jointly perform a given task by applying
resources of multiple computers/nodes. It is network of computing environment
where several scattered resources provide running environment for single task.
5.
Embedded Systems: A computing environment in which software is integrated
into devices and products, often with limited processing power and memory.
Computing Environments
6.
Personal Computing Environment : In personal computing environment there is a stand-alone
machine. Complete program resides on computer and executed there. Different standalone machines that constitute a personal computing environment are laptops, mobiles,
printers, computer systems, scanners etc. That we use at our homes and offices.
7.
Time-Sharing Computing Environment : In Time Sharing Computing Environment multiple users
share system simultaneously. Different users (different processes) are allotted different time
slice and processor switches rapidly among users according to it. For example, student
listening to music while coding something in an IDE.
8.
Distributed Computing Environment : In a distributed computing environment multiple nodes
are connected together using network but physically they are separated. A single task is
performed by different functional units of different nodes of distributed unit. Here different
programs of an application run simultaneously on different nodes, and communication
happens in between different nodes of this system over network to solve task.
9.
Cluster Computing Environment : In cluster computing environment cluster performs task
where cluster is a set of loosely or tightly connected computers that work together. It is
viewed as single system and performs task parallelly that’s why also it is similar to parallel
computing environment. Cluster aware applications are especially used in cluster computing
environment.
10.
Mobile Computing: A computing environment in which users access information and
applications using handheld devices such as smartphones and tablets.
Open-Source Operating Systems

The term "open source" refers to computer software or applications where the owners or
copyright holders enable the users or third parties to use, see, and edit the product's source
code. The source code of an open-source OS is publicly visible and editable. The usually
operating systems such as Apple's iOS, Microsoft's Windows, and Apple's Mac OS are closed
operating systems. Open-Source Software is licensed in such a way that it is permissible to
produce as many copies as you want and to use them wherever you like. It generally uses
fewer resources than its commercial counterpart because it lacks any code for licensing,
promoting other products, authentication, attaching advertisements, etc.

The open-source operating system allows the use of code that is freely distributed and
available to anyone and for commercial purposes. Being an open-source application or
program, the program source code of an open-source OS is available. The user may modify
or change those codes and develop new applications according to the user requirement.
Some basic examples of the open-source operating systems are Linux, Open Solaris, Free
RTOS, Open BDS, Free BSD, Minix, etc.

The user may modify the source code of the program or application.

For instance, the information is packed and stored in a proprietary (closed) operating system.
In open-source, the same thing happens. However, because the source code is visible to you,
you may better understand the process and change how data is processed.

While the former operating system is secure and hassle-free, and the latter requires some
technical knowledge, you may customize these and increase performance. There is no
specific way or framework for working on the open-source OS, but it may be customized on
the user requirements.
Operating-System Services


User interface

CLI

GUI
Program Execution:


I/O operations


Many operating systems provide a variety of file systems
Communications


A running program may require I/0, which may involve a file or an I/0 device.
File System


The system must be able to load a program into memory and to run that program. The
program must be able to end its execution, either normally or abnormally (indicating
error)
Via shared memory or through message passing
Error Detection

Error may occur in CPU, Memory hardware, I/O devices or even in user programs. For
each type of error, the operating system should take the appropriate action to ensure
correct and consistent computing.
User and Operating-System Interface

A user interface (UI) is the part of an operating system, program, or
device that allows a user to enter and receive information.

The operating system provides a graphical user interface (GUI) or a
command-line interface (CLI) to interact with the computer, making it
easier for users to access and use the computer’s resources
User and Operating-System Interface

A text-based user interface (see the image to the left) displays text, and
its commands are usually typed on a command line using a keyboard.
With a graphical user interface (see the right-hand image), the functions
are carried out by clicking or moving buttons, icons and menus by means
of a pointing device.
System Calls







In computing, a system call is a programmatic way in which a computer
program requests a service from the kernel of the operating system it is
executed on.
A system call is a way for programs to interact with the operating system.
A computer program makes a system call when it makes a request to the
operating system’s kernel.
System call provides the services of the operating system to the user
programs via Application Program Interface(API). It provides an interface
between a process and an operating system to allow user-level processes to
request services of the operating system.
System calls are the only entry points into the kernel system. All programs
needing resources must use system calls.
A system call is a mechanism used by programs to request services from the
operating system (OS).
In simpler terms, it is a way for a program to interact with the underlying
system, such as accessing hardware resources or performing privileged
operations.
Types of System Calls
Types of System Calls

Process Control


File Management


Device management is a system call that is used to deal with devices. Some examples of
device management include read, device, write, get device attributes, release device, etc.
Information Maintenance


File management is a system call that is used to handle the files. Some file management
examples include creating files, delete files, open, close, read, write, etc.
Device Management


Process control is the system call that is used to direct the processes. Some process control
examples include creating, load, abort, end, execute, process, terminate the process, etc.
Information maintenance is a system call that is used to maintain information. There are some
examples of information maintenance, including getting system data, set time or date, get
time or date, set system data, etc.
Communication

Communication is a system call that is used for communication. There are some examples of
communication, including create, delete communication connections, send, receive
messages, etc.
Types of System Calls

Examples of Windows and Unix system calls

There are various examples of Windows and Unix system calls. These are
as listed below in the table:
Process
Windows
Unix
Process Control
CreateProcess()
ExitProcess()
WaitForSingleObject()
CreateFile()
ReadFile()
WriteFile()
CloseHandle()
SetConsoleMode()
ReadConsole()
WriteConsole()
GetCurrentProcessID()
SetTimer()
Sleep()
CreatePipe()
CreateFileMapping()
MapViewOfFile()
SetFileSecurity()
InitializeSecurityDescriptor()
SetSecurityDescriptorgroup()
Fork()
Exit()
Wait()
Open()
Read()
Write()
Close()
Ioctl()
Read()
Write()
Getpid()
Alarm()
Sleep()
Pipe()
Shmget()
Mmap()
Chmod()
Umask()
Chown()
File Manipulation
Device Management
Information
Maintenance
Communication
Protection
Types of System Calls

open()


The open() system call allows you to access a file on a file system. It allocates
resources to the file and provides a handle that the process may refer to.
Many processes can open a file at once or by a single process only. It's all
based on the file system and structure.
read()


It is used to obtain data from a file on the file system. It accepts three
arguments in general:

A file descriptor.

A buffer to store read data.

The number of bytes to read from the file.
The file descriptor of the file to be read could be used to identify it and open it
using open() before reading.
Types of System Calls

wait()


write()


In some systems, a process may have to wait for another process to complete its
execution before proceeding. When a parent process makes a child process, the
parent process execution is suspended until the child process is finished. The wait()
system call is used to suspend the parent process. Once the child process has
completed its execution, control is returned to the parent process.
It is used to write data from a user buffer to a device like a file. This system call is
one way for a program to generate data. It takes three arguments in general:

A file descriptor.

A pointer to the buffer in which data is saved.

The number of bytes to be written from the buffer.
fork()

Processes generate clones of themselves using the fork() system call. It is one of the
most common ways to create processes in operating systems. When a parent
process spawns a child process, execution of the parent process is interrupted until
the child process completes. Once the child process has completed its execution,
control is returned to the parent process.
Types of System Calls

close()


exec()


It is used to end file system access. When this system call is invoked, it signifies
that the program no longer requires the file, and the buffers are flushed, the
file information is altered, and the file resources are de-allocated as a result.
When an executable file replaces an earlier executable file in an already
executing process, this system function is invoked. As a new process is not
built, the old process identification stays, but the new process replaces data,
stack, data, head, etc.
exit()

The exit() is a system call that is used to end program execution. This call
indicates that the thread execution is complete, which is especially useful in
multi-threaded environments. The operating system reclaims resources spent
by the process following the use of the exit() system function.
System Programs

System programs provide an environment where programs can be
developed and executed. In the simplest sense, system programs also
provide a bridge between the user interface and system calls. In reality,
they are much more complex. For example: A compiler is a complex system
program.

The user view of the system is actually defined by system programs and not
system calls because that is what they interact with and system programs
are closer to the user interface.
System Programs

System programs as well as application programs form bridge between the
user interface and the system calls. So, from the user view the operating
system observed is actually the system programs and not the system calls.
Types of System Programs

File Manipulation


Status Information


These system programs are used to manipulate system files. This can be done using
various commands like create, delete, copy, rename, print etc. These commands can
create files, delete files, copy the contents of one file into another, rename files, print
them etc.
The status information system programs provide required data on the current or past
status of the system. This may include the system date, system time, available memory
in system, disk space, logged in users etc.
File Modification

System programs that are used for file modification basically change the data in the file
or modify it in some other way. Text editors are a big example of file modification system
programs.
Types of System Programs

Programming Language Support


Program Loading and Execution


The system programs that deal with program loading and execution make sure that programs
can be loaded into memory and executed correctly. Loaders and Linkers are a prime
example of this type of system programs.
Communications


These system programs provide additional support features for different programming
languages. Some examples of these are compilers, debuggers etc. These compile a program
and make sure it is error free respectively.
These system programs are needed for system communications such as web browsers. Web
browsers allow systems to communicate and access information from the network as
required.
Application Programs

Application programs can perform a wide range of services as per the needs of the users.
These include programs for database systems, word processors, plotting tools,
spreadsheets, games, scientific applications etc.
Operating-System Design and Implementation

Design Goals:



Design goals are the objectives of the operating system. They must be met to fulfill design requirements
and they can be used to evaluate the design. These goals may not always be technical, but they often
have a direct impact on how users perceive their experience with an operating system. While designers
need to identify all design goals and prioritize them, they also need to ensure that these goals are
compatible with each other as well as compatible with user expectations or expert advice
Mechanisms and Policies:

Mechanisms and policies are the two main components of an operating system.

Mechanisms handle low-level functions such as scheduling, memory management, and interrupt
handling;

Policies handle higher-level functions such as resource management, security, and reliability.

A well-designed OS should provide both mechanisms and policies for each component in order for it to be
successful at its task:
Implementation:

Implementation is the process of writing source code in a high-level programming language, compiling it
into object code, and then interpreting (executing) this object code by means of an interpreter. The
purpose of an operating system is to provide services to users while they run applications on their
computers.
Operating-System Structure

Operating systems are implemented using many types of structures:

Simple Structure

Monolithic Structure

Layered Approach Structure

Micro-Kernel Structure

Exo-Kernel Structure

Virtual Machines
Operating-System Structure
Simple Structure:

It is the most straightforward operating system structure, but it lacks definition and is only
appropriate for usage with tiny and restricted systems. Since the interfaces and degrees of
functionality in this structure are clearly defined, programs are able to access I/O routines,
which may result in unauthorized access to I/O procedures.
MS-DOS uses this structure:

There are four layers that make up the MS-DOS operating system, and each has its own set of
features.

These layers include ROM BIOS device drivers, MS-DOS device drivers, application programs,
and system programs.

The MS-DOS operating system benefits from layering because each level can be defined
independently and, when necessary, can interact with one another.

If the system is built in layers, it will be simpler to design, manage, and update. Because of
this, simple structures can be used to build constrained systems that are less complex.

When a user program fails, the operating system as whole crashes.

Because MS-DOS systems have a low level of abstraction, programs and I/O procedures are
visible to end users, giving them the potential for unwanted access.
Operating-System Structure
Layering in Simple Structure
Operating-System Structure

Monolithic Structure

The monolithic operating system controls all aspects of the operating system's
operation, including file management, memory management, device management, and
operational operations.
Operating-System Structure

Layered Structure

The OS is separated into layers or levels in this kind of arrangement. Layer 0 (the lowest
layer) contains the hardware, and layer 1 (the highest layer) contains the user interface
(layer N). These layers are organized hierarchically, with the top-level layers making use
of the capabilities of the lower-level ones.
Operating-System Structure

Micro-Kernel Structure

The operating system is created using a micro-kernel framework that strips the kernel of
any unnecessary parts. Systems and user applications are used to implement these
optional kernel components. So, Micro-Kernels is the name given to these systems that
have been developed.
Operating-System Structure

Exokernel Structure


An operating system called Exokernel was created at MIT with the goal of
offering application-level management of hardware resources. The exokernel
architecture's goal is to enable application-specific customization by separating
resource management from protection. Exokernel size tends to be minimal due
to its limited operability.
Virtual Machines (VMs)

The hardware of our personal computer, including the CPU, disc drives, RAM,
and NIC (Network Interface Card), is abstracted by a virtual machine into a
variety of various execution contexts based on our needs, giving us the
impression that each execution environment is a separate computer. A virtual
box is an example of it.
Operating-System Debugging
Debugging is the process of finding the problems in a computer system and solving them.
There are many different ways in which operating systems perform debugging. Some of
these are −

Log Files

The log files record all the events that occur in an operating system. This is done by writing
all the messages into a log file. There are different types of log files. Some of these are given
as follows −

Event Logs


Transaction Logs


These stores the records of all the events that occur in the execution of a system. This is done so
that the activities of all the events can be understood to diagnose problems.
The transaction logs store the changes to the data so that the system can recover from crashes and
other errors. These logs are readable by a human.
Message Logs

These logs store both the public and private messages between the users. They are mostly plain text
files, but in some cases they may be HTML files.
Operating-System Debugging

Core Dump Files


Crash Dump Files


The whole contents of the physical memory at the time of the system crash are captured in the complete memory dump.
This is the default setting on the Windows Server System.
Kernel Memory Dump


In the event of a total system failure, the information about the state of the operating system is captured in crash dump
files. There are three types of dump that can be captured when a system crashes. These are −
Complete Memory Dump


The core dump files contain the memory address space of a process that terminates unexpectedly. The creation of the
core dump is triggered in response to program crashes by the kernel. The core dump files are used by the developers to
find the program’s state at the time of its termination so that they can find out why the termination occurred.
Only the kernel mode read and write pages that are present in the main memory at the time of the system crash are
stored in the kernel memory dump.
Small Memory Dump

This memory dump contains the list of device drivers, stop code, process and thread information, kernel stack etc.
Operating-System Debugging

Trace Listings


The trace listing record information about a program execution using logging.
This information is used by programmers for debugging. System administrators
and technical personnel can use the trace listings to find the common problems
with software using software monitoring tools.
Profiling

This is a type of program analysis that measures various parameters in a
program such as space and time complexity, frequency and duration of function
calls, usage of specific instructions etc. Profiling is done by monitoring the
source code of the required system program using a code profiler.
Operating-System Generation
System Boot

Booting is the process of starting a computer.
Sequence of Booting
System Boot

Booting Steps:
System Boot

Booting Steps:
Download