QUESTION 29 What is the value of a counting semaphore when 7P and 8V operations are...
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
QUESTION 29
What is the value of a counting semaphore when 7P and 8V operations are executed on it?
Show answer & explanation
The final value of a counting semaphore depends on its initial value. A P operation decrements the semaphore by 1, and a V operation increments it by 1. With 7 P operations and 8 V operations, the net change is +1 (8 - 7 = +1), but without knowing the initial semaphore value, we cannot determine the absolute final value.
Step-by-step Derivation:
A counting semaphore's value is determined by: final_value = initial_value + (V_operations) - (P_operations) = initial_value + 8 - 7 = initial_value + 1. Since the initial value is not provided in the problem, the final value cannot be determined. For example: if initial = 0, final = 1; if initial = 5, final = 6; if initial = 10, final = 11.