Chp2 OS-Structures
Chp2 OS-Structures
• Operating-System Components
• Operating-System Services
• System Calls
• System Programs
• Operating-System Design & Implementation
• Operating-System Structure
• Virtual Machines
• Process Management
• Main Memory Management
• File Management
• I/O System Management
• Secondary Storage Management
• Networking
• Protection System
• Command-Interpreter System
Operating System Concepts
1
Process Management
2
Main-Memory Management
File Management
• A file is a collection of related information defined by its
creator. Commonly, files represent programs (both
source and object forms) and data.
• A file consists of a sequence of bits, bytes, lines, or
records whose meanings are defined by their creators.
• The operating system is responsible for the following
activities in connections with file management:
– File creation and deletion.
– Directory creation and deletion.
– Support of primitives for manipulating files and
directories.
– Mapping files onto secondary storage.
– File backup on stable (nonvolatile) storage media.
Operating System Concepts
3
I/O System Management
Secondary-Storage Management
• Since main memory (primary storage) is volatile and
too small to accommodate all data and programs
permanently, the computer system must provide
secondary storage to back up main memory.
• Most modern computer systems use disks as the
principle on-line storage medium, for both programs
and data.
• The operating system is responsible for the following
activities in connection with disk management:
– Free space management
– Storage allocation
– Disk scheduling
4
Networking (Distributed Systems)
Protection System
5
Command-Interpreter System
6
Operating-System Services
• Program execution – system capability to load a program into
memory and to run it.
• I/O operations – since user programs cannot execute I/O
operations directly, the operating system must provide some
means to perform I/O.
• File-system manipulation – program capability to read, write,
create, and delete files.
• Communications – exchange of information between processes
executing either on the same computer or on different systems tied
together by a network. Implemented via shared memory or
message passing.
• Error detection – ensure correct computing by detecting errors in
the CPU (such as power failure) and memory hardware, in I/O
devices (such as connection failure), or in user programs.
7
System Calls
• System calls provide the interface between a running program
and the operating system.
– Generally available as assembly-language instructions.
– Languages defined to replace assembly language for
systems programming allow system calls to be made directly
(e.g., C. Bliss, PL/360, PERL)
• 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 pop off the stack by operating system.
X
X
register
Register
X:
X: Parameter
parameters
for
for call
call
Load Use
use parameters
parameters Code
code for
address
load address xX from tableXx
from table for
system
system call 13 system
call 13
System call
call 13
13
user program
User Program
operating system
Operating System
8
MS-DOS Execution
Free Memory
free memory
free memory
Free Memory
process
Process
Command
command
Interpreter
interpreter Command
command
Interpreter
interpreter
kernel
Kernel Kernel
kernel
(a)
(a) (b)
(b)
Operating System Concepts
process
ProcessD
D
Freememory
free Memory
process C
Process C
interpreter
Interpreter
process
Process BB
Kernel
kernel
9
Communication Models
Process
process AA M Process
process A A
1
Shared Memory
shared memory
2
Process
process BB M process B
Process B
2 1
Kernel
kernel M kernel
Kernel
(a)
(a) (b)
10
System Programs
• System programs provide a convenient environment for program
development and execution. They can be divided into several
categories:
– File manipulation: create, delete, copy, rename, print files.
– Status information: Some programs ask the system for date and
time, disk space, number of users.
– File modification: Text editors to create and modify the content of
files stored on disk.
– Programming language support: Compilers and assemblers are
provided to the user with the O.S.
– Program loading and execution: After a program is assembled or
compiled, it must be loaded into memory to be executed. The
system may provide loaders, linkage editors and debuggers.
– Communications: Programs provide mechanism for creating
virtual connections among processes, users, and computer
systems, such as sending messages and transferring files.
11
Operating-System Implementation
12
MS-DOS Layer Structure
Application
application Program
program
Resident Systemprogram
resident system Program
MS-DOS
MS-DOS Device
device Drivers
drivers
ROM BIOS
ROM BIOS device
Device drivers
Drivers
13
UNIX System Structure
Users
14
An Operating-System Layer
It consists of data structures and a set of routines that can be
invoked by higher-level layers.
layer MM
Layer
new ..
new
operations
operations
.
hidden
Hidden
.. layer M –M1 - 1
Layer
operations
operations .
existing
existing
..
operations
operations .
15
Venus Layer Structure
• It consists of 7 layers as follows:
---------------------------------------------------------------------------
Layer 6: user programs
---------------------------------------------------------------------------
Layer 5: device drivers and schedulers
---------------------------------------------------------------------------
Layer 4: virtual memory
---------------------------------------------------------------------------
Layer 3: I/O channel
---------------------------------------------------------------------------
Layer 2: CPU scheduling
---------------------------------------------------------------------------
Layer 1: instruction interpreter
---------------------------------------------------------------------------
Layer 0: hardware
---------------------------------------------------------------------------
16
OS/2 Layer Structure
application
application application
application application
application
application - programming
Application interface
– programming interface API extension
subsystems
subsystem subsystems
subsystem subsystems
subsystem
System
system
kernel • memory management
kernel • memory management
• task dispatching
• task dispatching
• device management
• device management
17
Virtual Machines (VM)
• 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.
• Example of disk systems in virtual machines: suppose
you have 3 disks drives in physical machine and you
want 7 disks drives in virtual machine. The solution is to
provide virtual disks, which are identical in all respects
except size, called minidisks in IBM’s VM. The sum of
the sizes of all minidisks must be less than the actual
amount of physical disk space available.
18
System Models
processes
processes
processes
processes
processes
processes processes
processes
Programming
programming
interface
interface
kernel
kernel kernel
kernel kernel
kernel
kernel
kernel Virtual machine
virtual machine
hardware
hardware hardware
hardware
(a)
(a) (b)
(b)
19
Advantages/Disadvantages of VM (Cont.)
20