26.02.2014 Views

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

Getting Started with QNX Neutrino - QNX Software Systems

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

© 2009, <strong>QNX</strong> <strong>Software</strong> <strong>Systems</strong> GmbH & Co. KG. Multiple threads<br />

Some examples<br />

Send-driven (client/server)<br />

Reply-driven (server/subserver)<br />

An important subtlety<br />

that we’re limited only by the number of available machines on the network (and<br />

network bandwidth, of course). Combining this <strong>with</strong> multiple threads on a bunch of<br />

SMP boxes distributed over a network yields “clusters of computing,” where the<br />

central “arbitrator” delegates work (via the server/subserver model) to the SMP boxes<br />

on the network.<br />

Now we’ll consider a few examples of each method.<br />

Filesystems, serial ports, consoles, and sound cards all use the client/server model. A<br />

C language application program takes on the role of the client and sends requests to<br />

these servers. The servers perform whatever work was specified, and reply <strong>with</strong> the<br />

answer.<br />

Some of these traditional “client/server” servers may in fact actually be reply-driven<br />

(server/subserver) servers! This is because, to the ultimate client, they appear as a<br />

standard server, even though the server itself uses server/subserver methods to get the<br />

work done. What I mean by that is, the client still sends a message to what it thinks is<br />

the “service providing process.” What actually happens is that the “service providing<br />

process” simply delegates the client’s work to a different process (the subserver).<br />

One of the more popular reply-driven programs is a fractal graphics program<br />

distributed over the network. The master program divides the screen into several areas,<br />

for example, 64 regions. At startup, the master program is given a list of nodes that<br />

can participate in this activity. The master program starts up worker (subserver)<br />

programs, one on each of the nodes, and then waits for the worker programs to send to<br />

the master.<br />

The master then repeatedly picks “unfilled” regions (of the 64 on screen) and delegates<br />

the fractal computation work to the worker program on another node by replying to it.<br />

When the worker program has completed the calculations, it sends the results back to<br />

the master, which displays the result on the screen.<br />

Because the worker program sent to the master, it’s now up to the master to again<br />

reply <strong>with</strong> more work. The master continues doing this until all 64 areas on the screen<br />

have been filled.<br />

Because the master program is delegating work to worker programs, the master<br />

program can’t afford to become blocked on any one program! In a traditional<br />

send-driven approach, you’d expect the master to create a program and then send to it.<br />

Unfortunately, the master program wouldn’t be replied to until the worker program<br />

was done, meaning that the master program couldn’t send simultaneously to another<br />

worker program, effectively negating the advantages of having multiple worker nodes.<br />

April 30, 2009 Chapter 2 • Message Passing 89

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!