ORT BRAUDE COLLEGE OF ENGINEERING Electronic and Electrical Engineering Department Client Server Systems and prallel programming 31261 PROJECT 7: Producer Consumer Computing Model * Look at the file sorters.py * It contains 7 popular sorting algorithms, but in our case they are restricted to lists of integers bubble_sort selection_sort insertion_sort quick_sort heap_sort merge_sort radix_sort * We want to find out which algorithm is the fastest by conducting many random experiments on many lists of different sizes * For that purpose we will need a Producer process that creates randomly shuffled lists and Consumer processes that run these algorithms (on separate processes) and returns run time results. --------- PROBLEM 1 --------- Write a ListProducer class which extends the multiprocessing.Process class and produces random lists of integers (0, 1, ...,n: shuffled) of size 1MB to 2MB and puts them on a Queue. Hints: class ListProducer(Process): def __init__(self, que, minsize=10000, maxsize=20000): Process.__init__(self) ... * Use random.shuffle(L) to shuffl your initial list (range(size)) at least 100 times * Don't forget to insert your generated list to self.que ... --------- PROBLEM 2 --------- Write a ListConsumer class which reads list from the Queue and runs all the seven sorting algoriths (on a separate process of course) and applies the sorting algorithm on that list (one in a row), and saves the run time data in a result_que (Queue object). The results are inserted into the result_que as a tuple. --------- PROBLEM 3 --------- Write a main() function which starts the ListProducer and ListConsumer and prints initial results like: 1. algorithm name, 2. list size, 3. run time, ... Think of a way to collect all these result each 100 rounds and print a total summary? Hint: def main(): list_que = Queue(50) # Bounded Queue - will never contain more than 50 lists result_que = Queue() # This is where the ListConsumer will put his results ... # This is important ! if __name__ == "__main__" : main()