FIFO Library | C, Linux (November 2025): A simple FIFO (First-In-First-Out) library implemented in C. Built off of semaphore structures that are built off of primitive spin locks. The program is meant to solve the problem of concurrent access to shared data structures in a multi-threaded environment, dealing with multiple readers and writers.
This project provides a thread-safe, concurrent FIFO queue for inter-process communication (IPC) using shared memory. It includes synchronization primitives like semaphores and spinlocks, built from low-level assembly operations, to ensure safe access in multi-process environments. The FIFO maintains order and handles concurrent producers and consumers without data corruption.
fifo.c/fifo.h: Main FIFO implementation with circular buffer and read/write operations.sem.c/sem.h: Semaphore implementation using spinlocks for atomicity.spin.c/spin.h: Spinlock implementation with busy-wait and CPU yielding.tas.S/tas.h: Low-level x86-64 assembly for atomic test-and-set operations.testfifo.c: Test program for FIFO operations, including producer-consumer scenarios.testsem.c: Test program for semaphore operations.testspin.c: Test program for spinlock operations.Makefile: Build script for compiling the project.
Run make to compile the object files and executables.
Refer to the test files (testfifo.c, etc.) for examples of how to use the FIFO, semaphores, and spinlocks in your code. The library is designed for Unix-like systems with support for shared memory and signals.