Solution_BICSE_assgnmt 2

advertisement
Assignment No 2.
Question 1.
What problems do caching solve? What problems do they cause?
Solution:
Reasons for usefulness of caching:
Caches are useful when there is a large access time between two different components,
most common example be the CPU and the RAM.
Cache provides a temporary storage for maintaining a sustained pipeline of information,
when such difference in access time is present. It also applies to the case when there is a
great different of data transfer rate.Caching decreases the amount of idle time, by making
information available faster.
Caching problems:
Caches pose the problem of maintaining cache-coherency where all versions of a
particular information need to be kept consistent with each other.
Question 2.
Caches store frequently accessed data from HDD or other sources. An alternative
solution can be to have larger storage devices such as HDD and RAMs etc. Comment on
the correctness of this solution.
Caches are not meant for data storage. Their primary objective is to pre-fetch the data and
store it for future use. It works on the principle of storing recently accessed data. Even if
we increase the size of HDD, the purpose of caches cannot be fulfilled. The access
latency of HDD will be there. Similarly, having large size RAM is a better solution
because more processes can be fully loaded in the memory but still the purpose of caches
cannot be fully met.
Question 3.
What is the difference between synchronous and asynchronous I/O?
Solution:
Synchronous I/O: Control is returned to user only when process is completed
Asynchronous I/O: Control is returned to user without waiting for process completion
Question 4.
What does the following figure signify w.r.t the kernel and system services
implementation.
The given figure is the Solaris Modular Approach of operating system design.
A microkernel with a small privileged core surrounded by user-mode services, would
deliver unprecedented modularity, flexibility, and portability. The kernel provides only
minimal functionality that allows user-level processes called subsystems to perform
operating system services efficiently
Following are its key benefits:
1. Easier to extend a microkernel
2. Easier to port the operating system to new architectures
3. More reliable (less code is running in kernel mode)
4. More secure
The microkernel approach consists of defining a simple abstraction over the hardware,
with a set of primitives or system calls to implement minimal OS services such as
memory management multitasking, and inter-process communication. The other
components of the OS interact with the microkernel in a message-based relationship
and do not have to be rewritten when the OS is ported to a new platform. Only the
hardware-dependent microkernel has to be reprogrammed. Other services, including
those normally provided by the kernel such as networking, are implemented in userspace programs, referred to as servers. Microkernels are easier to maintain than
monolithic kernels.
A microkernel allows the implementation of the remaining part of the operating
system as a normal application program written in a high-level language, and the use
of different operating systems on top of the same unchanged kernel. It is also possible
to dynamically switch among operating systems and to have more than one active
simultaneously
The microkernel is the only part of the system executing in a kernel mode. The actual
operating-system services are provided by user-mode servers. These include device
drivers, protocol stacks, file systems and user-interface code.
ASSIGNMENT 2
Question 1.
Explain how system calls can be an overhead for OS?
A system call results in changing fro muser mode to kernel mode to perform priviledged
tasks. This switch between a kernel mode and a user mode is done on the cost of
software interruptions or context switches. Unlike kernel modules, user programs are
executed as ordinary processes. Therefore, keeping aside the system security ensured by
maintaining two modes, the excessive switching between these modes causes an
overhead.
Question 2.
Explain the benefits of Microkernel implementation? How does it interact with the
external services and programs?
A microkernel with a small privileged core surrounded by user-mode services, would
deliver unprecedented modularity, flexibility, and portability. The kernel provides only
minimal functionality that allows user-level processes called subsystems to perform
operating system services efficiently
Following are its key benefits:
5. Easier to extend a microkernel
6. Easier to port the operating system to new architectures
7. More reliable (less code is running in kernel mode)
8. More secure
The microkernel approach consists of defining a simple abstraction over the hardware,
with a set of primitives or system calls to implement minimal OS services such as
memory management multitasking, and inter-process communication. The other
components of the OS interact with the microkernel in a message-based relationship
and do not have to be rewritten when the OS is ported to a new platform. Only the
hardware-dependent microkernel has to be reprogrammed. Other services, including
those normally provided by the kernel such as networking, are implemented in userspace programs, referred to as servers. Microkernels are easier to maintain than
monolithic kernels.
A microkernel allows the implementation of the remaining part of the operating
system as a normal application program written in a high-level language, and the use
of different operating systems on top of the same unchanged kernel. It is also possible
to dynamically switch among operating systems and to have more than one active
simultaneously
The microkernel is the only part of the system executing in a kernel mode. The actual
operating-system services are provided by user-mode servers. These include device
drivers, protocol stacks, file systems and user-interface code.
Question 3.
Explain the difference between the two scenarios? List the sequence of events taking
place step by step
Fig 1
Fig 2
FIG 1 shows a function call:
FIG 2 shows a system call:
The first diagram shows the function call in this case process calls different functions in
the same program. Since all the functions are part of same program they are loaded in
same code section for execution. Only the value of Instruction Pointer is update in order
to start execution of other function. The address of instruction following the function call
instruction in callee is stored in stack before call is made and IP is updated to the
function, which we have to call. Process still remains in same context and there is no
context switch.
In case of system call process executing system call makes request to operating
system to perform certain task on its behalf. There are number of steps through which
system call is executed, they are:
1. _ The computer (hardware) saves its state
2. _ The OS code takes control of the CPU, privileges are updated.
3. _ The OS examines the call parameters
4. _ The OS performs the requested function
5. _ The OS saves its state (and call results)
6. _ The OS returns control of the CPU to the caller
In simple words context switching overhead is also involved since system call needs to be
executed in privilege mode. Hence there is a vital difference between both.
Question 4.
Write down the layers of the OS in layered architecture approach from top to the bottom.
Explain with the help of examples.
Applications layer -- Banking system, airline reservations, adventure games
Applicaction such as MS Word, Mediaplayer exist at this layer.This is the most
abstract and upper layer presented to User to interact with the help of UI.
System development tools -- Compilers, Editors, Command interpreters (shell)
They are underlying tools to develop application layer programs. C++, Java and other
are example of these languages which facilitate in rapid application development.
System calls (operating system)- exec(), fork(), printf().
System calls are made using langauage API so some duties can be delegated to OS .
OS performs requested task on applications behalf.
Machine Language
Machine Language is lowest layer of abstraction it is directly understandable by
machine and is based on 1,0’s
Microprogramming
Microprogramming is the lowest level hard wired glued logic in digital circuitry based
on digital design principles.
Physical devices
Physical devices are actual hardware which is used to execute the application.
Download