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

Threads Give C-like pseudocode for solving the following problem with OpenMP: co

ID: 3603994 • Letter: T

Question

Threads

Give C-like pseudocode for solving the following problem with OpenMP: compress the contents of a directory. You may use recursion if you want. Assume that your function will look like file list compress (charl foldername) where file list is a list of files. You should assume that there is an existing function called: file get_compressed (char[ filename) that compresses a file and void add to list (file list fl, file f) that adds a file to a list. Be careful not to generate an exponential number of threads.

Explanation / Answer

file_list compress(char[] foldername){

file_list fl ={};

#pragma omp parallel

for each filename fn in the folder{

/* If there is a subfolder */

if(isFolder(fn)){

add_to_list(fl,compress(fn));

}

else{

file f=get_compressed(fn);

add_to_list(fl,f);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote