I'm not sure in what context you want the question answered. maybe what isn't explained or assumed is that "INCREMENT A" or "DECREMENT A" is one instruction completed in one machine cycle. The semaphone concept is very dependent on that happening in one cycle. If the processor gets an interrupt before or an interrupt after the instruction, it doesn't matter.
A multi-core processor may have trouble. It will depend on the archetecture of the machine.
I have no idea if you question is about a class, a project your doing, a homework assignment or what, I learned the semaphone concept in an Operating System class where we had to write an operating system.
The semaphore concept is very dependent on increment happening in one machine cycle.
I believe they mean when two tasks are writing the same value to a register.
if the instuction is INCREMENT A, then two processes can;t write at the same time.
But, if it's
mov A, register
increment register
mov register, A
that's 3 instructions which can be interrupted and the semaphore concept won't work. it MIGHT work if you disabled all interrupts.
there is usually a test first, where a task wants the resource. the task assumes it got the resource. If the value moved by 2 increments, it didn't get the resource and therefore it decrements the value and tries again later.
it's a wierd concept, but in order for it to work, you have to "play computer" with two tasks and pretend your being interrupted fter every instruction by another process that wants the resource.
Example:
two processes want to use the disc controller to fetch a different block.