Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 60

Operating System

Chapter 2
Operating System Structures

Computer Department

CHAPTER 2.SYTEM STRUCTURE


Chapter 2:
System Structures
• 2.1 System components activities
• 2.2 Operating system services.
• 2.3 System calls – Uses, process
control, file management, Device
management, Information
maintenance, communication.
• 2.4 Operating system structure.
• 2.5 Booting

CHAPTER 2.SYTEM STRUCTURE


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

CHAPTER 2.SYTEM STRUCTURE


Process Management

– program (passive) vs. process (active)


– A process is a program in execution. A
process needs certain resources, including
CPU time, memory, files, and I/O devices, to
accomplish its task.

CHAPTER 2.SYTEM STRUCTURE


Process Management

The operating system is responsible for the


following activities in connection with process
management:
• process creation and deletion.
• process suspension and resumption.
• provision of mechanisms for:
– process synchronization
– process communication
– Deadlock handling
CHAPTER 2.SYTEM STRUCTURE
Main-Memory Management

– Memory is a large array of words or bytes,


each with its own address. It is a repository of
quickly accessible data shared by the CPU
and I/O devices.
– Main memory is a volatile storage device. It
loses its contents in the case of system
failure.

CHAPTER 2.SYTEM STRUCTURE


Main-Memory Management

– The operating system is responsible for the


following activities in connection with memory
management:
• Keep track of which parts of memory are
currently being used and by whom.
• Decide which processes to load when
memory space becomes available.
• Allocate and deallocate memory space as
needed.

CHAPTER 2.SYTEM STRUCTURE


File Management
– The OS through the file system provides a
uniform logical view of information storage. It
abstracts from the physical properties of its
storage devices to define a logical storage
unit, the file.
– A file is a collection of related information
defined by its creator. Commonly, files
represent programs (both source and object
forms) and data.

CHAPTER 2.SYTEM STRUCTURE


File Management
– The operating system is responsible for the
following activities in connection with file
management:
• File creation and deletion.
• Directory creation and deletion.
• Support of primitives for manipulating files
and directories.
• Mapping files onto secondary storage.
• File backup on stable (nonvolatile) storage
media.

CHAPTER 2.SYTEM STRUCTURE


I/O System Management
– The peculiarities of the various I/O devices
are hidden from the bulk of the operating
system itself by the I/O subsystem
– The I/O system consists of:
• A buffer-caching system
• A general device-driver interface
• Drivers for specific hardware devices

CHAPTER 2.SYTEM STRUCTURE


Secondary-Storage Management

– Since main memory (primary storage) is


volatile and too small to accommodate all
data and programs permanently, the
computer system must provide secondary
storageto back up main memory.
– Most modern computer systems use disks
as the principle on-line storage medium,
for both programs and data.

CHAPTER 2.SYTEM STRUCTURE


Secondary-Storage Management

– The operating system is responsible for


the following activities in connection with
disk management:
• Free-space management
• Storage allocation
• Disk scheduling

CHAPTER 2.SYTEM STRUCTURE


Protection System
– Protection refers to a mechanism for
controlling access by programs, processes, or
users to both system and user resources.
– The protection mechanism must:
• distinguish between authorized and
unauthorized usage.
• specify the controls to be imposed.
• provide a means of enforcement.

CHAPTER 2.SYTEM STRUCTURE


Networking

– A distributed system is a collection of


processors that do not share memory or a
clock. Each processor has its own local
memory.
– The processors in the system are connected
through a communication network.
– A distributed system provides user access to
various system resources.

CHAPTER 2.SYTEM STRUCTURE


Networking

– Access to a shared resource allows:


• Computation speed-up
• Increased data availability
• Enhanced reliability

CHAPTER 2.SYTEM STRUCTURE


Command-Interpreter System

– Many commands are given to the operating


system by control statements which deal with:
• process creation and management
• I/O handling
• secondary-storage management
• main-memory management
• file-system access
• protection
• networking

CHAPTER 2.SYTEM STRUCTURE


Command-Interpreter System

– The program that reads and interprets


control statements is called variously:
• control-card interpreter
• command-line interpreter
• shell (in UNIX)
• Its function is to get and execute the next
command statement.

CHAPTER 2.SYTEM STRUCTURE


Operating System Services
• 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 -)
– I/O operations -
– File-system manipulation -

CHAPTER 2.SYTEM STRUCTURE


Operating System Services
(Cont.)

• One set of operating-system services provides


functions that are helpful to the user (Cont):
– Communications –
– Error detection –

CHAPTER 2.SYTEM STRUCTURE


Operating System Services
(Cont.)

• Another set of OS functions exists for


ensuring the efficient operation of the system
itself via resource sharing
– Resource allocation –
– Accounting -
– Protection and security -
• Protection
• Security

CHAPTER 2.SYTEM STRUCTURE


System Calls
• Programming interface to the services
provided by the OS
• Typically written in a high-level language
(C or C++)
• Mostly accessed by programs via a high-
level Application Program Interface
(API) rather than direct system call use
• Why use APIs rather than system calls?

CHAPTER 2.SYTEM STRUCTURE


Example of System Calls

• System call sequence to copy the contents of


one file to another file

CHAPTER 2.SYTEM STRUCTURE


Example of Standard API

• Consider the ReadFile() function in the


• Win32 API—a function for reading from a file

CHAPTER 2.SYTEM STRUCTURE


Example of Standard API
• A description of the parameters passed to
ReadFile()
– HANDLE file—the file to be read
– LPVOID buffer—a buffer where the data will be
read into and written from
– DWORD bytesToRead—the number of bytes to
be read into the buffer
– LPDWORD bytesRead—the number of bytes
read during the last read
– LPOVERLAPPED ovl—indicates if overlapped
I/O is being used

CHAPTER 2.SYTEM STRUCTURE


System Call Implementation

• Typically, a number associated with each


system call
– System-call interface maintains a table
indexed according to these numbers
• The system call interface invokes intended
system call in OS kernel and returns status of
the system call and any return values
• The caller need know nothing about how the
system call is implemented

CHAPTER 2.SYTEM STRUCTURE


System Call Implementation

– Just needs to obey API and understand what


OS will do as a result call
– Most details of OS interface hidden from
programmer by API
• Managed by run-time support library (set of
functions built into libraries included with
compiler)

CHAPTER 2.SYTEM STRUCTURE


API – System Call – OS Relationship

CHAPTER 2.SYTEM STRUCTURE


Standard C Library Example
• C program invoking printf() library call, which
calls write() system call

CHAPTER 2.SYTEM STRUCTURE


System Call Parameter Passing

– Parameters stored in a block, or table, in


memory, and address of block passed as a
parameter in a register
• This approach taken by Linux and Solaris
– Parameters placed, or pushed, onto the
stack by the program and popped off the
stack by the operating system
– Block and stack methods do not limit the
number or length of parameters being
passed

CHAPTER 2.SYTEM STRUCTURE


Parameter Passing via Table

CHAPTER 2.SYTEM STRUCTURE


Types of System Calls
• Process control
• File management
• Device management
• Information maintenance
• Communications

CHAPTER 2.SYTEM STRUCTURE


MS-DOS execution

(a) At system startup (b) running


a program
CHAPTER 2.SYTEM STRUCTURE
FreeBSD Running Multiple
Programs

CHAPTER 2.SYTEM STRUCTURE


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 by defining goals and specifications
• Affected by choice of hardware, type of
system

CHAPTER 2.SYTEM STRUCTURE


Operating System Design and
Implementation

• 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

CHAPTER 2.SYTEM STRUCTURE


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

CHAPTER 2.SYTEM STRUCTURE


Simple Structure

• 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

CHAPTER 2.SYTEM STRUCTURE


Simple Structure

Advantages :
• The OS has the complete control over h/w and
the application running on the system.
• It reduces the complication of the structure
designing

CHAPTER 2.SYTEM STRUCTURE


MS-DOS Layer Structure

CHAPTER 2.SYTEM STRUCTURE


UNIX

• UNIX – limited by hardware functionality, the


original UNIX operating system had limited
structuring. The UNIX OS consists of two
separable parts
– Systems programs
– The kernel

CHAPTER 2.SYTEM STRUCTURE


UNIX

• Consists of everything below the


system-call interface and above the
physical hardware
• Provides the file system, CPU
scheduling, memory management, and
other operating-system functions; a
large number of functions for one level

CHAPTER 2.SYTEM STRUCTURE


UNIX System Structure

CHAPTER 2.SYTEM STRUCTURE


Layered Approach

• The operating system is divided into a number of


layers (levels), each built on top of lower layers.
The bottom layer (layer 0), is the hardware; the
highest (layer N) is the user interface.
• With modularity, layers are selected such that
each uses functions (operations) and services of
only lower-level layers

CHAPTER 2.SYTEM STRUCTURE


Layered Operating System

CHAPTER 2.SYTEM STRUCTURE


Layered Operating System

Advantage :-
•Simplicity of construction and easy to debugging.
•The layer does not need to know the operations of
the lower level layers

Disadvantages:
•The major difficulty with layered approach involves
appropriately defining the various layer.
•Final problem with the layered approach is that they
tends to le be less efficient than other types

CHAPTER 2.SYTEM STRUCTURE


Microkernel System Structure

• Moves as much from the kernel into “user”


space
• Communication takes place between user
modules using message passing

CHAPTER 2.SYTEM STRUCTURE


Advantages:

Microkernel System Structure

CHAPTER 2.SYTEM STRUCTURE


Microkernel System Structure

• 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

CHAPTER 2.SYTEM STRUCTURE


Microkernel System Structure

Detriments:

• Performance overhead of user space to


kernel space communication

CHAPTER 2.SYTEM STRUCTURE


Modules
• Most modern operating systems implement
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

CHAPTER 2.SYTEM STRUCTURE


Modules

CHAPTER 2.SYTEM STRUCTURE


Modules
Advantages:

•Simple to design and implement.


•Simplicity provides speed on simple h/w.
•Can be expanded using module systems
•Time tested and design well known

CHAPTER 2.SYTEM STRUCTURE


Modules
Disadvantages :
•Module system may not provide runtime loading
and unloading
•The size of the kernel increase
•Lack of the extensibility.
•Bugs fixing or addition of the new
•This is the resources and time consuming

CHAPTER 2.SYTEM STRUCTURE


Operating System
Generation
• Operating systems are designed to run on
any of a class of machines; the system
must be configured for each specific
computer site
• SYSGEN program obtains information
concerning the specific configuration of the
hardware system

CHAPTER 2.SYTEM STRUCTURE


Operating System
Generation
• Booting – starting a computer by loading
the kernel
• Bootstrap program – code stored in ROM
that is able to locate the kernel, load it into
memory, and start its execution

CHAPTER 2.SYTEM STRUCTURE


System Boot
– Operating system must be made
available to hardware so hardware can
start it
– Small piece of code – bootstrap loader,
locates the kernel, loads it into memory,
and starts it
– Sometimes two-step process where
boot block at fixed location loads
bootstrap loader

CHAPTER 2.SYTEM STRUCTURE


System Boot
– When power initialized on system,
execution starts at a fixed memory
location
– Firmware used to hold initial boot code

CHAPTER 2.SYTEM STRUCTURE


SUMMARY
Operating System Concepts

Operating System Services, System Programs


and System calls

Operating System Design and Implementation

Structuring Operating Systems

CHAPTER 2.SYTEM STRUCTURE


References:
Operating System Concepts -
Silberschatz Galvin,Gange

CHAPTER 2.SYTEM STRUCTURE


End of Chapter 2

CHAPTER 2.SYTEM STRUCTURE

You might also like