Bài giảng Nguyên lý hệ điều hành - Nguyễn Hải Châu - Tuần 14,15: Linux

The Linux System

„ History

„ Design Principles

„ Kernel Modules

„ Process Management

„ Scheduling

„ Memory Management

„ File Systems

„ Input and Output

„ Interprocess Communication

„ Network Structure

„ Security

pdf10 trang | Chuyên mục: Hệ Điều Hành | Chia sẻ: dkS00TYs | Lượt xem: 1815 | Lượt tải: 0download
Tóm tắt nội dung Bài giảng Nguyên lý hệ điều hành - Nguyễn Hải Châu - Tuần 14,15: Linux, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
constant, architecture-
dependent region of the virtual address space of every 
process for its own internal use.
„ This kernel virtual-memory area contains two regions:
) A static area that contains page table references to every 
available physical page of memory in the system, so that 
there is a simple translation from physical to virtual 
addresses when running kernel code.
) The reminder of the reserved section is not reserved for any 
specific purpose; its page-table entries can be modified to 
point to any other areas of memory.
Silberschatz, Galvin and Gagne ©200220.38Operating System Concepts
Executing and Loading User Programs
„ Linux maintains a table of functions for loading programs; 
it gives each function the opportunity to try loading the 
given file when an exec system call is made.
„ The registration of multiple loader routines allows Linux to 
support both the ELF and a.out binary formats.
„ Initially, binary-file pages are mapped into virtual memory; 
only when a program tries to access a given page will a 
page fault result in that page being loaded into physical 
memory.
„ An ELF-format binary file consists of a header followed by 
several page-aligned sections; the ELF loader works by 
reading the header and mapping the sections of the file 
into separate regions of virtual memory.
Silberschatz, Galvin and Gagne ©200220.39Operating System Concepts
Memory Layout for ELF Programs
Silberschatz, Galvin and Gagne ©20.40Operating System Concepts
Static and Dynamic Linking
„ A program whose necessary library functions are 
embedded directly in the program’s executable binary file 
is statically linked to its libraries.
„ The main disadvantage of static linkage is that every 
program generated must contain copies of exactly the 
same common system library functions.
„ Dynamic linking is more efficient in terms of both physical 
memory and disk-space usage because it loads the 
system libraries into memory only once.
Silberschatz, Galvin and Gagne 20.41Operating System Concepts
File Systems
„ To the user, Linux’s file system appears as a hierarchical 
directory tree obeying UNIX semantics.
„ Internally, the kernel hides implementation details and 
manages the multiple different file systems via an 
abstraction layer, that is, the virtual file system (VFS).
„ The Linux VFS is designed around object-oriented 
principles and is composed of two components:
) A set of definitions that define what a file object is allowed to 
look like
 The inode-object and the file-object structures represent 
individual files
 the file system object represents an entire file system
) A layer of software to manipulate those objects.
Silberschatz, Galvin and Gagne ©200220.42Operating System Concepts
The Linux Ext2fs File System
„ Ext2fs uses a mechanism similar to that of BSD Fast 
File System (ffs) for locating data blocks belonging to a 
specific file.
„ The main differences between ext2fs and ffs concern 
their disk allocation policies.
) In ffs, the disk is allocated to files in blocks of 8Kb, with 
blocks being subdivided into fragments of 1Kb to store 
small files or partially filled blocks at the end of a file.
) Ext2fs does not use fragments; it performs its allocations 
in smaller units. The default block size on ext2fs is 1Kb, 
although 2Kb and 4Kb blocks are also supported.
) Ext2fs uses allocation policies designed to place logically 
adjacent blocks of a file into physically adjacent blocks on 
disk, so that it can submit an I/O request for several disk 
blocks as a single operation.
8Silberschatz, Galvin and Gagne ©200220.43Operating System Concepts
Ext2fs Block-Allocation Policies
Silberschatz, Galvin and Gagne ©200220.44Operating System Concepts
The Linux Proc File System
„ The proc file system does not store data, rather, its 
contents are computed on demand according to user file 
I/O requests.
„ proc must implement a directory structure, and the file 
contents within; it must then define a unique and 
persistent inode number for each directory and files it 
contains.
) It uses this inode number to identify just what operation is 
required when a user tries to read from a particular file 
inode or perform a lookup in a particular directory inode.
) When data is read from one of these files, proc collects the 
appropriate information, formats it into text form and places 
it into the requesting process’s read buffer.
Silberschatz, Galvin and Gagne ©200220.45Operating System Concepts
Input and Output
„ The Linux device-oriented file system accesses disk 
storage through two caches:
) Data is cached in the page cache, which is unified with the 
virtual memory system
) Metadata is cached in the buffer cache, a separate cache 
indexed by the physical disk block.
„ Linux splits all devices into three classes:
) block devices allow random access to completely 
independent, fixed size blocks of data
) character devices include most other devices; they don’t 
need to support the functionality of regular files.
) network devices are interfaced via the kernel’s networking 
subsystem
Silberschatz, Galvin and Gagne ©200220.46Operating System Concepts
Device-Driver Block Structure
Silberschatz, Galvin and Gagne ©200220.47Operating System Concepts
Block Devices
„ Provide the main interface to all disk devices in a system.
„ The block buffer cache serves two main purposes:
) it acts as a pool of buffers for active I/O
) it serves as a cache for completed I/O
„ The request manager manages the reading and writing of 
buffer contents to and from a block device driver.
Silberschatz, Galvin and Gagne ©200220.48Operating System Concepts
Character Devices
„ A device driver which does not offer random access to 
fixed blocks of data.
„ A character device driver must register a set of functions 
which implement the driver’s various file I/O operations.
„ The kernel performs almost no preprocessing of a file 
read or write request to a character device, but simply 
passes on the request to the device.
„ The main exception to this rule is the special subset of 
character device drivers which implement terminal 
devices, for which the kernel maintains a standard 
interface.
9Silberschatz, Galvin and Gagne ©200220.49Operating System Concepts
Interprocess Communication
„ Like UNIX, Linux informs processes that an event has 
occurred via signals.
„ There is a limited number of signals, and they cannot 
carry information: Only the fact that a signal occurred is 
available to a process.
„ The Linux kernel does not use signals to communicate 
with processes with are running in kernel mode, rather, 
communication within the kernel is accomplished via 
scheduling states and wait.queue structures.
Silberschatz, Galvin and Gagne ©20.50Operating System Concepts
Passing Data Between Processes
„ The pipe mechanism allows a child process to inherit a 
communication channel to its parent, data written to one 
end of the pipe can be read a the other.
„ Shared memory offers an extremely fast way of 
communicating; any data written by one process to a 
shared memory region can be read immediately by any 
other process that has mapped that region into its 
address space.
„ To obtain synchronization, however, shared memory 
must be used in conjunction with another Interprocess-
communication mechanism.
Silberschatz, Galvin and Gagne ©20.51Operating System Concepts
Shared Memory Object
„ The shared-memory object acts as a backing store for 
shared-memory regions in the same way as a file can act 
as backing store for a memory-mapped memory region.
„ Shared-memory mappings direct page faults to map in 
pages from a persistent shared-memory object.
„ Shared-memory objects remember their contents even if 
no processes are currently mapping them into virtual 
memory.
Silberschatz, Galvin and Gagne ©200220.52Operating System Concepts
Network Structure
„ Networking is a key area of functionality for Linux.
) It supports the standard Internet protocols for UNIX to UNIX 
communications.
) It also implements protocols native to nonUNIX operating 
systems, in particular, protocols used on PC networks, such 
as Appletalk and IPX.
„ Internally, networking in the Linux kernel is implemented 
by three layers of software:
) The socket interface
) Protocol drivers
) Network device drivers
Silberschatz, Galvin and Gagne 20.53Operating System Concepts
Network Structure (Cont.)
„ The most important set of protocols in the Linux 
networking system is the internet protocol suite.
) It implements routing between different hosts anywhere on 
the network.
) On top of the routing protocol are built the UDP, TCP and 
ICMP protocols.
Silberschatz, Galvin and Gagne ©200220.54Operating System Concepts
Security
„ The pluggable authentication modules (PAM) system is 
available under Linux.
„ PAM is based on a shared library that can be used by any 
system component that needs to authenticate users.
„ Access control under UNIX systems, including Linux, is 
performed through the use of unique numeric identifiers 
(uid and gid).
„ Access control is performed by assigning objects a 
protections mask, which specifies which access modes—
read, write, or execute—are to be granted to processes 
with owner, group, or world access.
10
Silberschatz, Galvin and Gagne 20.55Operating System Concepts
Security (Cont.)
„ Linux augments the standard UNIX setuid mechanism in 
two ways:
) It implements the POSIX specification’s saved user-id
mechanism, which allows a process to repeatedly drop and 
reacquire its effective uid.
) It has added a process characteristic that grants just a 
subset of the rights of the effective uid.
„ Linux provides another mechanism that allows a client to 
selectively pass access to a single file to some server 
process without granting it any other privileges.

File đính kèm:

  • pdfBài giảng Nguyên lý hệ điều hành - Nguyễn Hải Châu - Tuần 14,15 Linux.pdf