A C program that demonstrates interprocess communication, shared memory, and synchronization between processes using semaphores.
This project simulates two processes sharing access to the same bank account balance.
The parent process represents a father who checks the balance and may deposit money, while the child process represents a student who checks the balance and may withdraw money.
Both processes access the same shared memory segment, and a semaphore is used to prevent simultaneous updates to the account balance.
- Creates shared memory using System V IPC
- Shares a bank account balance between processes
- Uses
fork()to create parent and child processes - Uses POSIX semaphores for mutual exclusion
- Simulates concurrent deposits and withdrawals
- Prevents race conditions while accessing shared data
- Cleans up shared memory and semaphore resources
- C
- Linux
- System V Shared Memory
- POSIX Semaphores
- Process Management
- Make
- Interprocess communication
- Shared memory
- Process synchronization
- Mutual exclusion
- Semaphores
- Forked processes
- Race condition prevention
- Operating systems concepts
The program begins with a shared bank account balance of $100.
The parent and child processes repeatedly check the shared balance. The parent may deposit money when the balance is low, while the child may attempt to withdraw money.
A semaphore protects the shared balance so only one process can modify it at a time.
The repository includes a Makefile for compiling the project.
makeThis project was created as an operating systems project to gain hands-on experience with shared memory, process creation, semaphores, synchronization, and interprocess communication in C.