Appendix A: Unixbsd
Appendix A: Unixbsd
UNIX History
Design Principles
Programmer Interface
User Interface
Process Management
Memory Management
File System
I/O System
Interprocess Communication
Operating System Concepts – 7th Edition, Feb 11, 2005 A.2 Silberschatz, Galvin and Gagne ©2005
UNIX History
Operating System Concepts – 7th Edition, Feb 11, 2005 A.3 Silberschatz, Galvin and Gagne ©2005
History of UNIX Versions
Operating System Concepts – 7th Edition, Feb 11, 2005 A.4 Silberschatz, Galvin and Gagne ©2005
Early Advantages of UNIX
Operating System Concepts – 7th Edition, Feb 11, 2005 A.5 Silberschatz, Galvin and Gagne ©2005
UNIX Design Principles
Operating System Concepts – 7th Edition, Feb 11, 2005 A.6 Silberschatz, Galvin and Gagne ©2005
Programmer Interface
Operating System Concepts – 7th Edition, Feb 11, 2005 A.7 Silberschatz, Galvin and Gagne ©2005
4.4BSD Layer Structure
Operating System Concepts – 7th Edition, Feb 11, 2005 A.8 Silberschatz, Galvin and Gagne ©2005
System Calls
Operating System Concepts – 7th Edition, Feb 11, 2005 A.9 Silberschatz, Galvin and Gagne ©2005
File Manipulation
Operating System Concepts – 7th Edition, Feb 11, 2005 A.10 Silberschatz, Galvin and Gagne ©2005
Typical UNIX Directory Structure
Operating System Concepts – 7th Edition, Feb 11, 2005 A.11 Silberschatz, Galvin and Gagne ©2005
Process Control
Operating System Concepts – 7th Edition, Feb 11, 2005 A.12 Silberschatz, Galvin and Gagne ©2005
Illustration of Process Control Calls
Operating System Concepts – 7th Edition, Feb 11, 2005 A.13 Silberschatz, Galvin and Gagne ©2005
Process Control (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.14 Silberschatz, Galvin and Gagne ©2005
Process Control (Cont.)
setuid bit sets the effective user identifier of the process to the
user identifier of the owner of the file, and leaves the real user
identifier as it was
setuid scheme allows certain processes to have more than
ordinary privileges while still being executable by ordinary users
Operating System Concepts – 7th Edition, Feb 11, 2005 A.15 Silberschatz, Galvin and Gagne ©2005
Signals
Operating System Concepts – 7th Edition, Feb 11, 2005 A.16 Silberschatz, Galvin and Gagne ©2005
Process Groups
Operating System Concepts – 7th Edition, Feb 11, 2005 A.17 Silberschatz, Galvin and Gagne ©2005
Process Groups (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.18 Silberschatz, Galvin and Gagne ©2005
Information Manipulation
Operating System Concepts – 7th Edition, Feb 11, 2005 A.19 Silberschatz, Galvin and Gagne ©2005
Library Routines
Operating System Concepts – 7th Edition, Feb 11, 2005 A.20 Silberschatz, Galvin and Gagne ©2005
User Interface
Operating System Concepts – 7th Edition, Feb 11, 2005 A.21 Silberschatz, Galvin and Gagne ©2005
Shells and Commands
Operating System Concepts – 7th Edition, Feb 11, 2005 A.22 Silberschatz, Galvin and Gagne ©2005
Shells and Commands (Cont.)
The shell usually suspends its own execution until the command
completes
Operating System Concepts – 7th Edition, Feb 11, 2005 A.23 Silberschatz, Galvin and Gagne ©2005
Standard I/O
Operating System Concepts – 7th Edition, Feb 11, 2005 A.24 Silberschatz, Galvin and Gagne ©2005
Standard I/O Redirection
Operating System Concepts – 7th Edition, Feb 11, 2005 A.25 Silberschatz, Galvin and Gagne ©2005
Pipelines, Filters, and Shell Scripts
Can coalesce individual commands via a vertical bar that tells the
shell to pass the previous command’s output as input to the
following command
% ls | pr | lpr
Filter – a command such as pr that passes its standard input to its
standard output, performing some processing on it
Writing a new shell with a different syntax and semantics would
change the user view, but not change the kernel or programmer
interface
X Window System is a widely accepted iconic interface for UNIX
Operating System Concepts – 7th Edition, Feb 11, 2005 A.26 Silberschatz, Galvin and Gagne ©2005
Process Management
Operating System Concepts – 7th Edition, Feb 11, 2005 A.27 Silberschatz, Galvin and Gagne ©2005
Process Control Blocks
Operating System Concepts – 7th Edition, Feb 11, 2005 A.28 Silberschatz, Galvin and Gagne ©2005
System Data Segment
Operating System Concepts – 7th Edition, Feb 11, 2005 A.29 Silberschatz, Galvin and Gagne ©2005
Finding parts of a process using process structure
Operating System Concepts – 7th Edition, Feb 11, 2005 A.30 Silberschatz, Galvin and Gagne ©2005
Allocating a New Process Structure
fork allocates a new process structure for the child process, and
copies the user structure
z new page table is constructed
z new main memory is allocated for the data and stack segments
of the child process
z copying the user structure preserves open file descriptors, user
and group identifiers, signal handling, etc
Operating System Concepts – 7th Edition, Feb 11, 2005 A.31 Silberschatz, Galvin and Gagne ©2005
Allocating a New Process Structure (Cont.)
vfork does not copy the data and stack to t he new process; the
new process simply shares the page table of the old one
z new user structure and a new process structure are still created
z commonly used by a shell to execute a command and to wait
for its completion
A parent process uses vfork to produce a child process; the child
uses execve to change its virtual address space, so there is no
need for a copy of the parent
Using vfork with a large parent process saves CPU time, but can
be dangerous since any memory change occurs in both processes
until execve occurs
execve creates no new process or user structure; rather the text
and data of the process are replaced
Operating System Concepts – 7th Edition, Feb 11, 2005 A.32 Silberschatz, Galvin and Gagne ©2005
CPU Scheduling
Operating System Concepts – 7th Edition, Feb 11, 2005 A.33 Silberschatz, Galvin and Gagne ©2005
Memory Management
Operating System Concepts – 7th Edition, Feb 11, 2005 A.34 Silberschatz, Galvin and Gagne ©2005
Memory Management (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.35 Silberschatz, Galvin and Gagne ©2005
Paging
Operating System Concepts – 7th Edition, Feb 11, 2005 A.36 Silberschatz, Galvin and Gagne ©2005
File System
The UNIX file system supports two main objects: files and
directories
Operating System Concepts – 7th Edition, Feb 11, 2005 A.37 Silberschatz, Galvin and Gagne ©2005
Blocks and Fragments
Operating System Concepts – 7th Edition, Feb 11, 2005 A.38 Silberschatz, Galvin and Gagne ©2005
Blocks and Fragments (Cont.)
The block and fragment sizes are set during file-system creation
according to the intended use of the file system:
z If many small files are expected, the fragment size should be
small
z If repeated transfers of large files are expected, the basic block
size should be large
The maximum block-to-fragment ratio is 8 : 1; the minimum block
size is 4K (typical choices are 4096 : 512 and 8192 : 1024)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.39 Silberschatz, Galvin and Gagne ©2005
Inodes
Operating System Concepts – 7th Edition, Feb 11, 2005 A.40 Silberschatz, Galvin and Gagne ©2005
Directories
Operating System Concepts – 7th Edition, Feb 11, 2005 A.41 Silberschatz, Galvin and Gagne ©2005
Directories (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.42 Silberschatz, Galvin and Gagne ©2005
Mapping of a File Descriptor to an Inode
System calls that refer to open files indicate the file is passing a file
descriptor as an argument
The file descriptor is used by the kernel to index a table of open
files for the current process
Each entry of the table contains a pointer to a file structure
This file structure in turn points to the inode
Since the open file table has a fixed length which is only setable at
boot time, there is a fixed limit on the number of concurrently open
files in a system
Operating System Concepts – 7th Edition, Feb 11, 2005 A.43 Silberschatz, Galvin and Gagne ©2005
File-System Control Blocks
Operating System Concepts – 7th Edition, Feb 11, 2005 A.44 Silberschatz, Galvin and Gagne ©2005
Disk Structures
The one file system that a user ordinarily sees may actually consist
of several physical file systems, each on a different device
Partitioning a physical device into multiple file systems has several
benefits
z Different file systems can support different uses
z Reliability is improved
z Can improve efficiency by varying file-system parameters
z Prevents one program form using all available space for a large
file
z Speeds up searches on backup tapes and restoring partitions
from tape
Operating System Concepts – 7th Edition, Feb 11, 2005 A.45 Silberschatz, Galvin and Gagne ©2005
Disk Structures (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.46 Silberschatz, Galvin and Gagne ©2005
Mapping File System to Physical Devices
Operating System Concepts – 7th Edition, Feb 11, 2005 A.47 Silberschatz, Galvin and Gagne ©2005
Implementations
The user interface to the file system is simple and well defined,
allowing the implementation of the file system itself to be changed
without significant effect on the user
For Version 7, the size of inodes doubled, the maximum file and file
system sized increased, and the details of free-list handling and
superblock information changed
In 4.0BSD, the size of blocks used in the file system was increased
form 512 bytes to 1024 bytes — increased internal fragmentation, but
doubled throughput
4.2BSD added the Berkeley Fast File System, which increased speed,
and included new features
z New directory system calls
z truncate calls
z Fast File System found in most implementations of UNIX
Operating System Concepts – 7th Edition, Feb 11, 2005 A.48 Silberschatz, Galvin and Gagne ©2005
Layout and Allocation Policy
Operating System Concepts – 7th Edition, Feb 11, 2005 A.49 Silberschatz, Galvin and Gagne ©2005
4.3BSD Cylinder Group
Operating System Concepts – 7th Edition, Feb 11, 2005 A.50 Silberschatz, Galvin and Gagne ©2005
I/O System
The I/O system hides the peculiarities of I/O devices from the bulk
of the kernel
Operating System Concepts – 7th Edition, Feb 11, 2005 A.51 Silberschatz, Galvin and Gagne ©2005
4.3 BSD Kernel I/O Structure
Operating System Concepts – 7th Edition, Feb 11, 2005 A.52 Silberschatz, Galvin and Gagne ©2005
Block Buffer Cache
Operating System Concepts – 7th Edition, Feb 11, 2005 A.53 Silberschatz, Galvin and Gagne ©2005
Block Buffer Cache (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.54 Silberschatz, Galvin and Gagne ©2005
Raw Device Interfaces
Operating System Concepts – 7th Edition, Feb 11, 2005 A.55 Silberschatz, Galvin and Gagne ©2005
C-Lists
Operating System Concepts – 7th Edition, Feb 11, 2005 A.56 Silberschatz, Galvin and Gagne ©2005
Interprocess Communication
Operating System Concepts – 7th Edition, Feb 11, 2005 A.57 Silberschatz, Galvin and Gagne ©2005
Sockets
Operating System Concepts – 7th Edition, Feb 11, 2005 A.58 Silberschatz, Galvin and Gagne ©2005
Socket Types
Operating System Concepts – 7th Edition, Feb 11, 2005 A.59 Silberschatz, Galvin and Gagne ©2005
Socket System Calls
Operating System Concepts – 7th Edition, Feb 11, 2005 A.60 Silberschatz, Galvin and Gagne ©2005
Socket System Calls (Cont.)
Operating System Concepts – 7th Edition, Feb 11, 2005 A.61 Silberschatz, Galvin and Gagne ©2005
Network Support
Operating System Concepts – 7th Edition, Feb 11, 2005 A.62 Silberschatz, Galvin and Gagne ©2005
Network Reference models and Layering
Operating System Concepts – 7th Edition, Feb 11, 2005 A.63 Silberschatz, Galvin and Gagne ©2005
End of Appendix A