Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #7670
| From | Joe Beanfish <joebeanfish@nospam.duh> |
|---|---|
| Newsgroups | comp.os.linux.networking, comp.os.linux.misc |
| Subject | Re: Mental-model of multiprocessing? |
| Date | 2013-03-27 14:02 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <kiuu67$4lv$1@dont-email.me> (permalink) |
| References | <kiuk8p$4is$1@dont-email.me> |
Cross-posted to 2 groups.
On Wed, 27 Mar 2013 11:13:30 +0000, Avoid9Pdf wrote:
> For someone who knows the stacked-subroutine-calling mechanism [down to
> the silicon level], and resists the little-men-in-the-box mental model,
> it's difficult to UNDERSTAND how to build a script that:
> calls a URL via openssl,
> conducts a dialog with the remote server,
> and saves the log of the process in a file.
> --
> My main difficulty seems to be that apparently the 'routines'
> are NOT stacked:
Correct, they all run at the "same" time. See below.
> User's shell > Script > openssl > REPEAT{dialog; log}.
>
> What's the meaning of:
> cat>/tmp/mesgFile
Read from stdin and write that to mesgFile.
> (
Commands inside parens are run in another shell.
> read line 0<&3 ; echo "$line">$log case "$line" in 2*) ;; *) echo
> "QUIT" 1>&3 ; exit 0 ;; esac echo "HELO $local_name" 1>&3
Read from file-descriptor 3 into variable line. Log it.
If it starts with anything but 2 write QUIT to file-descriptor 3 and exit.
write "HELO .." to file-descriptor 3.
> ) 3<>/dev/tcp/$smtp_server/25 ??!
Set file-descriptor 3 to read/write the specified device.
> Where's to doco/man for the syntax:-
> cat>/File ( <read; select; write> ) 3<>/dev/tcp/URL/PORT ??!
Those (>, <, <>, read, case) are all shell (bash) constructs, so in
the bash manual.
> How is data read from /dev/tty ?
>
> # echo dog > /dev/tty # cat /dev/tty # echo dog > /dev/tty ; cat
> /dev/tty give unexpected results FOR ME
/dev/tty is an alias for your "terminal". Remember that an ssh or telnet
shell session is essentially like a console session which is a glass tty.
Reading (cat) from a tty takes input from the "keyboard". Writing to a tty
displays the output on the "screen".
> So, where's a good mental-model of multiprocessing,
> documented?
For the real thing instead of a model how about
"Design of the Unix operating system" by Maurice J. Bach.
Chapter 5.12 for Pipes. Chapters 6-8 for processes.
*Quick* overview of preemptive multitasking (glossing over MANY details):
The kernel loads N programs and lets each one run for a small slice of
time. Then it suspends the running one, and lets another run for a slice,
and so on many times a second. So it *appears* that they are all running
at the same time. This way programs can interact with each other without
one having to run to completion first. It also allows one program to sit
and wait for something, like disk or user input, without holding up all
the other programs that are also running.
Given the [silly] shell command
echo "Hello World" | cat >foo
the shell tells the kernel to run programs "echo" and "cat" with the
standard-output(stdout) of echo connected to the standard-input(stdin)
of cat (see pipe(2) and pipe(7)). And the standard output of cat
connected to file "foo". So when cat reads it's stdin it will see "Hello
World" and dutifully write that to it's standard-output. Upon trying to
read more it will find nothing, because echo didn't print more, and
therefore quit. The result will be "Hello World" in the file foo.
HTH
Back to comp.os.linux.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-27 11:13 +0000
Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-03-27 14:02 +0000
Re: Mental-model of multiprocessing? Richard Kettlewell <rjk@greenend.org.uk> - 2013-03-27 14:13 +0000
Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 14:35 +0000
Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-27 15:30 +0000
Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 18:57 +0000
Re: Mental-model of multiprocessing? Richard Kettlewell <rjk@greenend.org.uk> - 2013-03-27 21:15 +0000
Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-27 21:36 +0000
Re: Mental-model of multiprocessing? Aragorn <stryder@telenet.be.invalid> - 2013-03-28 06:56 +0100
Re: Mental-model of multiprocessing? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2013-03-27 21:47 +0000
Re: Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-29 14:28 +0000
Re: Mental-model of multiprocessing? The Natural Philosopher <tnp@invalid.invalid> - 2013-03-29 15:32 +0000
Re: Mental-model of multiprocessing? J G Miller <miller@yoyo.ORG> - 2013-03-29 22:36 +0000
Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-29 17:31 +0000
Re: Mental-model of multiprocessing? Avoid9Pdf@gmail.com - 2013-03-29 21:10 +0000
Re: Mental-model of multiprocessing? "Chris F.A. Johnson" <cfajohnson@gmail.com> - 2013-03-29 18:55 -0400
Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-03-30 06:01 +0000
Re: Mental-model of multiprocessing? Chris Davies <chris-usenet@roaima.co.uk> - 2013-03-30 21:28 +0000
Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-04-01 15:32 +0000
Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-04-03 08:00 +0000
Re: Mental-model of multiprocessing? Joe Beanfish <joebeanfish@nospam.duh> - 2013-04-08 14:47 +0000
Re: Mental-model of multiprocessing? Unknown <dog@gmail.com> - 2013-04-03 08:02 +0000
csiph-web