Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

FIFO or named Pipe ( Part 16/24)

By Ashish Vara

FIFO or named Pipe

I already explained about pipe in tutorial Pipe in Linux. FIFO or unnamed pipe is same as pipe or named pipe except for one thing. Pipe is a one way communication between process which is related to each other like parent and child processes. Related processes have same file descriptor, so they communicate easily through single pipe but unrelated processes have different file descriptors, so they cannot communicate through single pipe. You can communicate only through creating multiple pipes each for one communication.  Communication between multiple processes is not sufficient and hence FIFO or named pipe overcomes this limitation.

FIFO (First In First Out) is first out file which is like normal file but doesn’t save the content of file, it should pass data, write or read by first in and first out process. When one process is read or written using FIFO, another process waits   to access FIFO. So FIFO can also be used for one-way communication between multiple and unrelated processes instead of single and related process.  It  creates file inode in virtual file system same as normal file  with similar characteristics. During communication if reading or writing of any process is stopped or closed,  it’s called broken pipe. It is simple, if names are given to pipe, then one would be able to read or write data to them just like a normal file.

You can communicate between unrelated processes through FIFO or named pipe by shell command.  To create named pipe, you can use following command from terminal:

Syntax:

mkfifo file_name 

  Here, file_name is indicating the name of pipe.

  You can use another way  to create FIFO or named pipe by following command:  

mknode file_name p

  Here, file_name indicates that the name of pipe and p  indicates of file type named pipe.

 

Let’s see one example of how to communicate two processes through named pipe.

I want to convert text file to compressed file through named pipe. Suppose I have text file named pipe.txt.

First I will create FIFO or named pipe using mkfifo command.

For example,

            mkfifo pipe_fifo

 Similarly I can create FIFO or named pipe using mknod command.

For example,

            mknod pipe_fifo p

You can create named pipe using any method as I explained here.

After creating named pipe, you can use it to communicate between two processes. Now, you will be able to share data between the two processes.

I can share the data of pipe.txt file with FIFO by following line:

            cat pipe.txt > pipe_fifo

Here content of pipe.txt is shared with named pipe pipe_fifo. File pipe.txt writes data into pipe_fifo file.

After pressing ENTER key, process is in running mode, so you cannot enter another command from command terminal. Open another command terminal for reading data from pipe_fifo and convert it into compressed file. We can read from pipe_fifo and convert it into compressed file (i.e. ZIP File) by following command line:

            gzip –q –c < pipe_fifo > pipe_compressed.gz

 Now pipe.txt file is converted into zip file named pipe_compressed.gz. As soon as  you enter command in second terminal the process stops and exits from running mode.

Note: when you open another terminal, do not close first running terminal.

In next tutorial, I will explain how to create named pipe or FIFO in C programming.


Filed Under: Tutorials

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • chebyshev sine approx
  • LLC HB with synchronous rectifiers can be very dodgy?
  • building lm2596 dc dc using Arduino uno
  • ADS Cascode Power Amplifier Loadpull Problem
  • DC DC converter output voltage rise time

RSS Electro-Tech-Online.com Discussions

  • Microcontrollable adjustable and switchable constant current source for driving LED's
  • Help diagnosing a coffee maker PCB
  • Trying to make a custom automated water container for my UV purifier. Can anyone help with where to begin?
  • Control Bare LCD With ATmega328p
  • Are Cross-wind compensation and Road crown compensation functions inputs to LKA function?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering