Does pain reduce cognitive abilities? Does subjecting a person to pain reduce his cognitive abilities?

If so, what is the process that reduces the ability? (By process, I mean the changes happening in the nervous system as a result of the pain and the subsequent loss of cognitive abilities)

Does this differ with gender?
For the purposes of this question, it would likely be useful to consider "pain" as simply a stimulus demanding the attention of the individual. In this light, any decrease in "cognitive abilities"—however you define that phrase—would likely be explainable as resultant from the same cognitive decrease that accompanies multitasking (or "task switching", as it is sometimes referred to) in general, which is a well-known and well-published finding.

Relevant papers can be found at the above link.