section02 structures
TRANSCRIPT
-
8/3/2019 Section02 Structures
1/21
2: OS Structures 1
Jerry Breecher
OPERATING SYSTEMS
STRUCTURES
-
8/3/2019 Section02 Structures
2/21
2: OS Structures 2
What Is In This Chapter?
System Components
System Calls
How Components Fit Together
Virtual Machine
OPERATING SYSTEM
Structures
-
8/3/2019 Section02 Structures
3/21
2: OS Structures 3
OPERATING SYSTEM
STRUCTURES
These are the pieces of the system well be looking at:
Process Management
Main Memory Management
File ManagementI/O System Management
Secondary Management
Networking
Protection System
Command-Interpreter System
SYSTEM
COMPONENTS
-
8/3/2019 Section02 Structures
4/21
2: OS Structures 4
OPERATING SYSTEM
STRUCTURES
PROCESS MANAGEMENT
A process is a program in execution: (A program is passive, a process active.)
A process has resources (CPU time, files) and attributes that must be managed.
Management of processes includes:
y Process Scheduling (priority, time management, . . . )
y Creation/termination
y
Block/Unblock (suspension/resumption )y Synchronization
y Communication
y Deadlock handling
y Debugging
SYSTEM
COMPONENTS
-
8/3/2019 Section02 Structures
5/21
2: OS Structures 5
MAIN MEMORY MANAGEMENT
y Allocation/de-allocation for processes, files, I/O.
y Maintenance of several processes at a time
y Keep track of who's using what memory
y Movement of process memory to/from secondary storage.
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.
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
STRUCTURESSystem
Components
-
8/3/2019 Section02 Structures
6/21
2: OS Structures 6
I/O MANAGEMENT
y Buffer caching system
y Generic device driver code
y Drivers for each device - translate read/write requests into disk position
commands.
SECONDARY STORAGE MANAGEMENTy Disks, tapes, optical, ...
y Free space management ( paging/swapping )
y
Storage allocation ( what data goes where on disk )
y Disk scheduling
OPERATING SYSTEM
STRUCTURESSystem
Components
-
8/3/2019 Section02 Structures
7/21
2: OS Structures 7
NETWORKING
y Communication system between distributed processors.
y Getting information about files/processes/etc. on a remote machine.
y Can use either a message passing or a shared memory model.
PROTECTION
y Of files, memory, CPU, etc.
y Means controlling of access
y Depends on the attributes of the file and user
SYSTEM PROGRAMSy Command Interpreters -- Program that accepts control statements
(shell, GUI interface, etc.)
y Compilers/linkers
y Communications (ftp, telnet, etc.)
OPERATING SYSTEM
STRUCTURESSystem
Components
How Do These All FitTogether?
In essence, they all provide
services for each other.
-
8/3/2019 Section02 Structures
8/21
2: OS Structures 8
Modifying the Operating System program for a particular machine. The goal is to include
all the necessary pieces, but not too many extra ones.
y Typically a System can support many possible devices, but any one installation has
only a few of these possibilities.
y Plug and play allows for detection of devices and automatic inclusion of the code
(drivers) necessary to drive these devices.
y A sysgen is usually a link of many OS routines/modules in order to produce an
executable containing the code to run the drivers.
OPERATING SYSTEM
STRUCTURESSystem
Tailoring
-
8/3/2019 Section02 Structures
9/21
2: OS Structures 9
ASystem Call is the main way a user program interacts with the Operating System.
code forsystem
call 13
operating system
user program
use parametersfrom table X
register
X
X: parameters
for call
load address X
system call 13
Figure 3.1
Figure 2.8
OPERATING SYSTEM
STRUCTURESSystem Calls
Check out the Linux system command strace!
-
8/3/2019 Section02 Structures
10/21
2: OS Structures 10
HOW A SYSTEM CALL WORKS
yObtain access to system space
yDo parameter validation
ySystem resource collection ( locks on
structures )yAsk device/system for requested item
ySuspend waiting for device
yInterrupt makes this thread ready to run
yWrap-up
yReturn to user
There are 11 (or more) steps in making the system call
read (fd, buffer, nbytes)
OPERATING SYSTEM
STRUCTURESSystem Calls
LinuxAPI
-
8/3/2019 Section02 Structures
11/21
2: OS Structures 11
Consider the ReadFile() function in the
Win32APIa function for reading from a file.
A description of the parameters passed to ReadFile()
HANDLE filethe file to be read
LPVOID buffera buffer where the data will be read into and written from
DWORD bytesToReadthe number of bytes to be read into the buffer
LPDWORD bytesReadthe number of bytes read during the last read
LPOVERLAPPED ovlindicates if overlapped I/O is being used
OPERATING SYSTEM
STRUCTURESSystem Calls
Example of Windows API
-
8/3/2019 Section02 Structures
12/21
2: OS Structures 12
OPERATING SYSTEM
STRUCTURESSystem Calls
Msg Passing Shared Memory
Two ways of passing
data between programs.
-
8/3/2019 Section02 Structures
13/21
2: OS Structures 13
OPERATING SYSTEM
STRUCTURESSystem Calls
These are examples
of various system
calls.
-
8/3/2019 Section02 Structures
14/21
2: OS Structures 14
A SIMPLE STRUCTURE:
Example of MS-DOS.
Application Programming
Resident System Programming
MS-DOS Drivers
ROM - BIOS Device Drivers
Note how all
layers can touch
the hardware.
Bad News!!
OPERATING SYSTEM
STRUCTURESHow An Operating
System Is Put
Together
-
8/3/2019 Section02 Structures
15/21
2: OS Structures 15
A LAYERED STRUCTURE:
Example of Windows 2000.
System Services
Windows
MGR
& GDI
Windows 2000 Kernel
Hardware Abstraction Layer (HAL)
IO
ManagerGraphicsDevice
Drivers
VM
Manager
Security
Reference
Monitor
Process
Manager
OPERATING SYSTEM
STRUCTURESHow An Operating
System Is Put
Together
-
8/3/2019 Section02 Structures
16/21
2: OS Structures 16
A LAYERED STRUCTURE:
Example ofUNIX.
OPERATING SYSTEM
STRUCTURESHow An Operating
System Is Put
Together
-
8/3/2019 Section02 Structures
17/21
2: OS Structures 17
In a Virtual Machine - each process "seems" to execute on its own processor with its own
memory, devices, etc.
y The resources of the physical machine are shared. Virtual devices are sliced out of the
physical ones. Virtual disks are subsets of physical ones.
y Useful for running different OS simultaneously on the same machine.
y Protection is excellent, but no sharing possible.
y Virtual privileged instructions are trapped.
Virtual User
Virtual Machine
Monitor Mode
Physical User
Physical Machine
OPERATING SYSTEM
STRUCTURESVirtual Machine
-
8/3/2019 Section02 Structures
18/21
2: OS Structures 18
OPERATING SYSTEM
STRUCTURESVirtual Machine
-
8/3/2019 Section02 Structures
19/21
2: OS Structures 19
Example of MS-DOS on top of Windows XP.
DOS APPLICATION
BIOS DRIVERS
Windows XP
Physical User
Physical Machine
OPERATING SYSTEM
STRUCTURESVirtual Machine
-
8/3/2019 Section02 Structures
20/21
2: OS Structures 20
Example of Java Virtual Machine
The Java Virtual Machine
allows Java code to be portable
between various hardware and
OS platforms.
OPERATING SYSTEM
STRUCTURESVirtual Machine
-
8/3/2019 Section02 Structures
21/21
2: OS Structures 21
OPERATING SYSTEM STRUCTURES
WRAPUP
Weve completed our second overview of an Operating System this atthe level of a high flying plane.
Weve looked at the basic building blocks of an operating system processes, memory management, file systems, and seen how they allconnect together.
Now well get into the nitty-gritty, spending considerable time on each ofthese pieces.