AuthurExcalbern / IPC

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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


Languages

Language:C 64.4%Language:Java 35.6%