Scenario is:
nthreads = 8
for j=0 = nthreads
pthread_created (thread_func)
for 1=0 to 1000
{
// Some work.
for j=0 = nthreads
sempost(mutex1)
// thread_func()
for j=0 = nthreads
semwait(mutex2)
// Some work.
}
thread_func()
{
while(1)
{
semwait(mutex1)
// Thread funcionality.
sempost(mutex2)
}
}
Que: I want a more efficient synchronization technique than current one. I want to remove one call to sempost
(total 8, one for one thread) at least. At the same time I want every thread to start their work at the same time.
How can it be achieved?
doing barrier or sempost/wait by each thread would involved the same expense. I want to remove one set of sempost/wait or one barrier in your case