magistraleinformaticanetworking:spm:farmposix
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
magistraleinformaticanetworking:spm:farmposix [22/03/2011 alle 17:47 (14 anni fa)] – Marco Danelutto | magistraleinformaticanetworking:spm:farmposix [22/03/2011 alle 18:02 (14 anni fa)] (versione attuale) – [Task farm (POSIX TCP/IP)] Marco Danelutto | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
===== Task farm (POSIX TCP/IP) ===== | ===== Task farm (POSIX TCP/IP) ===== | ||
+ | //(The code presented here does not pretend to be efficient, nor completely correct. It has been designed with the aim of illustrating several of the problems related to the implementation of fairly simple parallel applications)// | ||
==== Version 1 ==== | ==== Version 1 ==== | ||
This version uses two servers (emitter and collector). Emitter accepts requests from workers and delivers tasks to be executed. Collector accepts results from workers and print them out on the screen. Workers open a separate connection with both emitter and collector for each task. The two connections are closed after processing the task and delivering the result. Tasks and results are (positive) integers. Emitter and worker termination is handled correctly. Collector does not terminate (suggestion: | This version uses two servers (emitter and collector). Emitter accepts requests from workers and delivers tasks to be executed. Collector accepts results from workers and print them out on the screen. Workers open a separate connection with both emitter and collector for each task. The two connections are closed after processing the task and delivering the result. Tasks and results are (positive) integers. Emitter and worker termination is handled correctly. Collector does not terminate (suggestion: | ||
=== Emitter code === | === Emitter code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 80: | Linea 81: | ||
=== Worker code === | === Worker code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 172: | Linea 173: | ||
=== Collector code === | === Collector code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 230: | Linea 231: | ||
return 0; | return 0; | ||
} | } | ||
+ | </ | ||
+ | |||
+ | === Makefile === | ||
+ | <code makefile makefile> | ||
+ | CC = gcc | ||
+ | CFLAGS = | ||
+ | TARGETS = emitter collector worker | ||
+ | |||
+ | all: $(TARGETS) | ||
+ | |||
+ | clean: | ||
+ | rm -f $(TARGETS) | ||
+ | |||
+ | worker: | ||
+ | $(CC) -o worker $(CFLAGS) worker.c | ||
+ | |||
+ | collector: | ||
+ | $(CC) -o collector $(CFLAGS) collector.c | ||
+ | |||
+ | emitter: | ||
+ | $(CC) -o emitter $(CFLAGS) emitter.c | ||
+ | |||
+ | dist: | ||
+ | rsync -avz ../ | ||
+ | rsync -avz ../ | ||
+ | rsync -avz ../ | ||
</ | </ | ||
=== Deployment code (Perl) === | === Deployment code (Perl) === | ||
- | < | + | < |
# | # | ||
$sourcedir = "/ | $sourcedir = "/ | ||
Linea 245: | Linea 272: | ||
=== Deployment code (BASH) === | === Deployment code (BASH) === | ||
- | < | + | < |
#!/bin/bash | #!/bin/bash | ||
for m in $@ | for m in $@ | ||
Linea 256: | Linea 283: | ||
The launcher gets parameters from the command line (see comments) and saves the names of the machines used in the < | The launcher gets parameters from the command line (see comments) and saves the names of the machines used in the < | ||
- | < | + | < |
# | # | ||
Linea 284: | Linea 311: | ||
=== Terminator code (Perl) === | === Terminator code (Perl) === | ||
- | < | + | < |
# | # | ||
open FD, "< | open FD, "< | ||
Linea 303: | Linea 330: | ||
=== Emitter code === | === Emitter code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 426: | Linea 453: | ||
=== Worker code === | === Worker code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 525: | Linea 552: | ||
=== Collector code === | === Collector code === | ||
- | <code> | + | <codec collector.c> |
#include < | #include < | ||
#include < | #include < | ||
Linea 596: | Linea 623: | ||
=== Emitter code === | === Emitter code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 778: | Linea 805: | ||
=== Worker code === | === Worker code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < | ||
Linea 883: | Linea 910: | ||
=== Collector code === | === Collector code === | ||
- | < | + | < |
#include < | #include < | ||
#include < | #include < |
magistraleinformaticanetworking/spm/farmposix.1300816069.txt.gz · Ultima modifica: 22/03/2011 alle 17:47 (14 anni fa) da Marco Danelutto