Tuesday, October 2, 2012

Interview Questions BB 4

8. what is bus error? common causes of bus errors?

A bus error rarely means that the computer hardware is physically broken—it is normally caused by a bug in a program's source code.


There are two main causes of bus errors:
non-existent address 
  1. The CPU is instructed by software to read or write a specific physical memory address.
  2. This only covers physical memory addresses. Trying to access an undefined virtual memory address is generally considered to be a segmentation fault rather than a bus error

unaligned access 
Most CPUs are byte-addressable, where each unique memory address refers to an 8-bit byte. Most CPUs can access individual bytes from each memory address, but they generally cannot access larger units (16 bits, 32 bits, 64 bits and so on) without these units being "aligned" to a specific boundary. For example, if multi-byte accesses must be 16 bit-aligned, addresses (given in bytes) at 0, 2, 4, and so on would be considered aligned and therefore accessible, while addresses 1, 3, 5, and so on would be considered unaligned. Similarly, if multi-byte accesses must be 32-bit aligned, addresses 0, 4, 8, 12, and so on would be considered aligned and therefore accessible, and all addresses in between would be considered unaligned. Attempting to access a unit larger than a byte at an unaligned address can cause a bus error.

A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system).
Segmentation is a historic term for the approach to memory management nowadays known as paging (see e.g. Lions' Commentary on UNIX 6th Edition, with Source Code), but the term is still used in the context of "segmentation fault
9. How do applications communicate with kernel?
using shell with the help of a system call

10. What happens if the parent process ends before the child process?

To be more precise if a parent process dies before "wait()ing" for a child process then the child process becomes orphan and the init process(pid=1) becomes the parent.
Init process periodically "wait()s" for all its child processes to make sure they end up being defunct/zombie. OR then child process will come under root process, which is generally called init.

No comments:

Post a Comment