Title: Chapter 2: Operating-System Structures
1Chapter 2 Operating-System Structures
2Chapter 2 Operating-System Structures
- Operating System Services
- User Operating System Interface
- System Calls
- Types of System Calls
- System Programs
- Operating System Design and Implementation
- Operating System Structure
- Virtual Machines
3Objectives
- Describe the services an operating system
provides to users, processes, and other systems - Discuss various ways of structuring an operating
system - Explain how operating systems are installed and
customized and how they boot
4Operating System Services
- Provide functions that are helpful to users
- User interface
- Batch, Command-Line (CLI), Graphics User
Interface (GUI) - Program execution
- Load a program into memory, Run it, End
execution normally or abnormally - I/O operations
- File-system manipulation
- Create, delete, read, write, and list files and
directories - Change permissions
5Operating System Services (Cont.)
- Provide functions that are helpful to users
- Communications
- Exchange information on the same computer or
between computers over a network - Shared memory or message passing
- Error detection
- Hardware CPU, memory, I/O devices, etc.
- User program
- For each type of error, take an appropriate
action to ensure correct and consistent computing - Debugging
6Operating System Services (Cont.)
- Ensure efficient system operation via resource
sharing - Resource allocation
- CPU cycles, main memory, file storage, I/O
devices - Accounting To keep track of which users use how
much and what kinds of computer resources - Protection and security
- Essential in multi-user/networked environment
- Protection Ensure that all access to system
resources is controlled, e.g., mode bit, memory
management - Security User authentication, access control, ...
7User Operating System Interface CLI (Command
Line Interface)
- Direct command entry
- Implemented in kernel or by systems program
- Multiple flavors can be implemented, e.g.,
several command shells for UNIX - Fetch a command from user and execute it
- Built-in (i.e., implemented in kernel)
- Invoke user-level programs
- Adding new features requires no shell modification
8User Operating System Interface GUI
- User-friendly desktop metaphor interface
- Icons represent files, programs, actions, etc
- Mouse buttons over objects cause various actions
- Invented at Xerox PARC
- Many systems have both CLI and GUI
- Microsoft Windows is GUI with CLI
- UNIX/LINUX is CLI with optional GUI interfaces
- Apple Mac OS X has Aqua GUI interface with UNIX
kernel underneath
9System Calls
- Programming interface to OS services
- Typically written in C or C
- Usually use high-level Application Program
Interface (API) rather than direct system calls - Win32 API for Windows
- POSIX API for POSIX-based systems (including
virtually all versions of UNIX, Linux, and Mac OS
X) - Java API for the Java virtual machine (JVM)
10Example System Calls
- System call sequence to copy the contents of one
file to another file
11Example of Standard API
- Consider the ReadFile() function in Win32 API
-
12System Call Implementation
- System call interface invokes intended system
call in OS and returns system status and any
return values - Caller needs to know nothing about how the system
call is implemented - Use API
- Hide implementation details
13API System Call OS Relationship
14Standard C Library Example
- C program invoking printf() library call, which
calls write() system call
15System Call Parameter Passing
- Often, more information is required than simple
identity of desired system call - How to pass parameters to OS
- Pass the parameters in registers
- Number length of parameters can be limited
- Parameters stored in a block or table in memory,
and pass the blocks address as a parameter in a
register - Push parameters onto stack
16Parameter Passing via Table
17Types of System Calls
- Process control
- File management
- Device management
- Information maintenance
- Communications
18MS-DOS execution
(a) At system startup (b) running a program
19FreeBSD Running Multiple Programs
20System Programs
- Convenient environment for program development
and execution - Program loading and execution
- File manipulation
- Programming language support
- Communications
- Application programs
- Most users view of the OS is defined by system
programs, not the actual system calls
21System 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,
- Status information
- File modification
- Text editors to create and modify files
- Commands to search file contents, e.g., grep in
UNIX/Linux
22System Programs (contd)
- Programming language support
- Compilers/interpreters, assemblers, debuggers
- Program loading and execution
- Absolute loaders, relocatable loaders, linkage
editors, and overlay loaders - Communications
- Creating virtual connections among processes,
users, and computer systems - Send messages to somebodys screen, send email,
browse web pages, remote log in, file transfer
23Operating System Design and Implementation
- No silver bullet but some approaches have been
successful - Internal structure of different OSs can vary
widely - Affected by choice of hardware OS type
- First define goals and specifications
- User goals and System goals
- User goals OS should be convenient, easy to
learn, reliable, safe, and fast - System goals OS should be easy to design,
implement, and maintain, as well as flexible,
reliable, error-free, and efficient
24Operating System Design and Implementation (Cont.)
- Important 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
25Simple 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
26Layered 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
27Layered Operating System
28UNIX
- UNIX
- Limited by hardware functionality, the original
UNIX had limited structuring consisted of two
separable parts - Systems programs
- Kernel
- Consists of everything below the system-call
interface and above the physical hardware - Provides a large number of functions for one
level CPU scheduling, memory management, file
system and other OS functions
29UNIX System Structure
30Microkernel System Structure
- Moves as much from the kernel into user space
as possible - Message passing between user modules
- Benefits
- Easier to extend a microkernel
- Easier to port the OS to new architectures
- More reliable (less code is running in kernel
mode) - More secure
- Problem
- Performance overhead due to communications
between user space to kernel space
31Mac OS X Structure
- Hybrid approach (microkernel layered approach)
- Mach microkernel Memory management, RPC IPC
- BSD kernel BSD command line interface,
networking file system, POSIX APIs such as
Pthreads - In addition, kernel environment provides an I/O
kit dynamically loadable modues
32Modules
- 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,
e.g., device drivers system calls - Similar to layers but more flexible
33Solaris Modular Approach
34Virtual Machines
- Take the layered approach
- Treat hardware and OS kernel as though they were
all hardware - Provide an interface identical to the underlying
hardware - An OS creates the illusion of multiple processes
executing on its own processor with its own
(virtual) memory
35Virtual Machines (Cont.)
- (a) Nonvirtual machine (b) virtual machine
Non-virtual Machine
Virtual Machine
36Virtual Machines (Cont.)
- Provide complete protection of system resources
- Each virtual machine is isolated from all other
virtual machines - No direct sharing of resources
- A perfect vehicle for operating systems research
and development - Develop an OS on a virtual machine
- Do not disrupt normal system operation.
- Difficult to implement due to the effort required
to provide an exact duplicate to the underlying
machine
37VMware Architecture
38The Java Virtual Machine
39End of Chapter 2 Questions?