Messages in this thread | | | Date | Fri, 19 Jan 2001 14:18:44 -0800 | From | Mike Kravetz <> | Subject | Re: [Lse-tech] Re: multi-queue scheduler update |
| |
On Fri, Jan 19, 2001 at 02:03:06PM -0800, Davide Libenzi wrote: <stuff deleted> > > void oneatwork(int thr) > > { > > int i; > > while (!start) /* don't disturb pthread_create() */ > > usleep(10000); > > > > actthreads++; > > while (!stop) > > { > > if (count) > > totalwork[thr]++; > > > > syscall(158); /* sys_sched_yield() */ > > } > > actthreads--; > > pthread_exit(0); > > } > > > > Note that actthreads is a global variable which is being updated > > by multiple threads without any form of synchronization. Because > > of this actthreads sometimes never goes to zero after all worker > > threads have finished. > > If all threads complete successfully actthreads has to be zero.
Not as currently coded. If two threads try to decrement actthreads at the same time, there is no guarantee that it will be decremented twice. That is why you need to put some type of synchronization in place.
-- Mike Kravetz mkravetz@sequent.com IBM Linux Technology Center - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
| |