Chaitu Tech Bits
Showing posts with label operating system interview questions. Show all posts
Showing posts with label operating system interview questions. Show all posts

what is the stack where it is used ? what is the use of the stack

Wednesday, December 15, 2010


The stack is a place in the computer memory where all the variables that are declared and initialized before runtime are stored.
A stack is a last in, first out (LIFO) data structure.
The push operation adds to the top of the stack, hiding any items already on the stack, or initializing the stack if it is empty. The pop operation removes an item from the top of the stack, and returns this value to the caller. A pop either reveals previously concealed items, or results in an empty stack.

Stack is used in

1. Expression evaluation and syntax parsing

Many compilers use a stack Expression evaluation before translating into low level code.

Example (general)


Share/Bookmark

what is segmentation ? how to overcome segmentation


In computing, memory segmentation is one of the most common ways to achieve memory protection; another common one is paging.

In a computer system using segmentation, an instruction operand that refers to a memory location includes a value that identifies a segment and an offset within that segment.

A segment has a set of permissions, and a length, associated with it.
If the currently running process is allowed by the permissions to make the type of reference to memory that it is attempting to make, and the offset within the segment is within the range specified by the length of the segment, the reference is permitted; otherwise, a hardware exception is raised.


Share/Bookmark

What is virtual memory ? what is the use of virtual memory


Since the early days of computing, there has been a need for more memory than exists
physically in a system. Virtual memory makes the system appear to have more memory than it actually has by sharing it between competing processes as they need it.

Virtual memory does more than just make your computer's memory go further
Large Address Spaces
Protection
Memory Mapping
Fair Physical Memory Allocation
Shared Virtual Memory

Share/Bookmark

What is page fault? how to over come page fault



A: virtual address is composed of two parts; an offset and a virtual page frame number. If
The page size is 4 Kbytes; bits 11:0 of the virtual address contain the offset and bits 12
And above is the virtual page frame number.

Each time the processor encounters a virtual address it must extract the offset and the
Virtual page frame number. The processor must translate the virtual page frame number into a physical one and then access the location at the correct offset into that physical page. To do this the processor uses page tables.

The processor uses the virtual page frame number as an index into the processes page table to retrieve its page table entry. If the page table entry at that offset is valid, the

Processor takes the physical page frame number from this entry. If the entry is invalid, the process has accessed a non-existent area of its virtual memory. This is called Page fault.
In this case, the processor cannot resolve the address and must pass control to the operating system so that it can fix things up.

Share/Bookmark

what is semaphore ? what is the advantage of semaphore

semaphore is a correct way which help operating system to share its source between processors, you can fined more information in professional blogs in operating systems field.



Semaphore is a synchronization tool to solve critical-section problem, can be used to control access to the critical section for a process or thread. The main disadvantage (same of mutual-exclusion) is require busy waiting. It will create problems in a multiprogramming system, where a single CPU is shared among many processes.
Busy waiting wastes CPU cycles.
Deadlock is a situation when two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes. The implementation of a semaphore with a waiting queue may result in this situation.

Share/Bookmark

What is deadlock? how to aviod deadlock ? how to prevent dead lock


 What is deadlock?

A: Deadlock is a situation when two or more processes are each waiting for each other to   release a resource

A deadlock is a situation where in two or more competing actions are each waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like the "chicken or the egg". The concept of a Catch 22 is similar.
When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone.
— Illogical statute passed by the Kansas Legislature


Share/Bookmark

What is paging ? what is the use of paging

In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory. In the paging memory-management scheme, the operating system retrieves data from secondary storage in same-size blocks called pages. The main advantage of paging is that it allows the physical address space of a process to be noncontiguous. Before the time paging was used, systems had to fit whole programs into storage contiguously, which caused various storage and fragmentation problems
Share/Bookmark

Related Posts Plugin for WordPress, Blogger...