In this assignment your task is to create very simple thread pool.
In files queue.h
, worker.h
, queue.c
and worker.c
is prepared implementation of
task executor. It contains queue implementation as well.
The goal is to have worker, that executes given jobs concurrently using pthread library.
Deadline is 9th November 2017 23:59:59 CET (22:59:59 UTC)
Late submission will be penalised by 2 points for every day after deadline
You will submit code that will be thread-safe in worker.c
, queue.c
,worker.h
and queue.h
, you will also submit
tests you used to prove your code in test_queue.c
and test_worker.c
.
As last part of assignment you will write an pdf report, where you'll discuss which techniques of
mutual exclusion you have used and why.
The report will also contain list of problems you discovered in process of development using hellgrind,
with short description of them and solution you have chosen.
The queue implemented in queue.c
is not prepared to be used in multiple threads.
Your first task is to add appropriate mutual exclusion technique to the queue implementation,
so it can be safely used in multithreaded application.
There is also test_queue.c
file which should contain your tests for queue, which you will use to
check your code with helgrind. It's very recommended to write those tests first and try to run
helgrind against unmodified queue first.
You should write down every problem you might encounter during development, you will use it in report.
The worker is implemented in worker.c
but currently it runs pushed jobs in master thread when
function worker_execute
is executed. The goal is to start several threads in worker_init
, number of threads is one of attributes of function.
The threads will then take out jobs from queue and execute them asynchronously.
As for queue you should write tests first in file test_worker.c
and write down any problems you will encounter during development.
You will also need to create some function that will be used as thread executor, which will pop job from queue and run the task.
The last part of assignment will be report of your work. You are expected to write how you solved assignment, what thread-related problems you've found during development and how you've solved them. If you are not capable writing buggy code, or you won't encounter any error reported by hellgrind during development, then your task will be to write some thread dangerous code by yourself, and report errors you will find. For instance you can try to use Worker to calculate over same memory from different threads.