0% found this document useful (0 votes)
16 views53 pages

03-Aug-2021 Structuring Methods

Structuring methods in os

Uploaded by

tihate6359
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views53 pages

03-Aug-2021 Structuring Methods

Structuring methods in os

Uploaded by

tihate6359
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 53

Chapter 2: Operating-System

Structures

Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne


Chapter 2: Operating-System Structures

 Operating System Services


 User Operating System Interface
 Operating System Design and Implementation
 Operating System Structure
 Operating System Debugging
 Operating System Generation
 System Boot

Operating System Concepts – 9th Edition 2.2 Silberschatz, Galvin and Gagne
Objectives
 To describe the services an operating system
provides to users, processes, and other systems
 To discuss the various ways of structuring an
operating system
 To explain how operating systems are installed
and customized and how they boot

Operating System Concepts – 9th Edition 2.3 Silberschatz, Galvin and Gagne
Operating System Services
 Operating systems provide an environment for execution
of programs and services to programs and users
 One set of operating-system services provides functions
that are helpful to the user:
 User interface - Almost all operating systems have a
user interface (UI).
 Varies between Command-Line (CLI), Graphics
User Interface (GUI), Batch
 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)
 I/O operations - A running program may require I/O,
which may involve a file or an I/O device

Operating System Concepts – 9th Edition 2.4 Silberschatz, Galvin and Gagne
Operating System Services (Cont.)
 One set of operating-system services provides functions that
are helpful to the user (Cont.):
 File-system manipulation - The file system is of particular
interest. Programs need to read and write files and
directories, create and delete them, search them, list file
Information, permission management.
 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)
 Error detection – OS needs to be constantly aware of
possible errors
 May occur in the CPU and memory hardware, in I/O
devices, in user program
 For each type of error, OS should take the appropriate
action to ensure correct and consistent computing
 Debugging facilities can greatly enhance the user’s and
programmer’s abilities to efficiently use the system
Operating System Concepts – 9th Edition 2.5 Silberschatz, Galvin and Gagne
Operating System Services (Cont.)
 Another set of OS functions exists for ensuring the efficient
operation of the system itself via resource sharing
 Resource allocation - When multiple users or multiple
jobs running concurrently, resources must be allocated to
each of them
 Many types of resources - CPU cycles, main memory,
file storage, I/O devices.
 Accounting - To keep track of which users use how much
and what kinds of computer resources
 Protection and security - The owners of information
stored in a multiuser or networked computer system may
want to control use of that information, concurrent
processes should not interfere with each other
 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

Operating System Concepts – 9th Edition 2.6 Silberschatz, Galvin and Gagne
A View of Operating System Services

Operating System Concepts – 9th Edition 2.7 Silberschatz, Galvin and Gagne
Operating System Design and Implementation

 Design and Implementation of OS not “solvable”, but


some approaches have proven successful

 Internal structure of different Operating Systems can


vary widely

 Start the design by defining goals and specifications

 Affected by choice of hardware, type of 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

Operating System Concepts – 9th Edition 2.8 Silberschatz, Galvin and Gagne
Operating System Design and Implementation (Cont.)

 Important principle to separate


Policy: What will be done?
Mechanism: How to do it?
 Mechanisms determine how to do something,
policies decide what will be done
 The separation of policy from mechanism is a very
important principle, it allows maximum flexibility if
policy decisions are to be changed later (example
– timer)
 Specifying and designing an OS is highly creative
task of software engineering

Operating System Concepts – 9th Edition 2.9 Silberschatz, Galvin and Gagne
Implementation
 Much variation
 Early OSes in assembly language
 Then system programming languages like Algol, PL/1
 Now C, C++
 Actually usually a mix of languages
 Lowest levels in assembly
 Main body in C
 Systems programs in C, C++, scripting languages like
PERL, Python, shell scripts
 More high-level language easier to port to other hardware
 But slower
 Emulation can allow an OS to run on non-native hardware

Operating System Concepts – 9th Edition 2.10 Silberschatz, Galvin and Gagne
Operating-System Operations
 Interrupt driven (hardware and software)
 Hardware interrupt by one of the devices
 Software interrupt (exception or trap):
 Software error (e.g., division by zero)
 Request for operating system service
 Other process problems include infinite
loop, processes modifying each other or the
operating system

Operating System Concepts – 9th Edition 2.11 Silberschatz, Galvin and Gagne
Operating-System Operations (cont.)
 Dual-mode operation allows OS to protect itself and
other system components
 User mode and kernel mode
 Mode bit provided by hardware
 Provides ability to distinguish when system is
running user code or kernel code
 Some instructions designated as privileged,
only executable in kernel mode
 System call changes mode to kernel, return
from call resets it to user
 Increasingly CPUs support multi-mode operations
 i.e. virtual machine manager (VMM) mode for
guest VMs

Operating System Concepts – 9th Edition 2.12 Silberschatz, Galvin and Gagne
Transition from User to Kernel Mode
 Timer to prevent infinite loop / process hogging resources
 Timer is set to interrupt the computer after some time
period
 Keep a counter that is decremented by the physical
clock.
 Operating system set the counter (privileged instruction)
 When counter zero generate an interrupt
 Set up before scheduling process to regain control or
terminate program that exceeds allotted time

Operating System Concepts – 9th Edition 2.13 Silberschatz, Galvin and Gagne
Operating System Structure
 Operating system can be implemented with the help of
various structures. The structure of the OS depends mainly
on how the various common components of the operating
system are interconnected and melded into the kernel.
 Various ways to structure ones
 Simple structure – MS-DOS OS
 Layered structure – UNIX OS
 Microkernel –Mach OS
 Modular – Solaris OS

Operating System Concepts – 9th Edition 2.14 Silberschatz, Galvin and Gagne
Simple Structure -- MS-DOS

 MS-DOS – written to
provide the most
functionality in the least
space
 Not divided into
modules
 Although MS-DOS has
some structure, its
interfaces and levels of
functionality are not
well separated

Operating System Concepts – 9th Edition 2.15 Silberschatz, Galvin and Gagne
Advantages and Disadvantages of
Simple structure
 Advantages
 It delivers better application performance because of the
few interfaces between the application program and the
hardware.
 Easy for kernel developers to develop such an operating
system.
 Disadvantages of Simple structure:
 The structure is very complicated as no clear boundaries
exists between modules.
 It does not enforce data hiding in the operating system.

Operating System Concepts – 9th Edition 2.16 Silberschatz, Galvin and Gagne
Layered structure
 An OS can be broken into pieces and retain much more
control on system.
 The OS is broken into number of layers (levels).
 The bottom layer (layer 0) is the hardware and the topmost
layer (layer N) is the user interface.
 These layers are so designed that each layer uses the
functions of the lower level layers only.
 This simplifies the debugging process as if lower level layers
are debugged and an error occurs during debugging then the
error must be on that specific layer only as the lower level
layers have already been debugged.

Operating System Concepts – 9th Edition 2.17 Silberschatz, Galvin and Gagne
 Advantages of Layered structure:
 Layering makes it easier to enhance the operating system
as implementation of a layer can be changed easily
without affecting the other layers.
 It is very easy to perform debugging and system
verification.
 Disadvantages of Layered structure:
 In this structure the application performance is degraded
as compared to simple structure.
 It requires careful planning for designing the layers as
higher layers use the functionalities of only the lower
layers.

Operating System Concepts – 9th Edition 2.18 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.19 Silberschatz, Galvin and Gagne
Traditional UNIX System Structure
Beyond simple but not fully layered

Operating System Concepts – 9th Edition 2.20 Silberschatz, Galvin and Gagne
Microkernel System Structure
 Moves as much from the kernel into user space
 Mach example of microkernel
 Mac OS X kernel (Darwin) partly based on Mach
 Communication takes place between user modules
using message passing
 Benefits:
 Easier to extend a microkernel
 Easier to port the operating system to new
architectures
 More reliable (less code is running in kernel
mode)
 More secure
 Detriments:
 Performance overhead of user space to kernel
space communication

Operating System Concepts – 9th Edition 2.21 Silberschatz, Galvin and Gagne
Microkernel System Structure

Operating System Concepts – 9th Edition 2.22 Silberschatz, Galvin and Gagne
Modules
 Many modern operating systems implement
loadable kernel modules
 Uses object-oriented approach
 Each core component is separate
 Each talks to the others over known interfaces
 Each is loadable as needed within the kernel
 Overall, similar to layers but with more flexible
 Linux, Solaris, etc

Operating System Concepts – 9th Edition 2.23 Silberschatz, Galvin and Gagne
Solaris Modular Approach

Operating System Concepts – 9th Edition 2.24 Silberschatz, Galvin and Gagne
Hybrid Systems

 Most modern operating systems are actually not one


pure model
 Hybrid combines multiple approaches to address
performance, security, usability needs
 Linux and Solaris kernels in kernel address space,
so monolithic, plus modular for dynamic loading of
functionality
 Windows mostly monolithic, plus microkernel for
different subsystem personalities
 Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa
programming environment
 Below is kernel consisting of Mach microkernel
and BSD Unix parts, plus I/O kit and dynamically
loadable modules (called kernel extensions)

Operating System Concepts – 9th Edition 2.25 Silberschatz, Galvin and Gagne
Mac OS X Structure

Operating System Concepts – 9th Edition 2.26 Silberschatz, Galvin and Gagne
iOS

 Apple mobile OS for iPhone, iPad


 Structured on Mac OS X, added
functionality
 Does not run OS X applications
natively
 Also runs on different CPU
architecture (ARM vs. Intel)
 Cocoa Touch Objective-C API for
developing apps
 Media services layer for graphics,
audio, video
 Core services provides cloud
computing, databases
 Core operating system, based on Mac
OS X kernel

Operating System Concepts – 9th Edition 2.27 Silberschatz, Galvin and Gagne
Android
 Developed by Open Handset Alliance (mostly Google)
 Open Source
 Similar stack to IOS
 Based on Linux kernel but modified
 Provides process, memory, device-driver
management
 Adds power management
 Runtime environment includes core set of libraries and
Dalvik virtual machine
 Apps developed in Java plus Android API
 Java class files compiled to Java bytecode then
translated to executable than runs in Dalvik VM
 Libraries include frameworks for web browser (webkit),
database (SQLite), multimedia, smaller libc

Operating System Concepts – 9th Edition 2.28 Silberschatz, Galvin and Gagne
Android Architecture

Operating System Concepts – 9th Edition 2.29 Silberschatz, Galvin and Gagne
Storage Structure

Operating System Concepts – 9th Edition 2.30 Silberschatz, Galvin and Gagne
Storage Structure
 Main memory – only large storage media that the
CPU can access directly
 Random access
 Typically volatile
 Typically random-access memory in the form of
Dynamic Random-access Memory (DRAM)
 Secondary storage – extension of main memory that
provides large nonvolatile storage capacity

Operating System Concepts – 9th Edition 2.31 Silberschatz, Galvin and Gagne
Storage Structure (Cont.)
 Hard Disk Drives (HDD) – 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
 Non-volatile memory (NVM) devices– faster than hard
disks, nonvolatile
 Various technologies
 Becoming more popular as capacity and performance
increases, price drops

Operating System Concepts – 9th Edition 2.32 Silberschatz, Galvin and Gagne
Magnetic disk

Operating System Concepts – 9th Edition 2.33 Silberschatz, Galvin and Gagne
Storage Definitions and Notation Review
The basic unit of computer storage is the bit. A bit can contain one of two
values, 0 and 1. All other storage in a computer is based on collections of bits.
Given enough bits, it is amazing how many things a computer can represent:
numbers, letters, images, movies, sounds, documents, and programs, to name
a few. A byte is 8 bits, and on most computers it is the smallest convenient
chunk of storage. For example, most computers don’t have an instruction to
move a bit but do have one to move a byte. A less common term is word,
which is a given computer architecture’s native unit of data. A word is made
up of one or more bytes. For example, a computer that has 64-bit registers and
64-bit memory addressing typically has 64-bit (8-byte) words. A computer
executes many operations in its native word size rather than a byte at a time.

Computer storage, along with most computer throughput, is generally


measured and manipulated in bytes and collections of bytes. A kilobyte, or
KB , is 1,024 bytes; a megabyte, or MB, is 1,0242 bytes; a gigabyte, or GB, is
1,0243 bytes; a terabyte, or TB, is 1,0244 bytes; and a petabyte, or PB, is 1,0245
bytes. Computer manufacturers often round off these numbers and say that
a megabyte is 1 million bytes and a gigabyte is 1 billion bytes. Networking
measurements are an exception to this general rule; they are given in bits
(because networks move data a bit at a time).

Operating System Concepts – 9th Edition 2.34 Silberschatz, Galvin and Gagne
Storage Hierarchy
 Storage systems organized in hierarchy
 Speed
 Cost
 Volatility
 Caching – copying information into faster storage system;
main memory can be viewed as a cache for secondary
storage
 Device Driver for each device controller to manage I/O
 Provides uniform interface between controller and
kernel

Operating System Concepts – 9th Edition 2.35 Silberschatz, Galvin and Gagne
Storage-Device Hierarchy

Operating System Concepts – 9th Edition 2.36 Silberschatz, Galvin and Gagne
How a Modern Computer Works

A von Neumann architecture

Operating System Concepts – 9th Edition 2.37 Silberschatz, Galvin and Gagne
Direct Memory Access Structure
 Used for high-speed I/O devices able to transmit
information at close to memory speeds
 Device controller transfers blocks of data from
buffer storage directly to main memory without
CPU intervention
 Only one interrupt is generated per block, rather
than the one interrupt per byte

Operating System Concepts – 9th Edition 2.38 Silberschatz, Galvin and Gagne
Computer-System Operation
 I/O devices and the CPU can execute concurrently
 Each device controller is in charge of a particular
device type
 Each device controller has a local buffer
 Each device controller type has an operating system
device driver to manage it
 CPU moves data from/to main memory to/from local
buffers
 I/O is from the device to local buffer of controller
 Device controller informs CPU that it has finished its
operation by causing an interrupt

Operating System Concepts – 9th Edition 2.39 Silberschatz, Galvin and Gagne
Common Functions of Interrupts

 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
 A trap or exception is a software-generated interrupt
caused either by an error or a user request
 An operating system is interrupt driven

Operating System Concepts – 9th Edition 2.40 Silberschatz, Galvin and Gagne
Interrupt Handling
 The operating system preserves the state of the
CPU by storing the registers and the program
counter
 Determines which type of interrupt has
occurred:
 Separate segments of code determine what
action should be taken for each type of interrupt

Operating System Concepts – 9th Edition 2.41 Silberschatz, Galvin and Gagne
Interrupt-drive I/O Cycle

Operating System Concepts – 9th Edition 2.42 Silberschatz, Galvin and Gagne
I/O Structure
 Two methods for handling I/O
 After I/O starts, control returns to user
program only upon I/O
completion(synchronous I/O)
 After I/O starts, control returns to user
program without waiting for I/O
completion(Asynchronous I/O)

Operating System Concepts – 9th Edition 2.43 Silberschatz, Galvin and Gagne
I/O Structure (Cont.)
 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 and CPU)
 Poll the device status if it does not support
interrupt
 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 OS 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
 OS indexes into I/O device table to determine device
status and to modify table entry to include interrupt

Operating System Concepts – 9th Edition 2.44 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.45 Silberschatz, Galvin and Gagne
Operating-System Operations
 Bootstrap program – simple code to initialize the system,
load the kernel
 Kernel loads
 Starts system daemons (services provided outside of the
kernel)
 Kernel interrupt driven (hardware and software)
 Hardware interrupt by one of the devices
 Software interrupt (exception or trap):
 Software error (e.g., division by zero)
 Request for operating system service – system call
 Other process problems include infinite loop,
processes modifying each other or the operating
system

Operating System Concepts – 9th Edition 2.47 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.48 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.49 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.50 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.51 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.52 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.53 Silberschatz, Galvin and Gagne
Operating System Concepts – 9th Edition 2.54 Silberschatz, Galvin and Gagne

You might also like