Threading ??? Shell Scripts

Les Mikesell lesmikesell at gmail.com
Tue Jun 27 19:30:33 UTC 2006


On Tue, 2006-06-27 at 11:57 -0700, Brian D. McGrew wrote:
> Is there any way to sort of make a shell script threaded???
> 
> Something like...
> 
> #!/bin/sh
> 
> Func1()
> {
> 	Param=$1
> }
> 
> Func2()
> {
> 	Param=$1
> }
> 
> Func1 test1 &
> Func2 test2 &
> Func1 test &
> 
> ???
> 
> I think I got the write concept but bad implementation???

Using '&' forks another process that runs independently.  Usually
when you say something is threaded you mean a single process where
all threads share the same memory.  With forked processes, the
memory is shared copy-on-write, meaning that each instance starts
will the same variable settings and open files but after the
fork any changes are local and cannot affect the other instances.
If they need to share information after the fork it must be done
through pre-arranged file descriptors or similar methods.

-- 
  Les Mikesell
   lesmikesell at gmail.com





More information about the fedora-list mailing list