Operating-System
Structures
Operating System Services
Execution of programs and services to programs and users
provide functions :
User interface
Program execution
I/O operations
File-system manipulation
Communications
Error detection
A View of OS Services
User Interface
• Almost all operating systems have a user interface
(UI).
• Command-Line Interface(CLI)
• Graphical User Interface (GUI)
• Touchscreen Interfaces
• Some systems provide two or all three of these
variations.
User OS Interface - CLI
Command interpreter allows direct
command entry to
implemented in kernel
systems program
User OS Interface - GUI
User-friendly desktop metaphor interface
Usually mouse, keyboard, and monitor
Icons represent files, programs, actions, etc
Various mouse buttons over objects in the interface
cause various actions
Touchscreen Interfaces
Touchscreen devices require new interfaces
Mouse not possible or not desired
Actions and selection based on gestures
Virtual keyboard for text entry
Voice commands.
System Calls
Programming interface to the services
provided by the OS
Mostly accessed by programs via a high-level
Application Programming Interface (API)
System Call Implementation
The system call interface invokes the 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
Managed by run-time support library (set of functions built into
libraries included with compiler)
API – System Call – OS Relationship
System Call Parameter Passing
Methods used to pass parameters to the OS
Simplest: pass the parameters in registers
Parameters stored in a block, or table, in
memory, and address of block
Parameters placed, or pushed, onto the stack
Block and stack methods
Types of System Calls
Process control
create process, terminate process
end, abort
load, execute
get process attributes, set process attributes
wait for time
wait event, signal event
allocate and free memory
Dump memory if error
Debugger for determining bugs, single step execution
Locks for managing access to shared data between
processes
Types of System Calls
File management
create file, delete file
open, close file
read, write, reposition
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
Types of System Calls
Information maintenance
get time or date, set time or date
get system data, set system data
get and set process, file, or device attributes
Types of System Calls
Communications
create, delete communication connection
send, receive messages if message passing model to host
name or process name
From client to server
Shared-memory model create and gain access to memory
regions
transfer status information
attach and detach remote devices
Types of System Calls
Protection
Control access to resources
Get and set permissions
Allow and deny user access
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
Program exit -> shell At system startup running a program
reloaded
System Programs
provide a convenient environment for
program development and execution.
File manipulation
Status information sometimes stored in a File
modification
Programming language support
Program loading and execution
Communications
Background services
Application programs
OS Design and Implementation
Internal structure of different OS can vary
widely
Start the design by defining goals and
specifications
Affected by choice of hardware, type of
system
OS 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
OS Design and Implementation
principle to separate
Policy: What will be done?
Mechanism: How to do it?
Specifying and designing an OS is highly creative
task of software engineering
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
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
iOS
Apple mobile OS for iPhone, iPad
Structured on Mac OS X
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 Google (Open Source)
Similar stack to IOS
Based on Linux kernel
Runtime environment includes core set of libraries
and Dalvik virtual machine
Libraries include frameworks
web browser (webkit)
database (SQLite)
multimedia
Android Architecture
Applications
Application Framework
Libraries Android runtime
SQLite openGL Core Libraries
surface media
Dalvik
manager framework
virtual machine
webkit libc
Linux kernel
Operating-System Debugging
finding and fixing errors
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
Performance Tuning
Improve performance by
removing bottlenecks
displaying measures of
system behavior
For example, “top”
program or Windows
Task Manager