Giter Club home page Giter Club logo

multi-threaded-processor's Introduction

Multi-threaded Producer Consumer Pipeline

Text Line Processor; Multi-threaded Producer Consumer Pipeline

Instructions

Create a program that creates 4 threads to process text input from standard input as follows.

  • Thread 1, called the Input Thread, reads in lines of characters from the standard input.
  • Thread 2, called the Line Separator Thread, replaces every line separator in the input by a space.
  • Thread 3, called the Plus Sign thread, replaces every pair of plus signs, i.e., "++", by a "^".
  • Thread 4, called the Output Thread, write this processed data to standard output as lines of exactly 80 characters.
  • Furthermore, these 4 threads must communicate with each other using the Producer-Consumer approach.

Multi-Threading Requirements

image

A pipeline of 4 threads. Input thread reads data from stdin and puts it in Buffer 1. Line Separator thread gets data from Buffer 1, processes it and puts it in Buffer 2. Plus Sign Thread reads data from Buffer 2, processes it and puts it in Buffer 3. Output Thread reads data from Buffer 3 and output lines to stdout.

Pipeline of threads that gets data from stdin, processes it and displays it to stdout.

Each pair of communicating threads must be constructed as a producer/consumer system. If a thread T1 gets its input data from another thread T0, and T1 outputs data for use by another thread T2, then T1 acts as a consumer with respect to T0 and T0 plays the role of T1โ€™s producer T1 acts as a producer with respect to T2 and T2 plays the role of T1โ€™s consumer. Thus each thread in the interior of the pipeline (i.e., the Line Separator and Plus Sign threads) will contain both producer code and consumer code. Each producer/consumer pair of threads will have its own shared buffer. Thus, there will be 3 of these buffers in your program, each one shared only by its producer and consumer. It must use synchronization variables for coordination. The program must never sleep.

multi-threaded-processor's People

Contributors

parkhyey avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

mathcodeman

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.