Concurrent Hash Table is a program that implements the concept of concurrent hash tables using the Rust language. A concurrent hash table uses the hash table data structure to allow concurrent access by multiple threads. This program simulates the scenario of multiple threads attempting to read or modify a list of employee salaries. Due to the nature of concurrency, the resulting output is unlikely to be the same for repeated simulations.
The hash table is of a fixed size, influenced by the number of threads specified within the input file. The program uses Jenkin’s one at a time hash function to determine data placement within the hash table. The program expects input to not cause any hash collisions. If a collision occurs, the program will terminate.
Conditional variables are used to sort operations by priority in ascending order. Locks are applied on a per-bucket basis, allowing fine-tuned locking behavior for threads accessing its contents; however, it is possible to cause race conditions within the program due to the locking system.
Rust 1.91.1 is required to install and execute this program. You can install Rust through Rustup here. Alternatively, you can follow the installation instructions provided by rust-lang.org.
- Clone the repository
- Navigate to the project directory
- Build the program using
cargo build - Run the program using
cargo run main.rswithin thesrcdirectory
Upon execution, the program takes input from a file, commands.txt, within its folder location, src, and simulates multiple threads concurrently accessing a list of employee salaries. Commands are sorted by priority and the results are printed to the console. A separate log of each completed thread is printed to hash.log, located in the same directory as the program.