Vous êtes sur la page 1sur 19

Unit – 4

Virtual memory

4.1 Virtual memory

The program thinks it has a large range of contiguous addresses; but in reality the
parts it is currently using are scattered around RAM, and the inactive parts are saved in a
disk file.

Virtual memory is a computer system technique which gives an application


program the impression that it has contiguous working memory, while in fact it is
physically fragmented and may even overflow on to disk storage. Systems which use this
technique make programming of large applications easier and use real physical memory
(e.g. RAM) more efficiently than those without virtual memory.

Note that "virtual memory" is not just "using disk space to extend physical memory
size". Extending memory is a normal consequence of using virtual memory techniques,
but can be done by other means such as overlays or swapping programs and their data
completely out to disk while they are inactive. The definition of "virtual memory" is
based on tricking programs into thinking they are using large blocks of contiguous
addresses.

4.2 Demand paging


In computer operating systems, demand paging is an application of virtual
memory. In a system that uses demand paging, the operating system copies a disk page
into physical memory only if an attempt is made to access it (i.e., if a page fault occurs).
It follows that a process begins execution with none of its pages in physical memory, and
many page faults will occur until most of a process's working set of pages is located in
physical memory. This is an example of lazy loading techniques.
Advantages
Demand paging, as opposed to loading all pages immediately:

• Does not load the pages that are never accessed, so saves the memory for
other programs and increases the degree of multiprogramming.
• Less loading latency at the program startup.
• Less of initial disk overhead because of fewer page reads.
• Does not need extra hardware support than what paging needs, since
protection fault can be used to get page fault.

Advantages over non-virtual memory systems:

• Pages will be shared by multiple programs until they are modified by one
of them, so a technique called copy on write will be used to save more
resources.
• Ability to run large programs on the machine, even though it does not
have sufficient memory to run the program. This method is easier for a
programmer than an old manual overlays.

Disadvantages
• Individual programs face extra latency when they access a page for the
first time. So prepaging, a method of remembering which pages a process used
when it last executed and preloading a few of them, is used to improve
performance.

4.3 Page replacement algorithm


In a computer operating system that utilizes paging for virtual memory ,memory
management, page replacement algorithms decide which memory pages to page out
(swap out, write to disk) when a page of memory needs to be allocated. Paging happens
when a page fault occurs and a free page cannot be used to satisfy the allocation, either
because there are none, or because the number of free pages is lower than some
threshold.

When the page that was selected for replacement and paged out is referenced again
it has to be paged in (read in from disk), and this involves waiting for I/O completion.
This determines the quality of the page replacement algorithm: the less time waiting for
page-ins, the better the algorithm.

A page replacement algorithm looks at the limited information about accesses to


the pages provided by hardware, and tries to guess which pages should be replaced to
minimize the total number of page misses, while balancing this with the costs (primary
storage and processor time) of the algorithm itself.
Local vs. global replacement
Replacement algorithms can be local or global.

When a process incurs a page fault, a local page replacement algorithm selects for
replacement some page that belongs to that same process (or a group of processes sharing
a memory partition). A global replacement algorithm is free to select any page in
memory.

Local page replacement assumes some form of memory partitioning that


determines how many pages are to be assigned to a given process or a group of processes.
Most popular forms of partitioning are fixed partitioning and balanced set algorithms
based on the working set model. The advantage of local page replacement is its
scalability: each process can handle its page faults independently without contending for
some shared global data structure.

Optimal page replacement algorithm


The theoretically optimal page replacement algorithm (also known as OPT or
clairvoyant replacement algorithm) is an algorithm that works as follows: ]

when a page needs to be swapped in, the operating system swaps out the page
whose next use will occur farthest in the future. For example, a page that is not going to
be used for the next 6 seconds will be swapped out over a page that is going to be used
within the next 0.4 seconds.

This algorithm cannot be implemented in the general purpose operating system


because it is impossible to reliably compute how long it will be before a page is going to
be used, except when all software that will run on a system is either known beforehand
and is amenable to the static analysis of its memory reference patterns, or only a class of
applications allowing run-time analysis is allowed. Despite this limitation, algorithms
exist that can offer near-optimal performance — on the first run of a program, the
operating system keeps track of all pages referenced by the program, and it uses this data
to decide which pages to swap in and out on subsequent runs. This algorithm can offer
near-optimal performance, but not on the first run of a program, and only if the program's
memory reference pattern is relatively consistent each time it runs.

Analysis of the paging problem has also been done in the field of online
algorithms. Efficiency of randomized online algorithms for the paging problem is
measured using amortized analysis.

Not recently used


The not recently used (NRU) page replacement algorithm is an algorithm that
favours keeping pages in memory that have been recently used. This algorithm works on
the following principle: when a page is referenced, a referenced bit is set for that page,
marking it as referenced. Similarly, when a page is modified (written to), a modified bit is
set. The setting of the bits is usually done by the hardware, although it is possible to do so
on the software level as well.

At a certain fixed time interval, the clock interrupt triggers and clears the
referenced bit of all the pages, so only pages referenced within the current clock interval
are marked with a referenced bit. When a page needs to be replaced, the operating system
divides the pages into four classes:

• Class 0: not referenced, not modified


• Class 1: not referenced, modified
• Class 2: referenced, not modified
• Class 3: referenced, modified

Although it does not seem possible for a page to be not referenced yet modified,
this happens when a category 3 page has its referenced bit cleared by the clock interrupt.
The NRU algorithm picks a random page from the lowest category for removal. Note that
this algorithm implies that a referenced page is more important than a modified page.

First-in, first-out
The first-in, first-out (FIFO) page replacement algorithm is a low-overhead
algorithm that requires little bookkeeping on the part of the operating system. The idea is
obvious from the name - the operating system keeps track of all the pages in memory in a
queue, with the most recent arrival at the back, and the earliest arrival in front. When a
page needs to be replaced, the page at the front of the queue (the oldest page) is selected.
While FIFO is cheap and intuitive, it performs poorly in practical application. Thus, it is
rarely used in its unmodified form. This algorithm experiences Belady's anomaly.

Least recently used


The least recently used page (LRU) replacement algorithm, though similar in name
to NRU, differs in the fact that LRU keeps track of page usage over a short period of
time, while NRU just looks at the usage in the last clock interval. LRU works on the idea
that pages that have been most heavily used in the past few instructions are most likely to
be used heavily in the next few instructions too. While LRU can provide near-optimal
performance in theory, it is rather expensive to implement in practice. There are a few
implementation methods for this algorithm that try to reduce the cost yet keep as much of
the performance as possible.

The most expensive method is the linked list method, which uses a linked list
containing all the pages in memory. At the back of this list is the least recently used page,
and at the front is the most recently used page. The cost of this implementation lies in the
fact that items in the list will have to be moved about every memory reference, which is a
very time-consuming process.

Another method that requires hardware support is as follows: suppose the hardware
has a 64-bit counter that is incremented at every instruction. Whenever a page is
accessed, it gains a value equal to the counter at the time of page access. Whenever a
page needs to be replaced, the operating system selects the page with the lowest counter
and swaps it out. With present hardware, this is not feasible because the required
hardware counters do not exist.

Because of implementation costs, one may consider algorithms (like those that
follow) that are similar to LRU, but which offer cheaper implementations.

One important advantage of LRU algorithm is that it is amenable to full statistical


analysis. It has been proved, for example, that LRU can never result in more than N-times
more page faults than OPT algorithm, where N is proportional to the number of pages in
the managed pool.

On the other hand, LRU's weakness is that its performance tends to degenerate
under many quite common reference patterns. For example, if there are N pages in the
LRU pool, an application executing a loop over array of N + 1 pages will cause a page
fault on each and every access. As loops over large arrays are common, much effort has
been put into modifying LRU to work better in such situations. Many of the proposed
LRU modifications try to detect looping reference patterns and to switch into suitable
replacement algorithm, like Most Recently Used (MRU).

Variants on LRU
• LRU-K improves greatly on LRU with regard to locality in time. It's also
known as LRU-2, for the case that K=2. LRU-1 (i.e. K=1) is the same as
normal LRU.
• The ARC[3] algorithm extends LRU by maintaining a history of recently
evicted pages and uses this to change preference to recent or frequent access. It
is particularly resistant to sequential scans.

4.4 Thrashing

• If a process does not have “enough” pages, the page-fault rate is very high.
This leads to:
o low CPU utilization.
o operating system thinks that it needs to increase the degree of
multiprogramming.
o another process added to the system.
• Thrashing ==> a process is busy swapping pages in and out to the virtual
exclusion of real work
• Why does paging work?
• Locality model
o Process migrates from one locality to another.
o Localities may overlap.
• Why does thrashing occur?
o sum of size of locality > total memory size

Working-Set Model

• d = working-set window = a fixed number of page references


Example: 10,000 instruction
• WSSi (working set of Process Pi) =
total number of pages referenced in the most recent d (varies in time)
o if d too small will not encompass entire locality.
o if d too large will encompass several localities.
o if d = infinity ==> will encompass entire program.
• D = sum WSSi ==> total demand frames
• if D > m ==> Thrashing
• Policy if D > m, then suspend one of the processes.

Working-set Model

Keeping Track of the Working Set


• Approximate with interval timer + a reference bit
• Example: d = 10,000
o Timer interrupts after every 5000 time units.
o Keep in memory 2 bits for each page.
o Whenever a timer interrupts copy and sets the values of all
reference bits to 0.
o If one of the bits in memory = 1 ==> page in working set.
• Why is this not completely accurate?
• Improvement = 10 bits and interrupt every 1000 time units.

Page Fault Frequency Scheme

• Establish “acceptable” page-fault rate


o If actual rate too low, process loses frame.
o If actual rate too high, process gains frame.

4.5 Allocating Frames


• Each process needs minimum number of pages.
o Example: IBM 370 – 6 pages to handle SS MOVE instruction:
o instruction is 6 bytes, might span 2 pages.
o 2 pages to handle from.
o 2 pages to handle to.
• Two major allocation schemes.
o fixed allocation
o priority allocation
Fixed Allocation

• Equal allocation – e.g., if 100 frames and 5 processes, give each 20 pages.
• Proportional allocation – Allocate according to the size of process.

Priority Allocation

• Use a proportional allocation scheme using priorities rather than size.


• If process Pi generates a page fault,
o select for replacement one of its frames.
o select for replacement a frame from a process with lower priority
number.

Global vs Local Allocation

• Global replacement – process selects a replacement frame from the set of


all frames; one process can take a frame from another.
• Local replacement – each process selects from only its own set of
allocated frames.

4.6 Other Considerations


• Prepaging
• Page size selection
o fragmentation
o table size
o I/O overhead
o locality
TLB considerations

• TLB Reach - The amount of memory accessible from the TLB.


• TLB Reach = (TLB Size) X (Page Size)
• Ideally, the working set of each process is stored in the TLB. Otherwise
there is a high degree of page faults.
• Increasing the size of the TLB
o Increase the Page Size. This may lead to an increase in
fragmentation as not all applications require a large page size.
o Provide Multiple Page Sizes. This allows applications that require
larger page sizes the opportunity to use them without an increase in
fragmentation.

Program Structure Considerations

• int A[][] = new int[1024][1024];


Each row is stored in one page
• Program 1
• for (j = 0; j < A.length; j++)
• for (i = 0; i < A.length; i++)
A[i,j] = 0;

1024 x 1024 page faults

• Program 2
• for (i = 0; i < A.length; i++)
• for (j = 0; j < A.length; j++)
A[i,j] = 0;

1024 page faults

I/O Considerations

• I/O Interlock – Pages must sometimes be locked into memory.


• Consider I/O. Pages that are used for copying a file from a device must be
locked from being selected for eviction by a page replacement algorithm.

4.7 File system


In computing, a file system (often also written as filesystem) is a method for
storing and organizing computer files and the data they contain to make it easy to find
and access them. File systems may use a data storage device such as a hard disk or CD-
ROM and involve maintaining the physical location of the files, they might provide
access to data on a file server by acting as clients for a network protocol (e.g., NFS,
SMB, or 9P clients), or they may be virtual and exist only as an access method for virtual
data (e.g., procfs).
More formally, a file system is a set of abstract data types that are implemented for
the storage, hierarchical organization, manipulation, navigation, access, and retrieval of
data. File systems share much in common with database technology, but it is debatable
whether a file system can be classified as a special-purpose database

4.8 File Concepts

Aspects of file systems


The most familiar file systems make use of an underlying data storage device that
offers access to an array of fixed-size blocks, sometimes called sector, generally 512
bytes each. The file system software is responsible for organizing these sectors into files
and directories, and keeping track of which sectors belong to which file and which are not
being used. Most file systems address data in fixed-sized units called "clusters" or
"blocks" which contain a certain number of disk sectors (usually 1-64). This is the
smallest logical amount of disk space that can be allocated to hold a file.

However, file systems need not make use of a storage device at all. A file system
can be used to organize and represent access to any data, whether it be stored or
dynamically generated (eg, from a network connection).

Whether the file system has an underlying storage device or not, file systems
typically have directories which associate file names with files, usually by connecting the
file name to an index into a file allocation table of some sort, such as the FAT in an MS-
DOS file system, or an inode in a Unix-like file system. Directory structures may be flat,
or allow hierarchies where directories may contain subdirectories. In some file systems,
file names are structured, with special syntax for filename extensions and version
numbers. In others, file names are simple strings, and per-file metadata is stored
elsewhere.

Other bookkeeping information is typically associated with each file within a file
system. The length of the data contained in a file may be stored as the number of blocks
allocated for the file or as an exact byte count. The time that the file was last modified
may be stored as the file's timestamp. Some file systems also store the file creation time,
the time it was last accessed, and the time that the file's meta-data was changed. (Note
that many early PC operating systems did not keep track of file times.) Other information
can include the file's device type (e.g., block, character, socket, subdirectory, etc.), its
owner user-ID and group-ID, and its access permission settings (e.g., whether the file is
read-only, executable, etc.).

The hierarchical file system was an early research interest of Dennis Ritchie of
Unix fame; previous implementations were restricted to only a few levels, notably the
IBM implementations, even of their early databases like IMS. After the success of Unix,
Ritchie extended the file system concept to every object in his later operating system
developments, such as Plan 9 and Inferno.
Traditional file systems offer facilities to create, move and delete both files and
directories. They lack facilities to create additional links to a directory (hard links in
Unix), rename parent links (".." in Unix-like OS), and create bidirectional links to files.

Traditional file systems also offer facilities to truncate, append to, create, move,
delete and in-place modify files. They do not offer facilities to prepend to or truncate
from the beginning of a file, let alone arbitrary insertion into or deletion from a file. The
operations provided are highly asymmetric and lack the generality to be useful in
unexpected contexts. For example, interprocess pipes in Unix have to be implemented
outside of the file system because the pipes concept does not offer truncation from the
beginning of files.

Secure access to basic file system operations can be based on a scheme of access
control lists or capabilities. Research has shown access control lists to be difficult to
secure properly, which is why research operating systems tend to use capabilities.
Commercial file systems still use access control lists. see: secure computing

Arbitrary attributes can be associated on advanced file systems, such as XFS,


ext2/ext3, some versions of UFS, and HFS+, using extended file attributes. This feature is
implemented in the kernels of Linux, FreeBSD and Mac OS X operating systems, and
allows metadata to be associated with the file at the file system level. This, for example,
could be the author of a document, the character encoding of a plain-text document, or a
checksum.

Types of file systems

File system types can be classified into disk file systems, network file systems and
special purpose file systems.

Disk file systems

A disk file system is a file system designed for the storage of files on a data storage
device, most commonly a disk drive, which might be directly or indirectly connected to
the computer. Examples of disk file systems include FAT, FAT32, NTFS, HFS and
HFS+, ext2, ext3, ISO 9660, ODS-5, and UDF. Some disk file systems are journaling file
systems or versioning file systems.

Flash file systems

A flash file system is a file system designed for storing files on flash memory
devices. These are becoming more prevalent as the number of mobile devices is
increasing, and the capacity of flash memories catches up with hard drives.

While a block device layer can emulate a disk drive so that a disk file system can
be used on a flash device, this is suboptimal for several reasons:
• Erasing blocks: Flash memory blocks have to be explicitly erased before
they can be written to. The time taken to erase blocks can be significant,
thus it is beneficial to erase unused blocks while the device is idle.
• Random access: Disk file systems are optimized to avoid disk seeks
whenever possible, due to the high cost of seeking. Flash memory devices
impose no seek latency.
• Wear levelling: Flash memory devices tend to wear out when a single block
is repeatedly overwritten; flash file systems are designed to spread out
writes evenly.

Log-structured file systems have all the desirable properties for a flash file system.
Such file systems include JFFS2 and YAFFS.

Database file systems

A new concept for file management is the concept of a database-based file system.
Instead of, or in addition to, hierarchical structured management, files are identified by
their characteristics, like type of file, topic, author, or similar metadata. Example: dbfs.

Transactional file systems

Each disk operation may involve changes to a number of different files and disk
structures. In many cases, these changes are related, meaning that it is important that they
all be executed at the same time. Take for example a bank sending another bank some
money electronically. The bank's computer will "send" the transfer instruction to the
other bank and also update its own records to indicate the transfer has occurred. If for
some reason the computer crashes before it has had a chance to update its own records,
then on reset, there will be no record of the transfer but the bank will be missing some
money.

Transaction processing introduces the guarantee that at any point while it is


running, a transaction can either be finished completely or reverted completely (though
not necessarily both at any given point). This means that if there is a crash or power
failure, after recovery, the stored state will be consistent. (Either the money will be
transferred or it will not be transferred, but it won't ever go missing "in transit".)

This type of file system is designed to be fault tolerant, but may incur additional
overhead to do so.

Journaling file systems are one technique used to introduce transaction-level


consistency to filesystem structures.

Network file systems


A network file system is a file system that acts as a client for a remote file access
protocol, providing access to files on a server. Examples of network file systems include
clients for the NFS, SMB protocols, and file-system-like clients for FTP and WebDAV.

Special purpose file systems

A special purpose file system is basically any file system that is not a disk file
system or network file system. This includes systems where the files are arranged
dynamically by software, intended for such purposes as communication between
computer processes or temporary file space.

Special purpose file systems are most commonly used by file-centric operating
systems such as Unix. Examples include the procfs (/proc) file system used by some Unix
variants, which grants access to information about processes and other operating system
features.

Deep space science exploration craft, like Voyager I & II used digital tape based
special file systems. Most modern space exploration craft like Cassini-Huygens used
Real-time operating system file systems or RTOS influenced file systems. The Mars
Rovers are one such example of an RTOS file system, important in this case because they
are implemented in flash memory.

4.9 Access methods


Based on a set of rules, eZ publish determines which siteaccess it should use every
time it processes an incoming request. The rules must be set up in the global override for
the site.ini configuration file: "/settings/override/site.ini.append.php". The behavior of the
siteaccess system is controlled by the "MatchOrder" setting within the
[SiteAccessSettings] block. This setting controls the way eZ publish interprets the
incoming requests. There are three possible methods:

• URI

• Host

• Port

The following text gives a brief explanation of the different access methods. Please
note that the access methods can be combined. The documentation page of the
"MatchOrder" directive reveals how this can be done.

URI

This is the default setting for the "MatchOrder" directive. When the URI access
method is used, the name of the target siteaccess will be the first parameter that comes
after the "index.php" part of the requested URL. For example, the following URL will
tell eZ publish to use the "admin" siteaccess: http://www.example.com/index.php/admin.
If another siteaccess by the name of "public" exists, then it would be possible to reach it
by pointing the browser to the following address:
http://www.example.com/index.php/public. If the last part of the URL is omitted then the
default siteaccess will be used. The default siteaccess is defined by the "DefaultAccess"
setting within the [SiteSettings] block. The following example shows how to set up
"/settings/override/site.ini.append.php" in order to make eZ publish use the URI access
method and to use a siteaccess called "public" by default:

...

[SiteSettings]

DefaultAccess=public

[SiteAccessSettings]

MatchOrder=uri

...

The URI access method is typically useful for testing / demonstration purposes. In
addition it is quite handy because it doesn't require any configuration of the web server
and the DNS server.

Host

The host access method makes it possible to map different host/domain


combinations to different siteaccesses. This access method requires configuration outside
eZ publish. First of all, the DNS server must be configured to resolve the desired
host/domain combinations to the IP address of the web server. Secondly, the web server
must be configured to trigger a virtual host configuration (unless eZ publish is located in
the main document root). Please refer to the "Virtual Host Setup" part of the installation
chapter for information about how to set up a virtual host for eZ publish. Once the DNS
and the web server is configured properly, eZ publish can be set up to use different
siteaccesses based on the host/domain combinations of the incoming requests. The
following example shows how to set up "/settings/override/site.ini.append.php" in order
to make eZ publish use the host access method. In addition, it reveals the basic usage of
the host matching mechanism.

...

[SiteAccessSettings]
MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=www.example.com;public
HostMatchMapItems[]=admin.example.com;admin
...

The example above tells eZ publish to use the "public" siteaccess if the requested
URL starts with "www.example.com". In other words, the configuration files in
"/settings/siteaccess/public" will be used. If the requested URL starts with
"admin.example.com", then the admin siteaccess will be used. The example above
demonstrates only a fragment of the host matching capabilities of eZ publish. Please refer
to the reference documentation for a full explanation of the "HostMatchType" directive.

Port

The port access method makes it possible to map different ports to different
siteaccesses. This access method requires configuration outside eZ publish. The web
server must be configured to listen to the desired ports (by default, a web server typically
listens for requests on port 80, which is the standard port for HTTP traffic). In addition,
the firewall will most likely have to be opened so that the traffic on port 81 actually
reaches the web server. The following example shows how to set up
"/settings/override/site.ini.append.php" in order to make eZ publish use the port access
method. It also shows how to map different ports to different siteaccesses.

...

[SiteAccessSettings]

MatchOrder=port

[PortAccessSettings]

80=public

81=admin

...

The example above tells eZ publish to use the "public" siteaccess if the requested
URL is sent to the web server using port 80. In other words, the configuration files inside
"/settings/siteaccess/public" will be used. If the URL is requested on port 81 (usually by
appending a :81 to the URL, like this: http://www.example.com:81), then the admin
siteaccess will be used.

4.10 Directory Structure


The structure of the directories and the relationship among them are the main areas
where file systems tend to differ, and it is also the area that has the most significant effect
on the user interface provided by the file system. The most common directory structures
used by multi-user systems are:
• single-level directory
• two-level directory
• tree-structured directory
• acyclic directory

Single-Level Directory

In a single-level directory system, all the files are placed in one directory. This is
very common on single-user OS's. A single-level directory has significant limitations,
however, when the number of files increases or when there is more than one user. Since
all files are in the same directory, they must have unique names. If there are two users
who call their data file "test", then the unique-name rule is violated. Although file names
are generally selected to reflect the content of the file, they are often quite limited in
length.Even with a single-user, as the number of files increases, it becomes difficult to
remember the names of all the files in order to create only files with unique names.

Two-Level Directory

In the two-level directory system, the system maintains a master block that has
one entry for each user. This master block contains the addresses of the directory of the
users.

There are still problems with two-level directory structure. This structure
effectively isolates one user from another. This is an advantage when the users are
completely independent, but a disadvantage when the users want to cooperate on some
task and access files of other users. Some systems simply do not allow local files to be
accessed by other users.

Tree-Structured Directories

In the tree-structured directory, the directory themselves are files. This leads to
the possibility of having sub-directories that can contain files and sub-subdirectories.An
interesting policy decision in a tree-structured directory structure is how to handle the
deletion of a directory. If a directory is empty, its entry in its containing directory can
simply be deleted. However, suppose the directory to be deleted id not empty, but
contains several files, or possibly sub-directories. Some systems will not delete a
directory unless it is empty.

Thus, to delete a directory, someone must first delete all the files in that directory.
If these are any sub-directories, this procedure must be applied recursively to them, so
that they can be deleted also. This approach may result in a insubstantial amount of work.
An alternative approach is just to assume that, when a request is made to delete a
directory, all of that directory's files and sub-directories are also to be deleted.

Acyclic-Graph Directories
The acyclic directory structure is an extension of the tree-structured directory
structure. In the tree-structured directory, files and directories starting from some fixed
directory are owned by one particular user. In the acyclic structure, this prohibition is
taken out and thus a directory or file under directory can be owned by several users.

4.11 Mounting File Systems


The process of incorporating a file system into the existing directory structure is
known as mounting the file system. The file system can be on a disk or disks connected
directly to your system, that is, a local file system, or it can be part of a remote NFS file
system, and it can be on either a non-LVM disk or a logical volume.

Mounting a file system associates it with a directory in the existing file system
tree. Prior to mounting, the files, although present on the disk, are not accessible to users;
once mounted, the file system becomes accessible.

The directory in the existing file system where the file is attached is known as the
mount point or mount directory for the new file system, and the files in the added file
system become part of the existing file system hierarchy.

The mount point should be an empty subdirectory on the existing file system. If
you mount a file system on to a directory that already has files in it, those files will be
hidden and inaccessible until you unmount the file system. If you try to mount the file
system on to a directory whose files are in use, the mount will fail.

4.12 File sharing


File sharing usually follows the peer-to-peer (P2P) model, where the files are
stored on and served by personal computers of the users. Most people who engage in file
sharing on the Internet both provide (upload) files and receive files (download).

Web-based sharing
Webhosting is also used for file sharing, since it makes it possible to exchange
privately. In small communities popular files can be distributed very quickly and
efficiently. Web hosters are independent of each other; therefore contents are not
distributed further. Other terms for this are one-click hosting and web-based sharing.

File sharing is the public or private sharing of computer data or space in a


network with various levels of access privilege. While files can easily be shared outside a
network (for example, simply by handing or mailing someone your file on a diskette), the
term file sharing almost always means sharing files in a network, even if in a small local
area network. File sharing allows a number of people to use the same file or file by some
combination of being able to read or view it, write to or modify it, copy it, or print it.
Typically, a file sharing system has one or more administrators. Users may all have the
same or may have different levels of access privilege. File sharing can also mean having
an allocated amount of personal file storage in a common file system.

File sharing has been a feature of mainframe and multi-user computer systems for
many years. With the advent of the Internet, a file transfer system called the File Transfer
Protocol (FTP) has become widely-used. FTP can be used to access (read and possibly
write to) files shared among a particular set of users with a password to gain access to
files shared from an FTP server site. Many FTP sites offer public file sharing or at least
the ability to view or copy files by downloading them, using a public password (which
happens to be "anonymous"). Most Web site developers use FTP to upload new or
revised Web files to a Web server, and indeed the World Wide Web itself can be thought
of as large-scale file sharing in which requested pages or files are constantly being
downloaded or copied down to the Web user.

More usually, however, file sharing implies a system in which users write to as
well as read files or in which users are allotted some amount of space for personal files
on a common server, giving access to other users as they see fit. The latter kind of file
sharing is common in schools and universities. File sharing can be viewed as part of file
systems and their management.

Any multi-user operating system will provide some form of file sharing. Among
the best known network file systems is (not surprisingly) the Network File System (NFS).
Originally developed by Sun Microsystems for its Unix-based systems, it lets you read
and, assuming you have permission, write to sharable files as though they were on your
own personal computer. Files can also be shared in file systems distributed over different
points in a network. File sharing is involved in groupware and a number of other types of
applications.

4.13 File System

An operating system's file system structure is its most basic level of organization.
Almost all of the ways an operating system interacts with its users, applications, and
security model are dependent upon the way it stores its files on a storage device. It is
crucial for a variety of reasons that users, as well as programs, be able to refer to a
common guideline to know where to read and write files.
A file system can be seen in terms of two different logical categories of files:
• Shareable vs. unsharable files
• Variable vs. static files
Shareable files are those that can be accessed by various hosts; unsharable files are not
available to any other hosts. Variable files can change at any time without any
intervention; static files, such as read-only documentation and binaries, do not change
without an action from the system administrator or an agent that the system administrator
has placed in motion to accomplish that task.
4.14 File system Implementation
A file is a meaningful set of data to be stored on a non-volatile media: must be
mapped to physical storage – typically a disk.

File control block: all the information about a file accessed on opening a file from the
directory information and stored in the “Open File table” see below.

Directory Structure (Stallings Table 12.2, p. 537, and also p. 481 Bottom):
The directory maps symbolic names to logical or physical disk addresses. When the file
is “opened”, the directory structure is searched for file information and copied to the
“open file table”. The key information is a pointer to the file itself. The open file table
is faster to access than the directory which must be searched. An index into this table to
the directory information of the file which was opened (file control block) is returned to
the user as a file descriptor in UNIX or a handle in some other OS’s. The index is faster
to use than searching the original directory.

Layered architecture to file system implementation:


A typical but not unique possibility:

Application
Logical file system:
Use directory structure and symbolic names. Output is a logical block address
File organization module:
Translate Logical block address to physical address.
Free space management here

Basic file system


Issue generic high level commands to device driver (physical block addresses).

I/O Control
Device driver: data transfer between memory and disk. Input is high-level
commands, and output is low-level hardware commands to device controller.

Device controller
Hardware interface between the device driver (OS) and the device itself.
Typically an adapter card in a bus on the mother board.
Low level logic controlling the device

Vous aimerez peut-être aussi