Giter Site home page Giter Site logo

jonledet / synchronization Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 62 KB

This project is a tool to help better understand classic problems of synchronization in multi-threading using synchronization primitives.

License: MIT License

Java 100.00%
bounded-buffer dining-philosophers-problem multithreading readers-writers-problem synchronization

synchronization's Introduction

Synchronization

This Java project is a synchronization problem solver that aims to provide solutions for three classic synchronization problems. The solutions are implemented using Java and make use of semaphores for synchronization.

Table of Contents

Project Overview

The project focuses on solving the following synchronization problems:

  1. Dining Philosophers

    • A classic problem where philosophers sit around a dining table and must share chopsticks without causing conflicts. Each philosopher(thread) needs 2 chopsticks(semaphores) to eat a meal.
  2. Bounded-Buffer

    • Simulates a post office with people, mailboxes, and messages. Semaphores are used to control mailbox access when sending messages. An extension of the bounded-buffer problem.
  3. Readers-Writers

    • Addresses the Readers-Writers problem where multiple readers can access a file simultaneously, but only one writer can write at a time.

Each of these problems is solved with proper synchronization techniques, ensuring that concurrent processes behave correctly.

Project Structure

The project is structured as follows:

  • src/ : Contains the source code for the three synchronization problems.
synchronization/
├── src/
│   └── com/
│       └── jonledet/
│           ├── main/
│           │    └── Main.java
│           ├── philosopher/
│           │    ├── Philosopher.java
│           │    ├── Chopstick.java
│           ├── mailbox/
│           │    ├── Person.java
│           │    ├── Mailbox.java
│           ├── readwrite/
│           │    ├── ReadersWriters.java
│           │    ├── Readers.java
│           │    └── Writers.java
│           └── utils/
│                ├── Colors.java
│                └── Tools.java
│
└── out/
  • docs/ : Documentation and additional resources.

How to Use

  1. Clone or download this repository to your local machine.

  2. Navigate to Main in the src/ directory.

  3. Compile and run the Java code for the chosen problem.

javac Main.java
java Main
  • To run Dining Philosophers, use the command line argument -A 1.
  • To run Post Office Simulation, use the command line argument -A 2.
  • To run Readers-Writer Problem, use the command line argument -A 3. For example, to run Dining Philosophers, use:
java Main -A 1

Follow the on-screen prompts and instructions to interact with and observe the solution.

You can run each problem separately and observe how they handle synchronization.

Acknowledgments

This project was completed to gain a deeper understanding of synchronization problems and their solutions. The code and implementations were developed as part of a learning process. Special thanks to the educators and resources that provided guidance and insights during the project's development.

Feel free to explore the source code and use it as a reference for your own synchronization challenges or for educational purposes.

synchronization's People

Contributors

jonledet avatar

Watchers

 avatar

synchronization's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.