Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shared Memory Bank Simulation

A C program that demonstrates interprocess communication, shared memory, and synchronization between processes using semaphores.

Overview

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.

Features

  • 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

Technologies

  • C
  • Linux
  • System V Shared Memory
  • POSIX Semaphores
  • Process Management
  • Make

Concepts Demonstrated

  • Interprocess communication
  • Shared memory
  • Process synchronization
  • Mutual exclusion
  • Semaphores
  • Forked processes
  • Race condition prevention
  • Operating systems concepts

How It Works

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.

Building the Project

The repository includes a Makefile for compiling the project.

make

Purpose

This 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.

About

C program demonstrating shared memory, semaphores, and process synchronization through a simulated bank account.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages