Date: Fri, 4 May 2001 10:35:47 -0700 (PDT) From: David Caldwell <inonit@yahoo.com> To: freebsd-java@freebsd.org Subject: RE: Reading and writing audio data at the same time on Linux Message-ID: <20010504173547.56360.qmail@web11504.mail.yahoo.com> In-Reply-To: <Pine.GSO.4.31.0105041621220.28133-100000@mail.ilrt.bris.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
Jan: I agree with what you've said ... there is no "guaranteed portable" way of ensuring timesliced scheduling. The MAX_PRIORITY thread is a 90% solution that works (essentially emulates timeslicing) in all the VMs that I know of ... but perfectly legal Java VMs could be constructed in which it would not work (as you point out, it would be legal to map every priority onto one native priority, for instance). I think the only way to guarantee that a thread will run is to make sure that every other thread is blocked. That said, I don't have an encyclopedic knowledge of the spec, either, and I'm too lazy to check it right now. If I do give the spec a good read before anyone else does, I'll post the results. -- David. --- Jan Grant <Jan.Grant@bristol.ac.uk> wrote: > On Fri, 4 May 2001, David P. Caldwell wrote: > > > I'm not an expert on the linux JDK, but I ran into this sort of problem a > > few years back. > > > > Could it have to do with different scheduling? > > > > Since the Java VM specification doesn't say much about how threads have to > > work, implementors on Windows have tended to use timeslicing (which Windows > > has), while implementors on Unix-like OSes have tended to use preemptive > > (for different priorities) but non-timeslicing scheduling. > > > > On Unix-like OSes, usually a call to Thread.yield() is required > periodically > > if you want other threads with equal priority to have a chance to run. > > Alternately, you can start a separate Thread at Thread.MAX_PRIORITY that > > just wakes up every specified number of milliseconds and does nothing, > > causing the scheduler to switch threads. > > Actually, according to the java spec (as I've been led to understand it) > there is NO WAY to guarantee round-robin timesliced scheduling in java. > > Why? Well, your suggestion above sounds plausible: have a high-priority > thread wake up occasionally and ensure that the right priority thread is > running. But Java says that thread priorities may be mapped onto a > smaller number of priority levels that the ohst OS provides, and says > nothing about how that mapping is performed. The result is that there > seems (to me, at least) to be NO portable way of ensuring that your > MAX_PRIORITY thread is _really_ running at any higher priorituy than any > other thread, so it may never wake up. > > If this is wrong, I'd love to hear of a pointer to the bits in the spec > that I've misunderstood ...? > > -- > jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ > Tel +44(0)117 9287163 Fax +44 (0)117 9287112 RFC822 jan.grant@bris.ac.uk > stty intr ^m > > __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010504173547.56360.qmail>