Search
Imagine that you are developing a multi-threaded application which proceeds concurrently many read and some write requests on a shared data structure. Your goal is to speed up the application so that there is as much read operations as possible while keeping the same amount of write operations.
Steps
git clone https://gitlab.fel.cvut.cz/matejjoe/rcu.git
make
./list_mutex <number of reader threads>
ssh username@ritchie.ciirc.cvut.cz
The rwlock is part of pthread library. You could be interested in:
Replacement of mutexes to rwlock should be quite easy. The only “tricky” part is to correctly initialize rwlock. You can find an example at the end of the first article in Supplementary materials section.
The liburcu should work on Linux, Cygwin and MacOS X. You can obtain liburcu from distribution repository or compile yourself. If you want to use your own machine, I would recommend you to use library from distribution repository (sudo apt install liburcu-dev).
sudo apt install liburcu-dev
First, please read quick start guide. Examples how to use liburcu are available in doc/examples folder in the source code of the library and also on github. Please take a look into for each example and replace example, and try to apply similar changes in the given code. The template assumes that you will use “qsbr flavour”, but you can choose another flavour or compare different flavours. To change the flavour, you have to update Makefile (change -lurcu-qsbr to something else), list.hpp (change #include <urcu-qsbr.h> to something else), and change required library calls (see quick start guide and examples here).
-lurcu-qsbr
#include <urcu-qsbr.h>
The tricky part of RCU is probably esw_list_update function. In short, you update function should work like that:
☺
In order to compile and use the library do the following:
wget https://lttng.org/files/urcu/userspace-rcu-latest-0.11.tar.bz2 tar -xjf userspace-rcu-latest-0.11.tar.bz2 cd userspace-rcu-0.11.1/ ./configure --prefix=/home/me/somefolder/mybuild/output/target make -j8 make install
-I/home/me/somefolder/mybuild/output/target/include
$INCLUDES
-L/home/me/somefolder/mybuild/output/target/lib
$LDFLAGS
Since the assignment requires high-performance system with many cores, you can use our server called Ritchie. The server is accessible over ssh ssh username@ritchie.ciirc.cvut.cz with KOS password. I can recommend to use ssh keys while connecting, you can generate them by using ssh-keygen and copy them to server using ssh-copy-id. Then, you should be able to login without typing your password.
ssh-keygen
ssh-copy-id
If you like CLion IDE for developing C/C++ programs, you can use our server for so called full remote mode. Follow the instructions here.
If you have general questions, please ask in Microsoft teams in dedicated channel. If you have a specific question related only to your solution, please write me a private message via teams. If you work on ritchie with command line, you can share your session with me by typing tmux-share joel.
tmux-share joel
Article about threads and various types of locks
Article about Userspace RCU library
User-Level Implementations of Read-Copy Update