lkml.org 
[lkml]   [2001]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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/

\
 
 \ /
  Last update: 2005-03-22 13:14    [W:1.165 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site