LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-07-2015, 03:25 PM   #1
MarkAren
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Shell script overhead for realtime processing


Hello all,

While working on a small digital video application (with character based I/O at 4M bytes/sec). A question arises about shell overhead.

Currently, data is sourced from /dev/video0 where it is passed to stdin of the first process. Output from this first process is then piped from stdout to the next process. All of the pipe connections, and process management is done using a shell script.

The other obvious option is for the first process to directly open /dev/video0, and process the data.

Assuming that the first process is written in the same language, with the same level of competence, what (roughly) is the burden of the shell script in this first example.

I realize that this may be a difficult to answer without understanding details of the first process, but any indicators, pointers to further reading etc. will be appreciated.

Thanks, Mark
 
Old 08-07-2015, 04:41 PM   #2
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
the first process reads it the same as it would if it opened it itself
first to second is the standard write->read fifo overhead

4MB per second is not much


there is no overhead here from the shell itself
it just sets up file descriptors and starts the processes

example for starting a process with stdout redirected to.. /dev/null
it would fork, close stdout (fd 1), open /dev/null (first free fd, 1) and exec the process

in short the shell acts as a shell around the kernel
hence the name
 
Old 08-07-2015, 09:19 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by MarkAren View Post
Assuming that the first process is written in the same language, with the same level of competence
Same as what?

I agree with genss that there is basically no overhead; after the shell sets up the pipes it just waits (i.e. the shell process is blocked, not running).
 
Old 08-07-2015, 11:58 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Your system is not 'real time'. Full stop. (https://en.wikipedia.org/wiki/Real-time_computing)
Now speaking of speed: shell scripts are slow because they keep forking to call external programs.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script for processing file: RudraB Programming 8 06-30-2010 01:13 AM
64Studio realtime kernel and debian lenny realtime module buid error? stratotak Linux - Newbie 0 01-30-2009 10:57 PM
processing each line of output in Bourne shell? ocicat Programming 11 08-01-2007 01:47 AM
processing a ksh shell in bash environment ntoughe Programming 9 09-12-2005 05:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration