BC0042-Operating Systems
1.What
is kernel? What are the main components of a kernel? [ 5 +5 marks]
The kernel provides the file system, CPU
scheduling, memory management, and other operating-system functions through
system calls. Taken in sum, that is an enormous amount of functionality to be
combined into one level. This monolithic structure was difficult to implement
and maintain.
The UNIX kernel has components as depicted in the figure
2.5 bellow. The figure is divided in to three modes: user mode, kernel mode,
and hardware. The user mode contains user programs which can access the
services of the kernel components using system call interface.
The kernel mode has four major components: system calls,
file subsystem, process control subsystem, and hardware control. The system
calls are interface between user programs and file and process control
subsystems. The file subsystem is responsible for file and I/O management
through device drivers.
The process control subsystem contains scheduler,
Inter-process communication and memory management. Finally the hardware control
is the interface between these two subsystems and hardware.
When the kernel became large and difficult to manage. In
the mid-1980 s , researches at Carnegie Mellon University developed an operating
system called Mach that modulated the kernel using the micro-kernel approach. This method structures the operating system by removing all
nonessential components from the kernel and implementing then as system and
user-level programs. The result is a smaller kernel. There is little consensus
regarding which services should remain in the kernel and which should be
implemented in user space. Typically, however, micro-kernels provide minimal
process and memory management, in addition to a communication facility.
Device
Drivers
|
File Server
|
Client Process
|
….
|
Virtual Memory
|
Micro-kernel
|
||||
Hardware
|
Micro-kernel Architecture
The main function of the micro-kernel is to provide a
communication facility between the client program and the various services that
are also running in user space. Communication is provided by message
passing. For example, if the client program and service never interact
directly. Rather, they communicate indirectly by exchanging messages with the micro-kernel.
On benefit of the micro-kernel approach is ease of
extending the operating system. All new services are added to user space and
consequently do not require modification of the kernel. When the kernel does
have to be modified, the changes tend to be fewer, because the micro-kernel is a
smaller kernel. The resulting operating system is easier to port from one
hardware design to another. The micro-kernel also provided more security and
reliability, since most services are running as user – rather than kernel –
processes, if a service fails the rest of the operating system remains
untouched.
Several contemporary operating systems have used the micro-kernel approach. Tru64 UNIX (formerly Digital UNIX provides a UNIX
interface to the user, but it is implemented with a March kernel. The March
kernel maps UNIX system calls into messages to the appropriate user-level
services.
The following figure shows the UNIX operating system
architecture. At the center is hardware, covered by kernel. Above that are the
UNIX utilities, and command interface, such as shell (sh), etc.
2.
What is mutual exclusion? What are its requirements? [ 5 +5 marks]
Ch 7
Mutual exclusion is a way of making sure that if one
process is using a shared modifiable data, the other processes will be excluded
from doing the same thing. That is, while one process executes the shared
variable, all other processes desiring to do so at the same time moment should
be kept waiting; when that process has finished using the shared variable, one
of the processes waiting to do so should be allowed to proceed. In this
fashion, each process using the shared data (variables) excludes all others
from doing so simultaneously, this is called Mutual Exclusion.
Mutual exclusion needs to be enforced only when processes
access shared modifiable data- when processes are performing operations that do
not conflict with one another they should be allowed to proceed concurrently.
Following are the six requirements for mutual exclusion.
·
Mutual exclusion must be
enforced: Only one process at a time is allowed into its critical section,
among all processes that have critical sections for the same resource or shared
object.
·
A process that halts in
its non critical section must do so without interfering with other processes.
·
It must not be possible
for a process requiring access to a critical section to be delayed
indefinitely.
·
When no process is in a
critical section, any process that requests entry to its critical section must
be permitted to enter without delay.
·
No assumptions are made
about relative process speed or number of processors.
·
A process remains inside
its critical section for a finite time only.
3. What are the two types of fragmentation's? Illustrate
them with block diagrams. [ 5 +5 marks]
There are two types of Fragmentation :-
1) External
Fragmentation
2) Internal
Fragmentation
External Fragmentation
a) It exists when there
us enough total memory space available to satisfy a request, but available
memory space are not contiguous.
b) Storage space is fragmented
into large number of small holes.
c) Both first fit and
best fit strategies suffer from this.
d) First fit is better
in some systems, whereas best fit is better for other.
e) Depending on the
total amount of memory storage, size, external fragmentation may be minor or
major problem.
f) Statistically N
allocated block, Another 0.5 N blocks will be lost to fragmentation. The 1/3 of
memory is unusable. It is called 50 - Percent Rule
Internal Fragmentation
Consider a multiple
partition allocation scheme with a hole of 18,462 bytes. The next process
request with 18,462 bytes. If we allocate, we are left with a hole of 2 bytes.
The general approach to
avoid this problem is to :-
a) Break physical memory
into fixed sized blocks and allocate memory in units based on block size.
b) Memory allocated to a
process may be slightly large than the requested memory
4.
List out the conditions that result in Deadlock situations. Illustrate deadlock
situation with a simple graphical notation. [ 5 +5 marks]
Ch 6
In order for deadlock occur, four conditions must be
true:-
Mutual
exclusion – Each resource is neither currently allocated to
exactly one process or it is available. (Two processes cannot simultaneously
control the same resource or be in their critical section).
Hold
and Wait – processes currently holding resources can request new
resources.
No Preemption – Once a process holds a resource, it
cannot be taken away by another process or the kernel.
Circular
wait
– Each process is waiting to obtain a resource which is held by another
process.
Deadlock
can be modeled with a directed graph. In a deadlock graph, vertices represent
either processes (circles) or resources (squares). A process which has acquired
a resource is show with an arrow (edge) from the resource to the process. A
process which has requested a resource which has not yet been assigned to it is
modeled with an arrow from the process to the resource. If these create a
cycle, there is deadlock.Deadlock is unlikely to occur very often; a system can
run for years without deadlock occurring. If the operating system has a
deadlock prevention or detection system in place, this will have a negative
impact on performance (slow the system down) because whenever a process or
thread requests a resource, the system will have to check whether granting this
request could cause a potential deadlock situation. If deadlock does occur, it
may be necessary to bring the system down, or at least manually kill a number
of processes, but even that is not an extreme solution in most situations.
5.
Explain what is file structure? Explain the various access modes. [ 5 +5 marks]
Ch 8
Unix hides the “chunkiness” of tracks, sectors, etc. and
presents each file as a “smooth” array of bytes with no internal structure.
Application programs can, if they wish, use the bytes in the file to represent
structures. For example, a wide-spread convention in Unix is to use
the newline character (the character with bit pattern 00001010) to
break text files into lines. Some other systems provide a variety of other
types of files. The most common are files that consist of an array of fixed or
variable size records and files that form
an index mapping keys to values. Indexed files are usually
implemented as B-trees.
Most systems divide files into various “types.” The
concept of “type” is a confusing one, partially because the term “type” can
mean different things in different contexts. Unix initially supported only four
types of files:directories, two kinds of special files (discussed
later), and “regular” files. Just about any type of file is considered a
“regular” file by Unix. Within this category, however, it is useful to
distinguish text files from binary files; within binary files there are
executable files (which contain machine-language code) and data files; text
files might be source files in a particular programming language (e.g. C or
Java) or they may be human-readable text in some mark-up language such as html
(hypertext markup language). Data files may be classified according to the
program that created them or is able to interpret them, e.g., a file may be a
Microsoft Word document or Excel spreadsheet or the output of TeX. The
possibilities are endless.
In general (not just in Unix) there are three ways of
indicating the type of a file:
The operating system may record the type of a file
in meta-data stored separately from the file, but associated with it.
Unix only provides enough meta-data to distinguish a regular file from a
directory (or special file), but other systems support more types.
Unix tends to be very lax in enforcing types.
Systems support various access modes for
operations on a file.
Sequential. Read or write the next record or
next n bytes of the file. Usually, sequential access also allows
are wind operation.
Random. Read or write the nth record or
bytes i through j. Unix provides an equivalent facility by
adding a seek operation to the sequential operations listed above. This
packaging of operations allows random access but encourages sequential access.
Indexed. Read or write the record with a given key.
In some cases, the “key” need not be unique--there can be more than one record
with the same key. In this case, programs use a combination of indexed and
sequential operations: Get the first record with a given key, then get other
records with the same key by doing sequential reads.
6.
With an example illustrate file access modes: Sequential, Indexed and Random
modes. [ 3 +3+4 marks]
Ch 8
Sequential Access
Refers to reading or writing data records in sequential
order, that is, one record after the other. To read record 10, for example, you
would first need to read records 1 through 9. This differs from random access,
in which you can read and write records in any order.Some programming languages
and operating systems distinguish between sequential-access data files and
random-access data files, allowing you to choose between the two types.
Sequential-access files are faster if you always access records in the same
order. Random-access files are faster if you need to read or write records in a
random order.Devices can also be classified as sequential access or random
access. For example, a tape drive is a sequential-access device because to get
to point on the tape, the drive needs to pass through points a through p. A
disk drive, on the other hand, is a random-access device because the drive can
access any point on the disk without passing through all intervening points.
No comments:
Post a Comment