A single IDE interface can support two devices. Most motherboards come with dual IDE interfaces (primary and secondary) for up to four IDE devices. Because the controller is integrated with the drive, there is no overall controller to decide which device is currently communicating with the computer. This is not a problem as long as each device is on a separate interface, but adding support for a second drive on the same cable took some ingenuity.
To allow for two drives on the same cable, IDE uses a special configuration called master and slave. This configuration allows one drive's controller to tell the other drive when it can transfer data to or from the computer. What happens is the slave drive makes a request to the master drive, which checks to see if it is currently communicating with the computer. If the master drive is idle, it tells the slave drive to go ahead. If the master drive is communicating with the computer, it tells the slave drive to wait and then informs it when it can go ahead.
The computer determines if there is a second (slave) drive attached through the use of Pin 39 on the connector. Pin 39 carries a special signal, called Drive Active/Slave Present (DASP), that checks to see if a slave drive is present.
Although it will work in either position, it is recommended that the master drive is attached to the connector at the very end of the IDE ribbon cable. Then, a jumper on the back of the drive next to the IDE connector must be set in the correct position to identify the drive as the master drive. The slave drive must have either the master jumper removed or a special slave jumper set, depending on the drive. Also, the slave drive is attached to the connector near the middle of the IDE ribbon cable. Each drive's controller board looks at the jumper setting to determine whether it is a slave or a master. This tells them how to perform. Every drive is capable of being either slave or master when you receive it from the manufacturer. If only one drive is installed, it should always be the master drive.
Many drives feature an option called Cable Select (CS). With the correct type of IDE ribbon cable, these drives can be auto configured as master or slave. CS works like this: A jumper on each drive is set to the CS option. The cable itself is just like a normal IDE cable except for one difference -- Pin 28 only connects to the master drive connector. When your computer is powered up, the IDE interface sends a signal along the wire for Pin 28. Only the drive attached to the master connector receives the signal. That drive then configures itself as the master drive. Since the other drive received no signal, it defaults to slave mode.
For more information, check out the links below.