Showing posts with label Operating System. Show all posts
Showing posts with label Operating System. Show all posts

Thursday, December 17, 2015

I/O SYSTEMS



1.What are the allocation methods of a disk space?
Methods of allocating disk space which are widely in use are
a.  Contiguous allocation
b.  Linked allocation
c.  Indexed allocation

2.What are the advantages of Contiguous allocation?

The advantages are
a.  Supports direct access
b.  Supports sequential access
c.  Number of disk seeks is minimal.

3.What are the drawbacks of contiguous allocation of disk space?

The disadvantages are
a.  Suffers from external fragmentation
b.  Suffers from internal fragmentation
c.  Difficulty in finding space for a new file
d. File cannot be extended
e.  Size of the file is to be declared in advance

4.What are the advantages of Linked allocation?

The advantages are
a.  No external fragmentation
b.  Size of the file does not need to be declared

5.What are the disadvantages of linked allocation?

The disadvantages are
a.  Used only for sequential access of files.
b.  Direct access is not supported
c.  Memory space required for the pointers.
d. Reliability is compromised if the pointers are lost or damaged

Wednesday, December 16, 2015

FILE SYSTEMS


1.What is a file?

A file is a named collection of related information that is recorded on secondary storage. A file contains either programs or data. A file has certain "structure" based on its type.

2.List the various file attributes.

A file has certain other attributes, which vary from one operating system to another, but typically consist of these:Name, identifier, type, location, size, protection, time, date and user identification

3.What are the various file operations?

The six basic file operations are

  Creating a file
  Writing a file
  Reading a file
  Repositioning within a file
  Deleting a file
  Truncating a file 

4.What are the information associated with an open file?

Several pieces of information are associated with an open file which may be:
  File pointer
  File open count
  Disk location of the file
  Access rights

Tuesday, December 15, 2015

Page Replacement Algorithms



1.What is Demand paging?

Virtual memory is commonly implemented by demand paging. In demand paging, the pager brings only those necessary pages into memory instead of swapping in a whole process. Thus it avoids reading into memory pages that will not be used anyway, decreasing the swap time and the amount of physical memory needed.

2.Define lazy swapper.

Rather than swapping the entire process into main memory, a lazy swapper is used. A lazy swapper never swaps a page into memory unless that page will be needed.

3.What is a pure demand paging?

When starting execution of a process with no pages in memory, the operating system sets the instruction pointer to the first instruction of the process, which is on a non-memory resident page, the process immediately faults for the page. After this page is brought into memory, the process continues to execute, faulting as necessary until every page that it needs is in memory. At that point, it can execute with no more faults.This schema is pure demand paging.

4.Define effective access time.

Let p be the probability of a page fault (0£p£1). The value of p is expected to be close to 0; that is, there will be only a few page faults. The effective access time is Effective access time = (1-p) * ma + p* page fault time.ma : memory-access time

5.Define secondary memory.

This memory holds those pages that are not present in main memory. The secondary memory is usually a high speed disk. It is known as the swap evice, and the section of the disk used for this purpose is known as swap space.

Monday, December 14, 2015

STORAGE MANAGEMENT



1.What is the main function of the memory-management unit?

The runtime mapping from virtual to physical addresses is done by a hardware device called a memory management unit (MMU).

2.Define dynamic loading.

To obtain better memory-space utilization dynamic loading is used. With dynamic loading, a routine is not loaded until it is called. All routines are kept on disk in a relocatable load format. The main program is loaded into memory and executed. If the routine needs another routine, the calling routine checks whether the routine has been loaded. If not, the relocatable linking loader is called to load the desired program into memory.

3.Define dynamic linking.

Dynamic linking is similar to dynamic loading, rather that loading being postponed until execution time, linking is postponed. This feature is usually used with system libraries,such as language subroutine libraries. A stub is included in the image for each library-routine reference. The stub is a small piece of code that indicates how to locate the appropriate memory-resident library routine, or how to load the library if the routine is not already present.

4.What are overlays?

To enable a process to be larger than the amount of memory allocated to it, overlays are used. The idea of overlays is to keep in memory only those instructions and data that are needed at a given time. When other instructions are needed, they are loaded into space occupied previously by instructions that are no longer needed.

5.Define swapping.

A process needs to be in memory to be executed. However a process can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution.This process is called swapping.

Sunday, December 13, 2015

banker’s algorithm



1.Define deadlock prevention.

Deadlock prevention is a set of methods for ensuring that at least one of the four necessaryconditions like mutual exclusion, hold and wait, no preemption and circular wait cannot hold. By ensuring that that at least one of these conditions cannot hold, the occurrence of a deadlock can be prevented.

2.Define deadlock avoidance.

An alternative method for avoiding deadlocks is to require additional information about how resources are to be requested.Each request requires the system consider the resources currently available, the resources currently allocated to each process, and the future requests and releases of each process, to decide whether the could be satisfied or must wait to avoid apossible future deadlock.
3.What are a safe state and an unsafe state?

A state is safe if the system can allocate resources to each process in some order and still avoid a deadlock. A system is in safe state only if there exists a safe sequence. A sequence of processes <P1,P2,....Pn> is a safe sequence for the current allocation state if, for each Pi, the resource that Pi can still request can be satisfied by the current available resource plus the resource held by all the Pj, with j<i. if no such sequence exists, then the system state is said to be unsafe.

4.What is banker’s algorithm?

Banker’s algorithm is a deadlock avoidance algorithm that is applicable to a resource-allocation system with multiple instances of each resource type.The two algorithms used for its implementation are:

a.   Safety algorithm: The algorithm for finding out whether or not a system is in a safe state.

b.     Resource-request algorithm: if the resulting resourceallocation is safe, the transaction is completed and process Pi is allocated its resources. If the new state is unsafe Pi must wait and the old resource-allocation state is restored.

5.Define logical address and physical address.

An address generated by the CPU is referred as logical address. An address seen by the memory unit that is the one loaded into the memory address register of the memory is commonly referred to as physical address.

6.What is logical address space and physical address space?

The set of all logical addresses generated by a program is called a logical address space; the set of all physical addresses corresponding to these logical addresses is a physical address space.




Saturday, December 12, 2015

deadlock



1.Define entry section and exit section.

The critical section problem is to design a protocol that the processes can use to cooperate. Each process must request permission to enter its critical section. The section of the code implementing this request is the entry section. The critical section is followed by an exit section. The remaining code is the remainder section.

2.Give two hardware instructions and their definitions which can be used for implementing mutual exclusion.

• TestAndSet
boolean TestAndSet (boolean &target)
{

boolean rv = target; target = true; return rv;
}
• Swap
void Swap (boolean &a, boolean &b)
{

boolean temp = a; a = b;

b = temp;
}

3.What is semaphores?

A semaphore 'S' is a synchronization tool which is an integer value that, apart from initialization, is accessed only through two standard atomic operations; wait and signal.Semaphores can be used to deal with the n-process critical section problem. It can be also used to solve various Synchronization problems.

4.Define busy waiting and spinlock.

When a process is in its critical section, any other process that tries to enter its critical section must loop continuously in the entry code. This is called as busy waiting and this type of semaphore is also called a spinlock,because the process while waiting for the lock.

5.Define deadlock.

A process requests resources; if the resources are not available at that time, the process enters a wait state. Waiting processes may never again change state, because the resources they have requested are held by other waiting processes. This situation is called a deadlock.