Giter Site home page Giter Site logo

authurexcalbern / ipc Goto Github PK

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

Just code for learning to solve the classic ITC/IPC problems. Programs are mainly implemented in C language(based on C POSIX library), some will be implemented in other languages.

License: MIT License

Java 35.57% C 64.43%

ipc's Introduction

ITC/IPC

This project focuses on the ITC/IPC problems.(inter-thread communication and Inter-process communication)

By learning Modern Operating Systems, I began to solve some of the classic ITC/IPC problems.This project is the result of my attempt to solve the classic ITC/IPC problems.

Thanks to anqurvanillapy for his Issues.

Notice

  • About ITC:
    "Focusing on constructs like semaphore, mutex, condition variable, atomic variable, memory barrier, STM, etc, and even some locks with alternative implementations like spinlock for atomics. They synchronize code in a single process"(from anqurvanillapy)

  • About IPC:
    "Focusing on constructs like FIFO (named pipe), shm-based/mmap-based shared memory, message queue, message broker, naming service, balancer, etc, that are usually heavily based on sockets with specific protocols (e.g. TCP, UDP), and it's often prone to fail. Other subproblems include RPC (remote procedure call), IDL (interface description language), load-balancing or API gateway, consensus algorithms, single point of failure, high availability (a higher-level problem, actually), etc"(from anqurvanillapy)

  • About C library:
    In most C language programs, we need to use C POSIX library (instead of C standard library). For example, we need to use POSIX thread like pthread.h. So if you want to run those programs successfully, you should ensure that your compiler can support C POSIX library.
    And I will mark those programs that can only use C standard library.

Solution List

To be continue...

  • Dining philosophers problem

    • C (ITC)
      Use semaphore.h. But it also can slove by using pthread_mutex_t and pthread_cond_t (from pthread.h).
    • Java (ITC)
      Use synchronized.
  • Producer–consumer problem

    • C (ITC)
      Use pthread_mutex_t and pthread_cond_t (from pthread.h).
    • Java (ITC)
      Use synchronized.
  • Readers–writers problem

    • Readers-preference
      • C (IPC)
        Use semaphore.h and sys/shm.h. If something goes wrong, we should run rm_shm.c to delete the shared memory.
    • Writers-preference
    • Other
      • C (ITC)
        Use pthread_rwlock_t (from pthread.h).

My Compiler

gcc and clang compiler should use -pthread.

  • gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0
  • g++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0
  • clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
  • openjdk version "9-internal" javac 1.8.0_151

Other

"Synchronization constructs are mainly about wise/unwise choices of design and good/bad uses of abstractions, which you could take into a deeper consideration."(from anqurvanillapy)

I will later make a document for analysis and discussion (Focus on my solutions). But this is very difficult and complicated, so it may be a long time to come true.

License

See the LICENSE file for license rights and limitations.

ipc's People

Contributors

authurexcalbern avatar

Stargazers

 avatar

Watchers

 avatar

ipc's Issues

So how can these ITC problems be of IPC?

  • ITC (inter-thread communication) is probably your problem domain, focusing on constructs like semaphore, mutex, condition variable, atomic variable, memory barrier, STM, etc, and even some locks with alternative implementations like spinlock for atomics. They synchronize code in a single process
  • IPC aims at some constructs like FIFO (named pipe), shm-based/mmap-based shared memory, message queue, message broker, naming service, balancer, etc, that are usually heavily based on sockets with specific protocols (e.g. TCP, UDP), and it's often prone to fail. Other subproblems include RPC (remote procedure call), IDL (interface description language), load-balancing or API gateway, consensus algorithms, single point of failure, high availability (a higher-level problem, actually), etc

In terms of C constructs like semaphore.h, pthread.h, it's better to point out their specifications/standards and even some implementation details (like scenarios for undefined behaviors).
Don't just simply dump the semver of your compilers in use. For instance, pthread.h are from POSIX, and not a part of ANSI C (C89), hence they imply bad portability (other compilers might not support them). And semaphore is a lower-level construct than a mutex, since a mutex could be implemented by a semaphore (the so-called critical section). Synchronization constructs are mainly about wise/unwise choices of design and good/bad uses of abstractions, which you could take into a deeper consideration.

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.