Giter Site home page Giter Site logo

ipc-in-linux's Introduction

IPC-in-Linux

Inter-process communication in Linux

Design 1: Shared File
• There is a shared file called design1.dat. All communications are carried out on this file.
• Clients can write to the file, server can read and write to the file.
• We can create as many clients as we want. There is only one server.
• Chat outputs are visible only on the server’s terminal. Client terminals are used for only inputs.
• The file is locked and unlocked before and after read/write actions at all times.

To run the Design 1:

  1. Run the client:
gcc design_1/client.c
./a.out
  1. Enter client name
  2. Enter the message to be written on shared file
  3. Run the server to see messages:
gcc design_1/server.c
./a.out

Design 2: Shared Memory
• There is a shared memory. All communications are carried out on this memory.
• Clients can write to the memory, server can read and write to the memory.
• We can create as many clients as we want. There is only one server.
• Chat outputs are visible only on the server’s terminal. Client terminals are used for only inputs.
• The memory is locked and unlocked using semaphores before and after read/write actions at all times.
• There are two semaphores: one for reader(server) one for writing permissions.
• Server opens the shared memory and waits for a client to write something into the memory (waits on a semaphore (read_semaphore which is initially 0))

To run the Design 2:

  1. Run the client:
gcc design_2/client.c -o client -lrt -pthread
./client
  1. Enter client name
  2. Enter the message to be written on shared memory
  3. Run the server to see messages:
gcc design_2/server.c -o server -lrt -pthread
./server

Design 3: Unnamed Pipes
• There is an unnamed pipeline. All communications are carried out on this pipeline.
• Clients can write to the pipeline, server can read and write to the pipeline.
• Chat outputs are visible only on the server’s terminal. Client terminals are used for only inputs.
• The pipeline is locked and unlocked using semaphores before and after read/write actions at all times.
• There are two semaphores: one for reader(server) one for writing permissions.

To run the Design 3:

  1. Run the client:
gcc design_3/client.c
./a.out
  1. Enter client name
  2. Enter the message to be written on shared pipeline
  3. Run the server to see messages:
gcc design_3/server.c
./a.out

Design 4: Named Pipes
• This is similar to unnamed pipes question. However, this time there is no parent-child relation.
• We can create as many clients as we want.

Design 5: Message Queues
• This is similar to the named pipes.
• There is a single semaphore, only for the writers.

Design 6: Sockets
• There is a single socket.
• There is a single semaphore.

Design 7: Sockets + Signals
• This is same as the previous design.
• Server is able to kill the clients by receiving a message “killme”. Server sends a kill signal to the client and the client will be terminated.

ipc-in-linux's People

Contributors

melikedogru avatar

Watchers

 avatar

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.