0% found this document useful (0 votes)
14 views

02-Operating System Structures

Uploaded by

amgd aly
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

02-Operating System Structures

Uploaded by

amgd aly
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

Operating System

(02)

Operating System Structures


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

2
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). Ex for Command-Line Interface (CLI),
Graphics User Interface (GUI).

3
Operating System Services
– Program execution - The system must be able to load a program
into memory and to run that program, end execution.

– I/O operations - A running program may require I/O, which may


involve a file or an I/O device.

– 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.

– Communications – Processes may exchange information, on the


same computer or between computers over a network. 4
Operating System Services
– Error detection – ensure correct computing by detecting
errors in the CPU and memory hardware, in I/O devices, or in
user programs.
» For each type of error, OS should take the appropriate
action to ensure correct and consistent computing.

– Resource allocation – allocating resources to multiple users


or multiple jobs running at the same time.

5
Operating System Services
– Accounting - To keep track of which users use how much
and what kinds of computer resources.

– 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.

6
A View of Operating System Services

7
A System Calls
• System calls provide the interface between a running
program and the operating system.

 Generally available as assembly-language instructions.


 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.

8
Example of System Calls
• System call sequence to copy the contents of one file to another file.

9
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
– 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

10
API – System Call – OS Relationship

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

12
How System Call Parameter Passing
Three general methods are used to pass parameters between a running
program and the operating system.
– Pass parameters in registers.
– Store the parameters in a table in memory, and the table address
is passed as a parameter in a register.
– Push (store) the parameters onto the stack by the program, and
popped off the stack by operating system.
• Block and stack methods do not limit the number or length of
parameters being passed.

13
Parameter Passing via Table

14
Types of System Calls
• Process control
– end, abort
– load, execute
– process, terminate process
– get process attributes, set process attributes
– wait for time
– wait event, signal event
– allocate and free memory
• File management
– create file, delete file
– open, close file
– read, write, reposition
15
– get and set file attributes
Types of System Calls
• Device management
– request device, release device
– read, write, reposition
– get device attributes, set device attributes
– logically attach or detach devices
• Information maintenance
– get time or date, set time or date
– get system data, set system data
– get and set process, file, or device attributes
• Communications
– create, delete communication connection
– send, receive messages
– transfer status information 16
– attach and detach remote devices
Examples of Windows and
Unix System Calls

17
System Programs
• System programs provide a convenient environment for
program development and execution.
• They 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 operating system is defined by system
programs, not the actual system calls. 18
System Programs
File manipulation
– 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
File modification
– Text editors to create and modify files
– Special commands to search contents of files or perform
transformations of the text

19
System Programs
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.

Application programs
operating systems are supplied with programs that are useful in solving
common problems or performing common operations such as application 20
programs ex. web browsers, database systems, compilers, games.
Operating System Design and Implementation
• Internal structure of different Operating Systems can vary widely.

• 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

21
Operating System Structure
■ General-purpose OS is very large program
■ Various ways to structure ones
● Simple structure – MS-DOS
● More complex -- UNIX
● Layered – an abstrcation
● Microkernel -Mach

22
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

23
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
24
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
26
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:
27
● Performance overhead of user space to kernel space communication
Microkernel System Structure

Application File Device user


Program System Driver mode

messages messages

Interprocess memory CPU kernel


Communication managment scheduling mode

microkernel

hardware

28
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

29
Solaris Modular Approach

30
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 Berkeley
Standard Distribution (BSD) Unix parts, plus I/O kit and
dynamically loadable modules (called kernel extensions) 31
Mac OS X Structure

graphical user interface


Aqua

application environments and services

Java Cocoa Quicktime BSD

kernel environment
BSD

Mach

I/O kit kernel extensions


32
iOS
■ Apple mobile OS for iPhone, iPad
● Structured on Mac OS X, added functionality
● Does not run OS X applications natively Cocoa Touch

• Also runs on different CPU architecture (ARM Media Services


vs. Intel)
Core Services
● Cocoa Touch Objective-C API for
developing apps Core OS

● Media services layer for graphics, audio, video


● Core services provides cloud computing,
databases
● Core operating system, based on Mac OS X kernel
33
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),
34
multimedia, smaller libc
Android Architecture

Application Framework

Libraries Android runtime

SQLite openGL Core Libraries

surface media
Dalvik
manager framework
virtual machine
webkit libc

35
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 host creates the illusion that a process has
its own processor and (virtual memory).

• Each guest provided with a (virtual) copy of underlying computer.


36
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

• The virtual-machine concept provides complete protection of system


resources.

• Some sharing of file can be permitted, controlled


• Commutate with each other, other physical systems via networking
• Useful for development, testing

37
Virtual Machines
• (a) Non virtual machine (b) virtual machine

38
The Java Virtual Machine

39
Operating-System Debugging
• Debugging is finding and fixing errors, or bugs
• OSes 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
40
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

41
DTrace

■ DTrace tool in Solaris,


FreeBSD, Mac OS X allows live
instrumentation on production
systems
■ Probes fire when code is
executed within a provider,
capturing state data and
sending it to consumers of
those probes

■ Example of following
XEventsQueued system call
move from libc library to kernel
and back 2.42
Dtrace (Cont.)

■ DTrace code to record amount of time each


process with UserID 101 is in running mode
(on CPU) in nanoseconds

2.43
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

• 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

44
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
45

You might also like