3 ms·
I'd say MUL(T) is absolutely useless in any practical manner. I'd take some form of CAS if I want atomic operations. MUL has to deal with overflow a lot more th
by xxs 5y ago
I'd say MUL(T) is absolutely useless in any practical manner. I'd take some form of CAS if I want atomic operations. MUL has to deal with overflow a lot more than inc/dec. Not knowing the value prior MUL, taking any branches is another issue, CAS would solve in that case as well.
Inc/dec are useful for a counter implementation (although I see no reason to have a designated dec) - even though counters should not be implemented in such a manner, e.g. each writer should have its own counter, and reader should sum them up when the value is needed. No contention, scalable.
In that regard I'd consider the interview question "weak", lacking a deeper understanding - not just show us you can code.
- gorgoiler 5y agoOh it’s a great question. Code this solution without having to worry about why. If only the job was actually like that. The why is 10x the how, IRL, once you get beyond IC0.5.