Thread Scheduling Policy - Thread.yield

2001-07-24 Thread Kazuhiro Minami
Hello,

I would like to know the "exact" thread scheduling policy in JDK on linux
based on a native thread model. 
I am currently using 

java version "1.2.2"
Classic VM (build Linux_JDK_1.2.2_RC4, native threads, sunwjit)

I examined the following simple test program with both a green thread
and a native thread model. In a green thread model, the strict priority-based 
scheduling is exforced, so the priority specified by Thread.setPriority 
method are considered by the scheduler in Java VM. 

On the other hand, in a native thread model, I am not sure whether the 
thread with maximum priority get the preference or not.
Both threads get pretty fair amout of time slices in turn. Furthermore, 
the Thread.yield() in Thread 1 does not cause to switch to the other thread to execute,
and Thread 1 continues to run for a while.  

import java.lang.*;

class TestThread extends Thread {
String id;

public TestThread(String s) {
id = s;
}

public void run() {
int i;
for (i = 0; i < 1000; i++) {
if(i == 500 && id.equals("Thread 1")){
System.out.println("Thread 1 yielding..\n");
yield();
}
System.out.println(id+":"+(new Integer(i)).toString());
}
}

public static void main(String args[]){
TestThread t1, t2;
t1 = new TestThread("Thread 1");
t1.setPriority(Thread.MIN_PRIORITY);
t1.start();
t2 = new TestThread("Thread 2");
t2.setPriority(Thread.MAX_PRIORITY);
t2.start();
}

I know that the spec of JVM does not say much about scheduling 
policy. 

"Every thread has a priority. When there is competition for processing
resources, threads with higher priority are generally executed in
preference to threads with lower priority. Such preference is not,
however, a guarantee that the highest priority thread will always be
running [...]"

It woudl be very nice to have the pricise description of
scheduling policy for JVM on Linux in a native thread model.
I particularly would like to know the following points.

- Is it meaning full to specify thread priority?
- Does Thread.yield work in a native thread model?

Kazuhiro 





-- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


Re: Thread Scheduling Policy - Thread.yield

2001-07-24 Thread Nathan Meyers

On Tue, Jul 24, 2001 at 01:26:01PM -0400, Kazuhiro Minami wrote:
> Hello, 
> 
> I would like to know the "exact" thread scheduling policy in JDK on 
> linux 
> based on a native thread model.  

Linux applications have very little control over how kernel threads
are scheduled - the only mechanism Linux provides for setting thread
priorities can only be used by the superuser, and even then it doesn't
match Java's thread priority model.

So the short answer is that thread priorities are ignored.

Nathan

> I am currently using  
> 
> java version "1.2.2" 
> Classic VM (build Linux_JDK_1.2.2_RC4, native threads, sunwjit) 
> 
> I examined the following simple test program with both a green thread 
> and a native thread model. In a green thread model, the strict 
> priority-based  
> scheduling is exforced, so the priority specified by Thread.setPriority 
>  
> method are considered by the scheduler in Java VM.  
> 
> On the other hand, in a native thread model, I am not sure whether the  
> thread with maximum priority get the preference or not. 
> Both threads get pretty fair amout of time slices in turn. Furthermore, 
>  
> the Thread.yield() in Thread 1 does not cause to switch to the other 
> thread to execute, 
> and Thread 1 continues to run for a while.   
> 
> import java.lang.*; 
> 
> class TestThread extends Thread { 
> String id; 
> 
> public TestThread(String s) { 
> id = s; 
> } 
> 
> public void run() { 
> int i; 
> for (i = 0; i < 1000; i++) { 
> if(i == 500 && id.equals("Thread 1")){ 
> System.out.println("Thread 1 yielding..\n"); 
> yield(); 
> } 
> System.out.println(id+":"+(new Integer(i)).toString()); 
> } 
> } 
> 
> public static void main(String args[]){ 
> TestThread t1, t2; 
> t1 = new TestThread("Thread 1"); 
> t1.setPriority(Thread.MIN_PRIORITY); 
> t1.start(); 
> t2 = new TestThread("Thread 2"); 
> t2.setPriority(Thread.MAX_PRIORITY); 
> t2.start(); 
> } 
> 
> I know that the spec of JVM does not say much about scheduling  
> policy.  
> 
> "Every thread has a priority. When there is competition for processing 
> resources, threads with higher priority are generally executed in 
> preference to threads with lower priority. Such preference is not, 
> however, a guarantee that the highest priority thread will always be 
> running [...]" 
> 
> It woudl be very nice to have the pricise description of 
> scheduling policy for JVM on Linux in a native thread model. 
> I particularly would like to know the following points. 
> 
> - Is it meaning full to specify thread priority? 
> - Does Thread.yield work in a native thread model? 
> 
> Kazuhiro  
> 
> 
> 
> 
> 
> -- 
> To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a 
> subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] 
> 
> 

-- 


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Nvidia and Java 3D

2001-07-24 Thread Jonathan Daugherty

I'm getting a Sig 11 and my x server crashes whenever I try running j3d apps.
Please help!

-- 

Jonathan Daugherty
Dept. of Computer Science / UCNS Workstation Support Group
The University of Georgia

/^.{10}\ +\d+\ +(\d+|\w+)\ +(\d+|\w+)\ +(\d+(\.\d+|)(M|k|G|)).*/ - master ls!


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Mouse click under KDE2

2001-07-24 Thread brEezE

Hi all,
When I run NetBeans using Blackdown's JDK 1.3.x under
KDE2, all the mouse clicks are treated as right-click!
Does anyone know what is wrong and how to fix it?

I am running Mandrake 8.0

Thanks!

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]