Sunday, 7 September 2008

Bus Arbitration

Deciding which bus master gets to use the bus next is called bus arbitration. There are a wide variety of schemes for bus arbitration; these may involve special hardware or extremely sophisticated bus protocols. In a bus arbitration scheme, a device (or the processor) wanting to use the bus signals a bus request and the later granted the bus. After a grant the device an use the bus, later signalling to arbiter that the bus is no longer required. The arbiter can grant the bus to another device. Most multiple bus masters have a set of bus lines for performing request or grants. A bus release line is also needed if each device does not have its own request lines. Some times the signals used for the bus arbitration have physically separate lines, while in other systems the data line of the bus are used for this function (though this prevents overlapping of arbitration with transfer).

Arbitration scheme usually try to balance two factors in choosing which device to grant the bus. First, each device has a bus priority, and the highest priority device must be serviced first. Second we should prefer that any device, even one with low priority, never be completely locked out from the bus. This property called fairness ensures that every device that wants to use the bus is guaranteed to get it eventually. In addition to these factors more sophisticated schemes aim to reduce the time needed to arbitrate the bus. Because arbitration time is overhead, which increases the bus time access, it should be reduced and overlapped with the bus transfers whenever possible.

Bus arbitration schemes can be divided into four broad classes.

Daisy chain arbitration
In this scheme the bus grant line is run through the device from highest priority to lowest priority (the priorities are determined by the position on the bus). A high priority device that desires bus access simply intercepts the bus grant signal, not allowing the lower priority device to see the signal.
Advantage: Simplicity.
Disadvantage: It cannot assure fairness- allow priority request may be locked out indefinitely-and the use of the daisy chain grant signal also limit the bus speed.

Centralised, parallel arbitration
These schemes use multiple request lines, and the device independently requests the bus. A centralized arbiter chooses from among the devices requesting bus access and notifies the selected device that it is now bus master.
Disadvantage: It requires a central arbiter, which may become the bottleneck for bus usage.
PCI, a standard backplane bus, uses a central arbitration scheme.

Distributed arbitration by self selection
These schemes also use multiple request lines, but the devices requesting bus access determine who will be granted access. Each device wanting bus access places a code indicating its identity on the bus. By examining the bus, the devices can determine highest priority device that has made a request. There is no need for a central arbiter; each device determines independently whether it is the high priority requester. This scheme however does require more lines for request signals.
The NuBus, which is the backplane bus in Apple Macintosh II, use this scheme.

Distributed arbitration by collision detection
In this scheme each device independently request the bus. Multiple simultaneous request results in a collision. The collision is detected and the scheme for selecting among the colliding parties is used.
Ethernet use this scheme.

Saturday, 6 September 2008

Hard Disk Size Measurement

Manufacturers and operating system measures hard disk capacity in different ways. That is, the binary gigabyte and the decimal gigabyte. When we install a new 160 GB (manufacturer measurement) hard drive, we see that operating system reports only 149 GB. Similarly, if we install a 4GB hard disk we get 3.72GB. This difference is because of the way in which manufacturers and software developers calculate the drive capacity. Technically, hard drive capacity is calculated by multiplying the number of cylinders, sectors, and heads time 512.

Capacity = Cylinders * Heads * Sectors * 512 (bytes per sector)

So a typical drive with 7752 cylinders, 16 heads and 36 sectors.
7752 * 16 * 63 * 512 = 4,000,776,192 bytes

Hard disk manufacturers use decimal megabyte to determine the size of their hard drive.
4,000,776,197 bytes / 1,000,000,000 = 4.0 GB

Whereas software makers use binary megabytes to calculate the drive size. A binary gigabyte is 1,073,741,824 bytes and a binary megabyte is 1,048,576 bytes. So we get 4,000,776,192 bytes / 1,073,741,824 = 3.72.