How sara-l-s-silva/ep-multithreaded-quicksort works
Project type and purpose
• This is a standalone CLI tool written in C, implementing a multithreaded QuickSort over a binary file of fixed-size records.
File structure
• Top level files:
• Makefile – build automation
• ep_input_generator.c – binary-file generator
• ep.c – main program with multithreaded QuickSort logic
• ep_output_verificator.c – post-sort validator
• mapeamentoInput.c – memory-mapping helper (likely wraps mmap calls)
• 10_registros_ja_ordenados.dat, output/… – sample data and outputs
• No “frontend” or network layers – it’s purely a local, compute-bound tool.
• Relies on POSIX threads and mmap for performance.
README for insights
• Clearly outlines the three stages: generate, sort, verify
• Emphasizes user-controlled thread count and use of mmap
• Goal: demonstrate parallel sorting performance on large files
a. Main components
1. CLI / User Interface
2. Input Generator Module
3. Memory-Mapping Layer
4. Sorting Engine (Thread Pool + Quicksort)
5. Merge/Interleave Logic
6. Output Writer
7. Output Verifier Module
b. Relationships and data flow
• User invokes ep_input_generator → writes binary file
• User invokes ep with args → main() calls mmap helper to map input file
• Sorting Engine spawns N pthreads, each sorts a segment in‐memory
• Once all threads complete, merge logic interleaves sorted segments
• Sorted buffer is written back (msync or write) to output file
• ep_output_verificator reads output file (possibly via mmap) and checks order
c. Architectural patterns / design principles
• Pipeline pattern: generator → mapper → sorter → merger → verifier
• Worker-pool (thread pool) pattern for parallel sorting
• Shared-memory via mmap to avoid explicit read/write loops
• Separation of concerns: each C file is a self-contained module
d. Key technologies/libraries
• POSIX threads (pthread_create, pthread_join)
• Memory mapping (mmap, msync, munmap)
• Standard C I/O for file creation/verifier
• Makefile for build targets