0% found this document useful (0 votes)
6 views54 pages

Operating System Structures Overview

Chapter 2

Uploaded by

hailemariam
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)
6 views54 pages

Operating System Structures Overview

Chapter 2

Uploaded by

hailemariam
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

Chapter Two

Operating System Structures


Outline
Operating System Services and Interfaces
 System Calls and Programs
System Design and Implementation
System Structure
Virtual Machines
OS Generation
1
Operating System Objectives
• Convenience
• Makes the computer more convenient to use

• Efficiency
• Allows computer system resources to be used in an efficient manner

• Ability to evolve
• Permit effective development, testing, and introduction
of new system functions without interfering with service

2
Operating System Objectives

•Convenience
• Makes the computer more convenient to use

• Efficiency
• Allows computer system resources to be used in an efficient
manner

• Ability to evolve
• Permit effective development, testing, and introduction of
new system functions without interfering with service

3
Services Provided by the OS
• Program development
• Utility programs like editors and debuggers

• Program execution
• Handles the scheduling duties like loading instructions and data into main
memory, initializing I/O devices and files, and preparing other resources
must be prepared

• Access to I/O devices


• OS provides a uniform interface that hides details of I/O operations to the
devices so that programmers can access them using simple reads and
writes.

4
Services Provided by the OS
• Controlled access to files
• Reflects detailed understanding structure of the data contained in
the files on the storage medium
• In case of multiple users, the OS may provide protection
mechanisms to control access to the files

• System access
• Provides protection of resources and data from unauthorized users
and must resolve conflicts for resource contention

5
Services Provided by the OS
• Error detection and response
Errors that may occur
Internal and external hardware errors
Memory error
Device failure
Software errors
Arithmetic overflow
Access forbidden memory locations
Operating system cannot grant request of application
OS must provide a response that clears the error condition with
the least impact on running applications
The response may include:
 ending the program that caused the error
retrying the operation or
simply reporting the error to the application.
6
Services Provided by the OS

• Accounting
• Collect usage statistics
• Monitor performance
• Used to anticipate future enhancements
• Used for billing purposes

7
Operating System Objectives
• Convenience
• Makes the computer more convenient to use

•Efficiency
• Allows computer system resources to be used in an efficient manner

• Ability to evolve
• Permit effective development, testing, and introduction of new
system functions without interfering with service

8
Operating system subsystems

OS includes four essential subsystem managers


Memory Manager
Processor Manager
Device Manager
File Manager

Network Manager (fifth subsystem manager)


In all modern operating systems

Assumes responsibility for networking tasks

9
Operating system subsystems

10
Operating system subsystems

• Each manager:
• Works closely with other managers
• Performs a unique role

• Manager tasks
• Monitor its resources continuously
• Enforce policies determining:
• Who gets what, when, and how much

• Allocate the resource (when appropriate)


• Deallocate the resource (when appropriate)

11
Operating system subsystems
• Network Manager
Operating systems with networking capability
Fifth essential manager
Convenient way for users to share resources
Retains user access control

• Resources include:
Hardware (CPUs, memory areas, printers, tape drives, modems, and disk
drives)
Software (compilers, application programs, and data files)

12
Operating system subsystems

Memory Manager
In charge of main memory
Random Access Memory (RAM)

Responsibilities include:
Preserving space in main memory occupied by operating system
Checking validity and legality of memory space request
Setting up memory tracking table
Tracks usage of memory by sections
Needed in multiuser environment

Deallocating memory to reclaim it

13
Operating system subsystems

Processor manager
• In charge of allocating Central Processing Unit (CPU)
• Tracks process status
• An instance of program execution

• Two levels of responsibility:


• Handle jobs as they enter the system
• Handled by Job Scheduler

• Manage each process within those jobs


• Handled by Process Scheduler

14
Operating system subsystems
Device manager
In charge of monitoring all resources
Devices, channels, and control units
Responsibilities include:
Choosing most efficient resource allocation method
Printers, ports, disk drives, etc.
Based on scheduling policy
Allocating the device
Starting device operation
Deallocating the device

15
Operating system subsystems
• File manager
• In charge of tracking every file in the system
• Data files, program files, compilers, application programs
• Responsibilities include:
Enforcing user/program resource access restrictions
Uses predetermined access policies

Controlling user/program modification restrictions


Read-only, read-write, create, delete

Allocating resource
Opening the file
Deallocating file (by closing it)

16
Operating System Objectives
• Convenience
• Makes the computer more convenient to use

• Efficiency
• Allows computer system resources to be used in an efficient manner

•Ability to evolve
• Permit effective development, testing, and introduction of
new system functions without interfering with service

17
Ease of Evolution of OS
• Hardware upgrade plus new types of HW

• New services
• In response to demands of users or system managers
• Examples:
• Maintain good performance

• Applications require windows

• Fixes
• Any operating system has faults
• A fix to a fault my introduce another fault

18
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


Programming Interface (API) rather than direct system call use
Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux,
and Mac OS X), and Java API for the Java virtual machine (JVM)
Example of Standard API
API – System Call – OS Relationship
Examples of Windows and Unix System Calls
Standard C Library Example
• C program invoking printf() library call, which calls write()
system call
Example: MS-DOS

• Single-tasking
• Shell invoked when system
booted
• Simple method to run
program
• No process created
• Single memory space
• Loads program into
memory, overwriting all
but the kernel
• Program exit -> shell
reloaded
At system startup running a program
Example: FreeBSD
• Unix variant
• Multitasking
• User login -> invoke user’s choice of
shell
• Shell executes fork() system call to
create process
• Executes exec() to load program into
process
• Shell waits for process to terminate or
continues with user commands
• Process exits with:
• code = 0 – no error
• code > 1 – error code
System Programs
• System programs provide a convenient environment for program
development and execution. The can be divided into:
• File manipulation

• Status information

• File modification

• Programming language support

• Program loading and execution

• Communications

• Application programs

• Most users’ view of the operation system is defined by system


programs, not the actual system calls
System Programs
• Provide a convenient environment for program development and execution
• Some of them are simply user interfaces to system calls; others are considerably more
complex

• File management - Create, delete, copy, rename, print, dump, list, and generally manipulate
files and directories

• Status information
• Some ask the system for info - date, time, amount of available memory, disk space,
number of users
• Others provide detailed performance, logging, and debugging information
• Typically, these programs format and print the output to the terminal or other output
devices
• Some systems implement a registry - used to store and retrieve configuration
information
System Programs (cont’d)
• File modification
• Text editors to create and modify files

• Special commands to search contents of files or perform transformations of the text

• Programming-language support - Compilers, assemblers, debuggers and


interpreters sometimes provided

• Program loading and execution- Absolute loaders, relocatable loaders, linkage


editors, and overlay-loaders, debugging systems for higher-level and machine
language

• Communications - Provide the mechanism for creating virtual connections


among processes, users, and computer systems
• Allow users to send messages to one another’s screens, browse web pages, send
electronic-mail messages, log in remotely, transfer files from one machine to another
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
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 Structure

• General-purpose OS is very large program

• Various ways to structure ones


• Simple structure – MS-DOS
• More complex -- UNIX
• Layered – an abstraction
• Microkernel -Mach
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
Non Simple 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
• 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
Traditional UNIX System Structure
Beyond simple but not fully layered
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
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
Microkernel System Structure
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..
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)
Mac OS X Structure
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
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..
Android Architecture
Operating-System Debugging
Debugging is finding and fixing errors, or bugs

OS generate log files containing error information

Failure of an application can generate core dump file capturing memory of the
process
Operating system failure can generate crash dump file containing kernel
memory
Beyond crashes, performance tuning can optimize system performance
• Sometimes using trace listings of activities, recorded for analysis
• Profiling is periodic sampling of instruction pointer to look for statistical trends

Kernighan’s Law: “Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not
smart enough to debug it.”
Performance Tuning
Improve performance by removing
bottlenecks
OS must provide means of computing
and displaying measures of system
behavior
For example, “top” program or
Windows Task Manager
Virtual Machines

• A virtual machine takes the layered approach to its logical


conclusion. It treats hardware and the operating system kernel
as though they were all hardware

• A virtual machine provides an interface identical to the


underlying bare hardware

• The operating system creates the illusion of multiple processes,


each executing on its own processor with its own (virtual)
memory
Virtual Machines (Cont.)
• The resources of the physical computer are shared to create
the virtual machines
• CPU scheduling can create the appearance that users have their own
processor
• Spooling and a file system can provide virtual card readers and
virtual line printers
• A normal user time-sharing terminal serves as the virtual machine
operator’s console
Virtual Machines (Cont.)

Non-virtual Machine Virtual Machine

(a) Nonvirtual machine (b) virtual machine


Virtual Machines (Cont.)
The virtual-machine concept provides complete protection of system
resources since each virtual machine is isolated from all other virtual
machines. This isolation, however, permits no direct sharing of
resources.
A virtual-machine system is a perfect vehicle for operating-systems
research and development. System development is done on the virtual
machine, instead of on a physical machine and so does not disrupt
normal system operation.
The virtual machine concept is difficult to implement due to the effort
required to provide an exact duplicate to the underlying machine
VMware Architecture
The Java Virtual Machine
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

• 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
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
• When power initialized on system, execution starts at a
fixed memory location
• Firmware used to hold initial boot code
Than
End k You
of Ch !!!
apter
2

54

You might also like