os:lab06
Return to Home page
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/lab06?rev=1574661824&do=diff
Differences
This shows you the differences between two versions of the page.
— | os:lab06 [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | Return to [[os: | ||
+ | ---- | ||
+ | ====== Operating Systems Course: Lab06 ====== | ||
+ | ===== Laboratory number 06 ===== | ||
+ | |||
+ | ==== Exercise 01: From recursion to concurrency ==== | ||
+ | The program named [[https:// | ||
+ | |||
+ | Transform the program from recursive to concurrent, i.e., substitute the recursive implementation with the generation (by means of a '' | ||
+ | |||
+ | |||
+ | ==== Exercise 02: Concurrent file sorting ==== | ||
+ | Implement a concurrent program with '' | ||
+ | |||
+ | The program (which name '' | ||
+ | <code bash> | ||
+ | pgrm n strA strB | ||
+ | </ | ||
+ | where: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | The input files '' | ||
+ | * in the first row, the number of integer numbers stored in the lines following the first | ||
+ | * in the following rows, the integer numbers. | ||
+ | |||
+ | The following is an example of correct file: | ||
+ | <code strA1.txt> | ||
+ | 5 | ||
+ | 102 | ||
+ | 99 | ||
+ | 34 | ||
+ | 234 | ||
+ | 25 | ||
+ | </ | ||
+ | |||
+ | The program, after the generation of the '' | ||
+ | |||
+ | Each thread: | ||
+ | - reads from " | ||
+ | - sorts (with a sorting algorithm of your choice) the vector with a numeric sort, and in an // | ||
+ | - saves the result in " | ||
+ | |||
+ | Note that the program implements the following // | ||
+ | |||
+ | <code txt> | ||
+ | Mi--------- | ||
+ | /\ | | ||
+ | / | ||
+ | R1 R2 ... | ||
+ | | | | ||
+ | O1 O2 ... | ||
+ | | | | ||
+ | W1 W2 ... | ||
+ | | ||
+ | \/ | | ||
+ | Mf--------- | ||
+ | </ | ||
+ | where: | ||
+ | - Mi and Mf are the initial and final operations of the main | ||
+ | - The flows Ri, Oi and Wi represent the execution of the threads, each of which | ||
+ | - read its input file (Ri) | ||
+ | - sort it (Oi) | ||
+ | - save it in its output file (Wi). | ||
+ | |||
+ | |||
+ | ==== Exercise 03: Concurrent file sorting and merging ==== | ||
+ | Modify the previous program in a way that the '' | ||
+ | |||
+ | More in detail: | ||
+ | - each thread reads and sorts the data stored in a file (but it does **not** write the results on an output file) | ||
+ | - the '' | ||
+ | - once all threads are terminated and all the sequences have been //merged//, the main stores the entire list of ordered data into a (single) output file. | ||
+ | |||
+ | The third command line parameter of the program indicates the name of the output file. | ||
+ | For simplicity (to allocate the data structure) it is possible to suppose that all the files store the same number of values and, eventually, this number is known a priori. | ||
+ | |||
+ | === Suggestions === | ||
+ | Use a matrix to store the data read by the input files, and dedicate a row (or a column) to each file (or, alternatively, | ||
+ | |||
+ | Each thread manipulates exclusively its //own// row (or column) of the matrix (or element of the vector). | ||
+ | |||
+ | The '' | ||
+ | * at the termination of the first thread, it merges '' | ||
+ | * at the termination of the second thread, it merges '' | ||
+ | * at the termination of the third thread, it merges '' | ||
+ | * ... | ||
+ | |||
+ | The '' |
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/lab06?rev=1574661824&do=diff