Академический Документы
Профессиональный Документы
Культура Документы
to block and request a wakeup when shared memory is delivered, and these
is no standard
mechanism for other processes to establish a shared memory links to an
existing process.
However, shared memory has advantage that it is very much faster than
socket
communications in many cases. When data is sent over a socket, it is
typically copied
from memory to memory multiple times. Shared memory updates requires
no data copies
if one process updates a data structure in shared memory, that update is
immediately
visible to all other processes sharing that memory. Sending or receiving data
over a socket
requires that a kernel system service call be made to initiate the transfer, but
shared
memory communication can be performed entirely in user mode with no
transfer of control
required.
Socket communication is typically preferred when connection management is
important or when these is a requirement to synchronise the sender and
reciever. For
example server processes will usually establish a listening socket to which
clients can
connect when they want to use that service. Once the socket is established,
individual
requests are also sent using the socket, so that the server can easily
determine when a
new request arrives and who it arrived from.
In some cases, however, shared memory is preferred. Shared memory is
often a better
solution when either large amounts of data are to be transferred or when two
processes
need random access to a large common data set. In this case, however, the
communicating
processes may still need an extra mechanism in addition to shared memory
to achieve
synchronization between themselves.
The X windows system, a graphical display environment for UNIX, is a
good example of this: most graphic requests are sent over sockets, but
shared
memory is offered as an additional transport in specid cases where
large bitmaps are to be displayed on the screen. In this case, a request to
display the
bitmap will still be sent over the socket, but the bulk data of the bitmap itself
will be
sent via shared memory.
Repeat
Wait (mutex);
Signal (mutex);
Remainder section
Critical section
Untill False;
Mutual Exculstion Implementation with Semaphore
Advantage of semaphore over test and set instruction:
1. The main advantage of semaphore i.e., Test and set hardware are not easy
to
generalize to more complex problems. But to overcome this difficulty, we can
use a
synchronization tool, called a semaphose.
2. Another advantage is Test and set Hardware solution is not feasible in a
multiprocessor environment. But by semaphose we will provide a solution for
multiprocessor environment.
Q.5. Define Critical section Problem. What are the necessary
File
concept,
access
methods,
directory
types.
If an operating system recognizes the type of a file, it can then operate on
the file in
reasonable ways. For example, a common mistake occurs a user tries to print
the binary
object form of a program.
A common technique technique for implementing file types is to include the
type as
part of the file name. The name is split into two partsa name and an
extension, usually
separated by a period character.
File Type Usual Extension Function
Executable exe, com, bin, or none ready-to-run machine- language program
Object obj, o compiled, machine language, not linked
Source Code C, P, pass f77, arm a source code in various languages
Batch bat, sh Commands to the command interpreter
Text text, doc textual data, documents
Word processor up, tex, rrf, etc various word-processor formats
Library Lib, a Libraries of routines for programmers.
Print of view Ps, dvi, fig ASCII or binary file in a format for
printing or viewing
File Allocation Methods:
1. Contiguous Allocation: This method requires each file to occupy a
setoff
contiguous address on the disk. Disk address defines a linear ordering on the
disk. The
difficulty with contiguous allocation is finding space for a new file. It also
suffers form
external fragmentation.
2. Linked Allocation: In linked allocation, each file is a linked list of disk
blocks.
The directory contains a pointer to the first (optionally the last) block of the
file. There
is no external fragmentation with linked allocation. Any free block is used to
satisfy a
request. The problem with it is that it is inefficient to support direct-access; it
is effective
only for sequential-access files.
3. Indexed Allocation: This allocation method is the solution to the
problem of
both continuous and linked allocation. This is done by bringing all the
pointers together
into one location called the index block. Each file has its own index block,
which is an
array of disk sector of addresses. The directly contains the adress of the
index block of
file.
Q.9. Write short on (12.5)
(i) Log structured File system
(ii) Efficiency and usage of disk space.
(iii) File system mounting
(iv) The protection strategies provided for Files.
Ans. (i) Log Structured File System: A log structured file system is a file
system
in which data and metadata are written sequentially to a circular buffer,
called a log.
The design of log-structured file system is based on the hypothesis that this
will no
longer be effecive because ever-increasing memory sizes on modern
computers would
lead to Input/Output becoming write heavy.
A log structured file system thus treats its storage as a circular log and writes
sequentially to the head of the log.
The design rationale for log-structured file systems assumes the most reads
will
be optimized away by ever-enlarging memory caches. This assumption does
not always
hold:
(i) On magnetic media
(ii) On flash memory
(ii) Efficiency and Usage of Disk Space: The efficiency use of disk space
is heavily
dependent on the disk allocation and directory dgorithms in use. For
instance, UNIX
inodes are preallocated on a partition. Even on empty disk has a
percentage of its
138 Fourth Semester Operating System, May-June 2013
space lost to inodes. However, by preallocating the indoes and spreading
these across
the partition, we improve the file systems performance. This improved
preformance is
a result of the UNIX allocation and free-space algorithms, which try to keep a
files data
blocks near that files inode block to reduce seek time.
As an example, consider how efficiency is affected by the size of the pointers
used to
access data. Most systems use either 16 or 32 bit pointers throughout the
operating
system. These pointers sizes limit the length of a file to either 216 (64 k) or
232 bytes (4
GB). Some systems implement 64-bit pointers to increase the limit to 264
bytes, which
is a very large number indeed. However, 64 bit pointers take more space to
store, and in
turn make the allocation and free space management methods (Linked lists,
indexes
and so on) use more disk space.
(iii) File System Mounting: Just as a file must be opened before it is used,
a file
system must be mounted before it can be available to processes on the
system. The
mount procedure is straight forward. The operating system is given the name
of the
device, and the location within the file structure at which to attach the file
system (called
the mount point) For instance, on a UNIX system, a file system containing
users home
directories might be mounted as home; then, to access the directory
structure within
that file system, one could preceede the directory names home, as in
/home/jane, mounting
that file system under/users would result in the path name /users/jane to
reach the same
directory.
Consider the actions of the macintosh operating system. Whenever the
system
ecounters a disk are for the first time (hard disks are found at boot time,
floppy disks
are seen when they are inserted into the drive), the maintain operating
system searches
for a file system on the device. If it finds one, it automatically mounts the file
system at
the root level adding a folder icon on the screen labeled with the name of the
file system.
(iv) Protection Stragegies provided by Files: When information is kept
in a
computer system, a major concern is its protection from both physical
damage
(reliability) and improper access (protection)
Reliability is generally provided by duplicate copies of files. many comp have
systems programs that automatically copy disk files to tape at regular
intervals to
maintain a copy should a file system be accidentally destroyed. File systems
can be
damaged by H/W problems.
Protection can be provided in many ways. For a small single user system, we
might
provide protection by physically removing the floppy disks and locking them
in a desk
drawer or file cobinet. In a multiuser system, however, other mechanisms
are needed.