I'm not going to mask this as anything but what it is... a homework help thread. I'm also not asking for anyone to give me the answer but to instead maybe point me in the right direction.
That said, here's my issue.
I'm attempting to write a C++ program that creates 15 threads, then accesses some shared resources. Problem is, I'm having trouble coming up with a good mechanism for synchronizing the threads so that each thread has a quasi-equal opportunity at hitting the shared resource (no deadlock/livelock).
I've got several google links, but at this point could use some peer to peer discussion over the topic. I've written the program thus far to create the threads and access the shared resource using a mutex... However, the method I'm doing it is laughable and leading to several threads never accessing the shared resource.
The main problem is for each thread to grab numbers from a pool of numbers from 0-999999 until the shared pool of numbers is exhausted.
The code I have thus far is on a VM, so I will copy and paste it here shortly unless no one shows any interest in assisting me. :[
Thanks in advance.
That said, here's my issue.
I'm attempting to write a C++ program that creates 15 threads, then accesses some shared resources. Problem is, I'm having trouble coming up with a good mechanism for synchronizing the threads so that each thread has a quasi-equal opportunity at hitting the shared resource (no deadlock/livelock).
I've got several google links, but at this point could use some peer to peer discussion over the topic. I've written the program thus far to create the threads and access the shared resource using a mutex... However, the method I'm doing it is laughable and leading to several threads never accessing the shared resource.
The main problem is for each thread to grab numbers from a pool of numbers from 0-999999 until the shared pool of numbers is exhausted.
The code I have thus far is on a VM, so I will copy and paste it here shortly unless no one shows any interest in assisting me. :[
Thanks in advance.