Operating System Structures & User Interface
Lecture Objective / Overview
In this lecture, we shall see: uOperating System Services uSystem Calls / OS Relationship uOS Design and Implementation uOperating System Structure uUser Classes & Interfaces
Slide #2 of 38
What is part of an Operating System?
u When you install an OS, what do you get?
nSystem programs – program loader, command interpreter nLanguage processors – C compiler, assembler, linker nUtilities – text editor, terminal emulator
nSubroutine libraries – standard C library, JVM
Slide #3 of 38
Operating System Services
Slide #4 of 38
System Calls
u Programming interface to the services provided by the OS
uTypically written in a high-level language (C or C++)
u Mostly accessed by programs via a high-level Application Programming Interface (API) rather than direct system call use
u 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)
Slide #5 of 38
System Calls – Example
Slide #6 of 38
API – System Call – OS Relationship
Slide #7 of 38
System Call Implementation
uTypically, a number associated with each system call nSystem-call interface maintains a table indexed according to
these numbers
uThe system call interface invokes intended system call in OS kernel and returns status of the system call and any return values
uThe caller doesn’t need to know implementation details nJust needs to obey API and understand what OS will do! nMost details of OS interface hidden from programmer by API
nManaged by run-time support libraries (set of functions built into libraries included with compiler)
Slide #8 of 38
Examples of Windows and Unix System Calls
Slide #9 of 38
Standard C Library Example
u C program invoking printf() library call, which calls write() system call
Slide #10 of 38
Operating System Design and Implementation
u Design and Implementation of OS not “solvable”, but some approaches have proven successful
u Internal structure of Operating Systems can vary widely u Start the design by defining goals and specifications uAffected by choice of hardware, type of system
uUser goals and System goals
nUser goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
nSystem goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient
Slide #11 of 38
Implementation
uMuch variation
nEarly OSes in assembly language
nThen system programming languages like Algol, PL/1 nNow C, C++
uActually usually a mix of languages
nLowest levels in assembly
nMain body in C
nSystems programs in C, C++, scripting languages like PERL, Python, shell scripts
u More high-level language easier to port to other hardware nBut slower
u Emulation can allow an OS to run on non-native hardware
Slide #12 of 38
Operating System Structure
uGeneral-purpose OS is very large program
uVarious ways to structure ones nSimple structure – MS-DOS nMore complex – UNIX
nLayered – An Abstraction nMicrokernel – Mach OS nModular and Hybrid
Slide #13 of 38
Simple Structure – MS DOS
uMS-DOS – written to provide the most functionality in the least space
nNot divided into modules
nAlthough MS-DOS has some structure, its interfaces and levels of functionality are not well separated
Slide #14 of 38
Non Simple Structure – UNIX
u UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts
nSystems programs nThe 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
Slide #15 of 38
Traditional UNIX System Structure
uBeyond simple but not fully layered!
Slide #16 of 38
Layered Approach
uThe 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.
uWith modularity, layers are selected such that each uses
functions (operations) and services of only lower-level layers
Slide #17 of 38
Microkernel System Structure
u Moves as much from the kernel into user space uMach example of microkernel
nMac OS X kernel (Darwin) partly based on Mach
u Communication takes place between user modules using
message passing
u Benefits:
nEasier to extend a microkernel
nEasier to port the operating system to new architectures nMore reliable (less code is running in kernel mode) nMore secure
u Detriments:
nPerformance overhead of user space to kernel space communication
Slide #18 of 38
Microkernel System Structure
Application Program
user mode
File System
Device Driver
messages
Interprocess Communication
memory CPU managment scheduling
microkernel
messages
kernel mode
hardware
Slide #19 of 38
Modules
uMany modern operating systems implement loadable kernel modules
nUses object-oriented approach
nEach core component is separate
nEach talks to the others over known interfaces nEach is loadable as needed within the kernel
u Overall, similar to layers but with more flexible nLinux, Solaris, etc
Slide #20 of 38
Solaris Modular Approach
Slide #21 of 38
Hybrid Systems
u Most modern operating systems are actually not one pure model
nHybrid combines multiple approaches to address performance, security, usability needs
nLinux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality
nWindows mostly monolithic, plus microkernel for different subsystem personalities
uApple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment
nNext slides shows a kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions)
Slide #22 of 38
Mac OS X Structure
graphical user interface
Aqua
application environments and services
Java Cocoa Quicktime BSD
kernel environment Mach
BSD
I/O kit
kernel extensions
Slide #23 of 38
User Interfaces
Almost all operating systems have a user interface.
This interface can take several forms.
uCommand-line Interface (CLI)
u Batch Interface – commands and directives entered into files, which are then executed
uGraphical User Interface (GUI)
Slide #24 of 38
User Interfaces – Key Information
uAny UI requires a software link to hardware nThis link may be buried under other software
u Most OS’s provide a set of system calls that invoke low level operating system functions
u System calls can be invoked directly, but are often hidden from user
Slide #25 of 38
User Classes
1) Programmers
uProduce system or application software (and drink a lot of coffee)
nSystem programmer = Operating Systems, compilers, devices drivers etc.
►Require low level access to machine facilities e.g. System calls.
nApplication programmer = Spreadsheets, DBs, Mobile / Web Apps etc.
Slide #26 of 38
User Classes
2) Operational (Admins)
uConcerned with provision, operation and management of computing facilities
Slide #27 of 38
User Classes
3) End-users
uSomeone who applies software to some problem area. Two extremes:
nUnaware they’re interacting with a computer
nSubstantial understanding of computer
Slide #28 of 38
Types of Interface
1) System Calls:
uAll interaction with hardware has to go though system call u OS provides layer of subroutines called an API
Slide #29 of 38
Types of Interface
2) Command Language:
uMost OS’s provide an interactive terminal uCommands can be entered here
uUsed to imitate programs
uPerform housekeeping control routines on system uUNIX provides shell programs
Slide #30 of 38
Types of Interface
3) Job Control Language:
u Define requirements for work submitted to a batch system uUsed for DBs
Slide #31 of 38
Types of Interface
4) Graphical User Interface
u Interaction via windows and mouse driven environment u Desktop, Icons, GUI APIs – Java X Windows uProgrammer’s Perspective
nSlightly more complex than shell script, but more rewarding
nEvent driven programming – responsive to user actions uUser viewpoint – friendlier?
uIncreased processing load
Slide #32 of 38
Types of Interface
Slide #33 of 38
Types of Interface
5) Touchscreen Interfaces
uTouchscreen devices require new interfaces uMouse not possible or not desired uActions and selection based on gestures uVirtual keyboard for text entry
Slide #34 of 38
Types of Interface
Slide #35 of 38
Summary
What elements of a computer system have we looked at:
uOperating System Services uSystem Calls / OS Relationship uOS Design and Implementation uOperating System Structure uUser Classes & Interfaces
Slide #36 of 38
References / Links
uChapter # 2: Operating System Concepts (9th edition) by Silberschatz, Galvin & Gagne
Slide #37 of 38