Process, thread, and socket are operating system terms.  Node is very close
to the OS in abstraction so that's why you should be versed with how the OS
works to be effective with node.

Practically, a process is a program.  It has it's own memory space, the
operating system runs it on whichever CPU core is available.  It can move
between cores.  This is all automatic and done by the system.  Node doesn't
schedule processes.  A process can be killed, it can spawn new child
processes using a node API.  A process usually has some communication
channels.  On posix systems like Linux, OSX, BSD, and Solaris there is
usually stdin, stdout, and stderr (standard input, output, error).  These
can be pipes, files, sockets, but they basically are data channels.

Threads are parallel execution threads within a single process.  They are
like new processes except they share memory with each other.  Node does not
use threads for the main logic.  They are used some as implementation
details for things like fs access, but for the most part, node is
single-threaded.  Meaning there is only one thread you need to worry about.
 This is a good thing because multiple threads in a single namespace are
very dangerous and require manual locking and unlocking of shared data to
prevent corruption.  Node avoids this problem by only having one main
thread.  The down side if your node thread cannot use more than one CPU
core so you're limited to the amount of CPU power a single node process can
use.

Sockets can be network sockets (usually TCP) or local sockets.  Data gets
written to one end and comes out the other end.  They are often duplex
meaning information can travel both direction.  Pipes are very similar.
 I'm not sure of the technical difference.  An HTTP server (webserver) is a
TCP server listening on some know port and parsing incoming data as HTTP
protocol traffic.  It then responds with HTTP responses controlled by your
node code.

Workers are an idea from the browser (which is also single threaded and
event based).  They are kinda like threads in that they can run in
parallel, but don't share data.  They communicate only through data
channels.  In node this is usually done with extra processes communicating
over serialized data channels.

For deeper understanding take an Operating Systems course at university or
research online on Wikipedia and other places.


On Wed, May 16, 2012 at 1:33 AM, randomnick <[email protected]> wrote:

> i'v been playing around with node for quite a while, did some
> applications in express,
> but coming from php i'm having hard time to understand
>
> what is
> process, thread, socket, workers etc....
>
> where can i find this information, what good books really explains
> node
> without telling me its evented io on v8 javascript, i want to
> understand the terms
> that come with node.
>
> thanks.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to