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 15th November 2018 24:00 CET (23:00 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.
As part part of implementation you should create a report that defines at least three different
corner cases that might manifest problematic or buggy behaviour in the queue implementation
and discuss the method how you avoided possible problems, for each such scenario you should
create test in test_queue.c
that will proove your code.
You should also put in the report all found errors you've encoutered during the implementation.
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 discuss possible corner-cases and bottlenecks that might happen in your worker,
since the worker is much more complex than the queue, you are expected to find, discuss and test
at least four of them. Your tests should be put in test_worker.c
file.
The last part of assignment will be report of your work. You are expected to discuss the possible points of error and corner-cases regarding the states and actions on both queue and worker and how you have tested it. Also you are expected to write how you solved assignment and what thread-related problems you've found during development and how you've solved them.