I try to think of insomnia as an uninvited personal trainer. It's a slightly nightmarish visitor who can nevertheless be helpful, if approached with sufficient care and determination.
When I was very young the intrusion of sleeplessness would always be associated with joy and hoping to annihilate the boring night before something good happened in the morning. It probably didn't last that long, didn't seem to cause tiredness and was all part of the pleasure of anticipating something wonderful. A little later, it was still a positive state. I would start thinking in the peace and security of my bed and begin scribbling notes under the covers – I was a horrible child and clearly going to be no use for anything beyond a life of typing.
But my real education began with wakeful nights caused by stress: I would hear my parents fighting, I would think of frightening teachers, I would fret over schoolwork I might have done poorly and – eventually – over exams that could ruin me if I crashed out in them and forgot what peristalsis was, or that the proper conjugation of the Latin verb to stand was sto stare steti statum, not sto stare stui statum. I got used to feeling cold and sick and small and wanting to be away from myself fast. The term fast asleep promised I might be locked safely and quickly away from harm. But my body wouldn't let me leave.
Insomnia was my first intimation of my body's unreliability. Before, it had always done what I asked. But just as I approached adolescence it demonstrated in many ways that it was only agreeing with me when it wanted to and that when it liked it would give me spots, or odd changes in weight, then short sight, then grey hairs and crinkly elbows, just because it could. It was and is the boss of me.
Some of the characteristics of my – thank God – intermittent insomnia have changed. The loneliness it seems to create in its particular dark can be alleviated – books are wonderful company and the internet puts people in other time zones within reach. I have a friend who tweets when he can't sleep – the blend of anger, despair and sheer, bloody tiredness seems very familiar. I read when I can't sleep now, watch sci-fi, text or email folks I know will be wakeful. Lying there trying to fight it just gives me a headache. As does fretting that this is the least suitable night to be sleepless. Of course it is. It always is. So I try to relax, not get tangled and overheated.
But time alone in bed with an unreliable mind is still a battle. When I can't sleep I recite the fears that would harm me most: harm to the man I love, or my mother, ill health, bad ill health, penury, death. It's horrible and pointless. So now I try to use the inventory to rehearse my appreciation for the good I have about me, to promise I will seize the day. What we love can be lost, so why not love it a lot while it's here ?
And on the good nights – when I'm writing into the small hours, jacked up on caffeine and pretending to be heroic at the keyboard – then I'm a kid again, dreaming with my eyes open, hoping for something wonderful, having fun.
• AL Kennedy's latest book is All The Rage (Jonathan Cape).