How do you prevent race conditions when sharing a buffer between a main loop and an interrupt handler?
Implement process_buffer(capacity, operations) to simulate a bounded single-producer, single-consumer ring buffer. Each operation is ['write', value] or ['read']; return True or False for writes and the consumed integer or None for reads. Writes to a full buffer and reads from an empty buffer must fail without corrupting existing data.
def process_buffer(capacity, operations):