Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please do in C language. the name of the book is Parallel Programming 2nd ISBN:

ID: 3866101 • Letter: P

Question

Please do in C language.

the name of the book is Parallel Programming 2nd ISBN: 0-13-140563-2

Exercise for Chapter 7 – Load Balancing Using the Pipeline Structure

This programming exercise is from the textbook Problem 7-2 in Page 225.

Write a parallel Program that will implement the load-balancing technique using the pipeline structure described in Section 7.2.3 for any arbitrary set of independent arithmetic tasks.

Please follow the following guidelines in writing your program:

Make Process 0 generate a set of tokens (e.g., integers). Process 0 doesn’t participate in task processing. Instead, it passes tokens alone to pipeline to other processes, and print a message when the program is terminating. The number of tokens must be several times larger than the number of processes.

Use the structure in Figure 7.7 and the codes in Page 209 to organize your coding.

Make each process sleep for 1 second when it takes a “task” to process, i.e., pulling out a token from the buffer to process.

When the program terminates, each process prints a message showing its rank and the number of “tasks” it has processes.

Process 0 sends a termination token to other processes when all tokens have been sent out. Each process terminates when it receives the termination token and has finished all “tasks” from the local buffer.

comm If buffer empty, make request - Request for task Receive task from request If free, If buffer full. send task Receive task from request request task task Figure 7.7 Using a communication process in line load balancing

Explanation / Answer

Innovations in hardware Architecture like hyper threading or multi core processor mean that parallel computing reaources are available.

Features and benefits

1.Borad covarage all aspects of programming

2.special emphasis on runtime efficiency and memory organisation

#include<stdio.h>

class purpose

{

int num_task=0;

String buffer;

String request_task;

for(int i=0;i<num_task;i++)

{

recv(p1,request_tag);

send($task,p1,task_tag)

}

if(buffer==empty)

{

send(pi-1,request-tag)

recv($buffer,pi-1, $task)

}

if(buffer == full) &&(!busy)

{

task=buffer;

buffer=empty;

busy=true;

}

if(busy)

{

send(pi-1,request-tag)

}

}

}

}