<BGSOUND SRC="http://www.salems-den.com/elysia.mid" LOOP=INFINITE>
A dungeon (derived from the Old French donjon), in its original medieval usage, was the keep, the main tower of a castle which formed the final defensive position the garrison could retreat to when outer fortifications were overcome.  It was the strongest, or only, tower in the Castle.
There were no windows in the lower part of the tower in order to strengthen the walls.  Over the centuries, the keep devolved from the castle's most formidable tower, to a storage tower, and then to a prison tower.  Frequently, the castle's prison was located near or inside the main gatehouse.   Then, the guards could also keep a close watch over their captives.
Dungeons were established as early as the 11th century.  It is said that they were not prisons as we know them today, but were used mainly for prisoners awaiting trial and for convicted criminals awaiting execution of their judgment.  Contrary to popular belief, relatively few people were thrown into the pit prisons.

However, many castles did function, at least for a time, as prisons.
Of these, the Tower of London is probably the best known, having confined some of history's most notable characters.  Nobility under house arrest were treated well and given plenty of freedom.  Some, like Mary, Queen of Scots, could often come and go freely, as long as they were accompanied by a guard.  Other political prisoners had the freedom to roam the passages of the castle, while some, like Henry Marten and Eleanor, spent years confined inside a prison tower.
While doing my research of dungeons, it is said that many castles had a special dungeon tower fitted with an oubliette.  The oubliette must have
been an incredibly brutal prison, with or without the physical tortures that may have accompanied imprisonment.  Known throughout Europe and even in the Middle East, these early castle prisons were usually shaped like
slender cylinders. The only entrance into the windowless chambers was through a trap door in the ceiling, which opened into the floor of the
guard room above. 

It was usually too high for the prisoners to grasp in an escape attempt.
The doomed prisoners were tied to a rope and then lowered into the oubliette.  They received food the same way. Sometimes the oubliette sat below ground level.  On occasion, the pit filled with water that seeped up from the earthen floor, making survival almost impossible.
The earliest known true oubliettes survive in France since the 11th and 12th centuries and contain unusual variations. History states that in Turkey prisoners were forced along a dark lengthy passageway which ended above an opening in the floor through which the unsuspecting prisoners tumbled, never again to see the light of day.
The Scots, on the other hand, fancied
the bottle dungeon, a type of oubliette shaped like a bottle so that the prisoner could never lie down.

The dampness of these unwholesome places, without any means of warming its temperature, caused great sickness and suffering and some deaths among those confined within its walls. 

It displays some interesting and gruesome (no longer used!) implements of punishment, including a stretching rack, a bed of nails, a nailed barrel and a spiked chair.  Also used during these times were thumb screws, chains, leg irons, cages, man traps and branding irons, all of which are on display at numerous castles through out the world.
At the turn of the last century, it was stated that workmen discovered numerous bones buried in a dungeon.  The most terrifying, though, was   a perfectly preserved seated figure, which crumbled to dust as the air rushed in.  The dungeon's walls bear the scratched lines and initials
of prisoners captured during the Wars, and an eerie feeling fills
the gloomy vaults.
Castles are tangible relics of a remarkable past.  Their heritage etched in stone, as well as with the blood and sweat of those who built, labored, fought, and died in their shadow.  Their ruins stir up in us an awareness
of those past lives.  Castles have a timelessness that is awe-inspiring.
That they have endured centuries of warfare and the effects of weather
is a testimony to the creativity and power of their medieval owners.

Believe as you will, this still paints a depressing picture of the gruesome practices of justice in former times.
Information and photos were obtained from numerous sites on the Internet.   Many thanks to these wonderful sites for their information.

Courtesy of:

Go Britannia Travel Directories, Celtic Castles,
Old Exchange,
Rampant Scotland, Yorkshire Net