1. A method in a data processing system for executing instructions, the method comprising: associating performance indicators with instructions related to acquiring a semaphore, wherein the performance indicators are data values in memory that specify counting of events that are associated with execution of the instructions or are data values in memory that specify counting of events that are associated with accesses to memory locations; executing the instructions related to acquiring a semaphore in a processor in the data processing system; detecting the performance indicators during execution of the instructions related to acquiring a semaphore; counting the events that occur within the data processing system as specified by the detected performance indicators to form counted events; retrieving a count value that represents the counted events; and using the count value to represent a number of operations related to acquiring a semaphore.