Server/client shm application
Implement the following two programs:
-
Initializes a hash table of given size (provided via the command line)
-
Supports the insertion of items in the hash table
-
Hash table collisions are resolved by maintaining a linked list for each bucket/entry in the hash table
-
Supports concurrent operations (multithreading) to perform insert, get and delete operations on the hash table
-
Use readers-writer lock to ensure safety of concurrent operations
-
Communicates with the client program using shared memory buffer (POSIX shm)
Enqueues requests/operations (insert, read, delete) to the server (that will operate on the the hash table) via shared memory buffer (POSIX shm)
- Linux kernel. Alternatively, Darwin can be used.
- GCC compiler
-
Compile the server
gcc server.c -o server -lrt -lpthread
-
Compile the client
gcc client.c -o client -lrt -lpthread
-
Run the server by specifying also the size of the Hash Table
./server --size 20
-
Operations available with the client
-
Operation to insert (key, value) pair in the Hash Table
./client -i --key <key> --value <value>
-
Operation to delete a key from the Hash Table
./client -d --key <key>
-
Operation to retrieve the value of a key from the Hash Table
./client -g --key <key>
-
Operation to shutdown the server
./client --shutdown
-
- WSL (Windows 11) using the same gcc command as the one in setup
- Linux Kernel (Ubuntu 22.04.4 LTS) using the same gcc command as the one in setup
- Darwin (macOS Sonoma 14.3.1 with M2 Max) -> using the same gcc command as the one in the setup, but without the option -lrt