Dwarves that have been awake for a long time will eventually become tired and desire sleep. Along with eating and drinking, this is a necessary maintenance activity that your dwarves will need to perform at intervals, a few times every season. Drowsy dwarves are indicated by a blinking gray arrow.
Dwarves that go without sleep will work more slowly. However, dwarves do not ever remain drowsy for long; upon getting sleepy they will finish whatever task they are currently performing, find a bed, and then slump onto them, falling unconscious. If no bed is available, they will fall to the floor immediately after completing their last task (drunken dwarves sleeping on barrels of hard liquor are quite common). If there is an unassigned bed located closer to them then their assigned room and board, they will sometimes choose to sleep there instead; thus, hospitals often find themselves "treating" exhausted dwarves, necessitating extra beds for actually wounded dwarves.
As one might imagine, having to sleep in the dirt is not a happy occurrence, and will give your dwarves unhappy thoughts. On the other hand, sleeping on a nice bed, in a nice room will give them a happy disposition upon waking. The exact arrangement of living conditions (bedroom design) is a big part of fortress design; some players lavish their dwarves' rooms and see it as an easy way to increase their happiness, some see bedrooms only as necessary provisions, and some do away with them entirely, preferring easier-to-create, easier-to-maintain public dormitories instead (these do have the advantage of making vampire spotting a piece of cake). Nonetheless, the need to prevent your dwarves from sleeping under the stars more than a few times at the very beginning is a universally agreed-upon point of importance.
Dwarves do not follow natural sleeping cycles. There is no "night" in fortress mode, beyond references in the form of night creatures (in adventurer mode, however, this is a different story entirely). Instead, they will sleep according to their own internal clock. At the very beginning, dwarves that arrive at the same time will tend to nod off at the same time, but as time progresses, they will diverge into their own cycles. After some time, at most a quarter of the fortress may be asleep at a time.
Unhappy thoughts associated with sleeping are collapsing from exhaustion and sleeping poorly, sourly, or being woken entirely by nearby noise. Noise can cause uncomfortable or troubled sleep, or wake the dwarf entirely, which cause increasingly negative thoughts.
Another is collapsing from exhaustion, which only really happens in the military. Dwarves on active military service (stationed or attacking) will forgo sleep for duty, but will be unhappy when they finally do get to sleep. Military dwarves can nonetheless spontaneously fall to the ground unconscious if they are exhausted. Since dwarves do not come with portable pillows, cannot munch on rations or take swings from flasks as they can to relieve hunger and thirst, the need to sleep is the primary limiting factor on how long you can keep your military dwarves on high alert before they fall dangerously unconscious.
Sleeping is not the same thing as being unconscious, although the effect is the same. A dwarf may fall unconscious when they give in to pain, universally a bad thing, or when recuperating from wounds in a hospital. Finally, ambushers have a tendency to fall asleep anywhere, which can cause problems with their happiness. To prevent this behavior, disable hunting from the labors.