Description
Modify the multi-threaded server (file server.c) such that it is created with a pool of
N threads and a buffer of M ints. The sever validates the argument:
$ ./server
usage: ./server N-threads M-items
When the buffer has reached its full capacity, inputs are ignored until room is available.
In the following scenario, inputs 5 and 6 are lost because the buffer is full:
$ ./server 2 2
*** 2 threads, 2 buffered items
1 2
Processing: 1
Processing: 2
3 4
5 6
buffer is full!
buffer is full!
Done with: 1
Processing: 3
Done with: 2
Processing: 4
7
Done with: 3
Processing: 7
Done with: 4
Done with: 7
Here is another normal execution:
./server 5 10
*** 5 threads, 10 buffered items
1 2 3 4 5
1
Processing: 1
Processing: 2
Processing: 3
Processing: 4
Processing: 5
6 7 8 9 10 11 12 13 14 15
Done with: 1
Done with: 2
Processing: 7
Done with: 3
Done with: 5
Processing: 8
Processing: 6
Processing: 9
Done with: 4
Processing: 10
Done with: 7
Done with: 9
Processing: 12
Processing: 11
Done with: 6
Processing: 13
Done with: 8
Processing: 14
Done with: 10
Processing: 15
Done with: 12
Done with: 11
Done with: 13
Done with: 14
Done with: 1
Due date: March 11. Submit you work on cuLearn. This exercise must be done
in the C programming language under Linux (make sure it runs on Ubuntu 16.04).
Submit a single tar.gz file. Submit source code and makefile. You are responsible for
the completeness of your submission. You are responsible for submitting your work on
time. Submissions that do not compile are not accepted.
2

