Prime Multiprocessor

Parallel prime number calculation with forward/reverse execution and automatic archiving.

The Prime Multiprocessor is a Python-based system designed to generate prime numbers in parallel by leveraging multiple independent processes interconnected as a pipeline. It operates in two distinct phases—Forward Processes and Reverse Processes—to ensure comprehensive coverage of the computation sequence. Each process: - Starts from a user-defined initial number or from the last prime generated by the previous process. - Runs for a random duration between 30–60 seconds (using the Python random module). - Computes prime numbers using an optimized modulo-based primality check. - Sends its final computed value (or a timeout-adjusted number if computation was interrupted) to the next process via a multiprocessing.Pipe connection. Prime numbers generated during each process are recorded in a CSV file containing: 1. Serial number of the entry 2. Time taken to generate the prime (seconds) 3. The prime number itself Forward execution proceeds sequentially from Process 0 → Process N, while reverse execution runs from Process N → Process 0, appending results to the same CSV file to facilitate direct forward/reverse performance comparison. Once all processes complete, the system: - Archives all CSV files into a timestamped ZIP file using the zipfile module. - Removes the original CSVs from disk to conserve space. The program includes robust error handling for: - Invalid user input (non-integers, negative values). - Cases where large numbers exceed the allocated time per process, ensuring computation resumes cleanly in the next stage. This design allows cross-platform execution (tested on Windows and macOS), producing accurate, time-stamped datasets for both forward and reverse computations, and providing clear insights into prime generation performance across varying process orders.

Execution Snapshot

Extracted from the report: Tabulated CSV-like outputs showing serial number, time taken, and prime numbers generated during forward and reverse execution for each process.