How to use power of Dual/ Quad core Processors in Applet?

S

Sanny

I have a large Applet I wish to use Dual/ Quad core Computers to take
advantage of all the 4/ 2 processors they have.

Will the JVM automatically gives each thread devoted to one core or
have to write something to assign different cores to different cores?

Bye
Sanny
 
P

Patrick

Sanny a écrit :
I have a large Applet I wish to use Dual/ Quad core Computers to take
advantage of all the 4/ 2 processors they have.

Will the JVM automatically gives each thread devoted to one core or
have to write something to assign different cores to different cores?

If you write carefully your program with multiple threads, the JVM
should assign them to different cores. But it may also depend of the
operating system.
 
T

Twisted

I have a large Applet I wish to use Dual/ Quad core Computers to take
advantage of all the 4/ 2 processors they have.

Will the JVM automatically gives each thread devoted to one core or
have to write something to assign different cores to different cores?

Just use threads to divide up the computational work in your
application.
 
D

Daniel Pitts

Sanny a écrit :



If you write carefully your program with multiple threads, the JVM
should assign them to different cores. But it may also depend of the
operating system.

Actually, The threads themselves may not be "assigned" to specific
cores, but when a core becomes free, the OS will choose which thread
to schedule on that core. Although the actual algorithm is somewhat
complicated, its fair to say that using multiple threads will give you
a fairly even distribution among the cores, assuming you're using a
modern OS and modern JVM.
 
S

Sanny

Actually, The threads themselves may not be "assigned" to specific
cores, but when a core becomes free, the OS will choose which thread
to schedule on that core. Although the actual algorithm is somewhat
complicated, its fair to say that using multiple threads will give you
a fairly even distribution among the cores, assuming you're using a
modern OS and modern JVM.

Does Unix, Windows 98, Windows XP, Windows Vista, OS/2, Linux etc
support Dual & Quad Processors.

My Applet is for everyone. So I want it to work on every Operating
System.

One more Question does an Applet gets only those resources which
Browser provides? Will it depend also on which browser the user is
using.

Is there a Chart where I can see which Browsers and Operating Systems
support Dual Core/ Quad core Processoors.

And Maximum how many threads can be created for an Applet. Can I
create 100 or 1000 threads running Simultaniously without crashing the
Browser?

JAVA was once a very modern language but I feel it is loosing it's
importance because of Microsoft Monopoly. Why do Microsoft not give
enough support for Java. We see Flash works better than Applets and
faster, While even little Applet takes lot of time to download. Why
Browsers do not support Applet as par as Flash.

Bye
Sanny
 
R

Roedy Green

Will the JVM automatically gives each thread devoted to one core or
have to write something to assign different cores to different cores?

So long as you have multiple threads, the multiple processors will be
automatically exploited. The JVM does not assign a thread to a
processor. On each slice the OS just gives the highest priority
waiting thread to the first available processor.
 
K

~kurt

Sanny said:
Does Unix, Windows 98, Windows XP, Windows Vista, OS/2, Linux etc
support Dual & Quad Processors.

I know Solaris has supported multiple processors for a long time,
same with Linux. I'm pretty sure Vista and XP do because I remember
having support for dual processors even with NT.

- Kurt
 
R

Roedy Green

I'm pretty sure Vista and XP do because I remember
having support for dual processors even with NT.

Duals have been supported since NT days, but I don't know about Quads.
 
P

pkriens

So long as you have multiple threads, the multiple processors will be
automatically exploited. The JVM does not assign a thread to a
processor. On each slice the OS just gives the highest priority
waiting thread to the first available processor.
Are you sure about this? Due to the problems with multi-core memory
models I would expect a lot of Java code to fail due to lack of proper
synchronization (which also handles memory synchronization between
CPUs). I think some OSs have an affinity for a single CPU, at least I
would not assign an application to multiple cores at the same time
unless I was told the application could live in a multi-core world.

Kind regards,

Peter Kriens
 
N

nebulous99

Are you sure about this? Due to the problems with multi-core memory
models I would expect a lot of Java code to fail due to lack of proper
synchronization (which also handles memory synchronization between
CPUs).

Threaded code that doesn't synchronize properly will experience buggy
behavior even on single-CPU systems. Threaded Java code that does
synchronize properly should not experience buggy behavior on multi-CPU
systems (at least, none that it can't also exhibit on single-CPU
systems, i.e. buggy behavior that it can exhibit due to having bugs
unrelated to race conditions, deadlocks, and other concurrency issues)
and should naturally use the available cores subject to OS
multiprocessing support and any OS affinity configuration. (Windows
users can use task manager to force a running javaw.exe onto a single
core or more generally a specific subset of the available cores, for
example, but by default it will spread out to use them all, at least
under the ubiquitous XP SP2.)

Bug-free compute-intensive threaded Java code appears to function
correctly and attain full CPU utilization on a dual-core Athlon with
XP SP2 and Java 1.6.0_0something, in actual practise, also.
 
L

Lew

Of what "multi-core memory models" do you speak?

Java has a well-defined memory model that the JVM on any system must follow.
How is its memory model subject to "the problems with multi-core memory
models"? (Be specific and precise.)

Why would you expect "a lot of Java code to fail due to lack of proper
synchronization" in greater proportion on multi-core systems than on
single-core systems, given that both have to follow the Java Memory Model?

Do you blame Java?

Threaded code that doesn't synchronize properly will experience buggy
behavior even on single-CPU systems. Threaded Java code that does
synchronize properly should not experience buggy behavior on multi-CPU
systems ... [more accurate and cogent information followed]

Exactly. The memory model is the same. Concurrent programming is tricky. If
pkriens were to actually study it, they might find that the Java Memory Model
exists specifically to address issues that come up on multi-CPU systems but
not on single-core systems.

So whether Roedy is sure about his assertion or not, I sure am.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Roedy said:
Duals have been supported since NT days, but I don't know about Quads.

Workstation is limited to 2.

Server is limited to 4 and 8 depending on version (it is claimed
that version with 32 exist, but ...).

Arne
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Sanny said:
Does Unix, Windows 98, Windows XP, Windows Vista, OS/2, Linux etc
support Dual & Quad Processors.

Windows 98 does not. I am not sure of OS/2. The rest should.
My Applet is for everyone. So I want it to work on every Operating
System.

Java shoudl enable you to do that.
One more Question does an Applet gets only those resources which
Browser provides? Will it depend also on which browser the user is
using.

It should depend on th JVM used.
Is there a Chart where I can see which Browsers and Operating Systems
support Dual Core/ Quad core Processoors.

You should read documentation for the OS's.
And Maximum how many threads can be created for an Applet. Can I
create 100 or 1000 threads running Simultaniously without crashing the
Browser?

In theory yes. But all JVM's are not bug free.

Note that 1000 threads will be painfully slow (unless it is a very
huge system).
JAVA was once a very modern language but I feel it is loosing it's
importance because of Microsoft Monopoly. Why do Microsoft not give
enough support for Java. We see Flash works better than Applets and
faster, While even little Applet takes lot of time to download. Why
Browsers do not support Applet as par as Flash.

Why did you expect MS to help the competition ??

Arne
 
K

~kurt

Roedy Green said:
Duals have been supported since NT days, but I don't know about Quads.

One thing I could never figure out on that machine is, when I would run
a process that sucked down a lot of CPU, and took a long time, it would
hit both of the processors at 50%. I'd think a single process would
hit the one processor at 100% (this was not a multi-threaded app). I'm
wondering if the process manager would just indicate that both were being
used to make me feel like I was getting my money's worth out of the machine.

Around the same time, on our Solaris server, one process would max out
one processor. We would fire up another process, and see the other
processor fire up.

- Kurt
 
R

Roedy Green

Are you sure about this? Due to the problems with multi-core memory
models I would expect a lot of Java code to fail due to lack of proper
synchronization (which also handles memory synchronization between
CPUs). I think some OSs have an affinity for a single CPU, at least I
would not assign an application to multiple cores at the same time
unless I was told the application could live in a multi-core world.

You are saying the hardware is at fault -- it does not share memory
between multi CPU caches as advertised? I know nothing about this. I
am merely repeating a response given when someone a long time ago
asked about how you lock a thread onto a CPU.

A single CPU program will mask threading bugs longer than a dual CPU,
so you should test multithreading code on a dual CPU.
 
T

Twisted

One thing I could never figure out on that machine is, when I would run
a process that sucked down a lot of CPU, and took a long time, it would
hit both of the processors at 50%. I'd think a single process would
hit the one processor at 100% (this was not a multi-threaded app). I'm
wondering if the process manager would just indicate that both were being
used to make me feel like I was getting my money's worth out of the machine.

The Windows scheduler will sometimes move threads from one processor
to another, so you can indeed have a single-threaded app using 50% of
each of two cores. Set a processor affinity for this process using
Task Manager and confine it to one core, and you'll see it run that
core at 100% and leave the other idle.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

pkriens said:
Are you sure about this? Due to the problems with multi-core memory
models I would expect a lot of Java code to fail due to lack of proper
synchronization (which also handles memory synchronization between
CPUs). I think some OSs have an affinity for a single CPU, at least I
would not assign an application to multiple cores at the same time
unless I was told the application could live in a multi-core world.

Assuming that:
- the Java program is written correctly according to Java memory model
- the JVM is implemented correctly
then it will work.

Multi CPU or core context is just more likely to see buggy code
actual fail. But the code is not less buggy on a single CPU and core
system and it could also fail there - it may just be one out
of a million instead of one out of two chance.

Arne
 
K

~kurt

Twisted said:
each of two cores. Set a processor affinity for this process using
Task Manager and confine it to one core, and you'll see it run that
core at 100% and leave the other idle.

Ah. Although, I generally try not to mess with these things. My assumption
is the people who design the kernel know a lot more about how to split up
resources than I do....

- Kurt
 
P

pkriens

You are saying the hardware is at fault -- it does not share memory
between multi CPU caches as advertised? I know nothing about this. I
am merely repeating a response given when someone a long time ago
asked about how you lock a thread onto a CPU.

A single CPU program will mask threading bugs longer than a dual CPU,
so you should test multithreading code on a dual CPU.

The Java memory model allows the caches of the processors to differ
for variables that are not synchronized or volatile. So on processor A
you can read a different value for variable x than on processor B
until they are synchronized. Code that works well on a single
processor because there is only one memory can fail subtly on multiple
processors. Obviously the code is wrong, but I think it makes sense to
schedule Java programs on a single CPU unless specifically allowed.

Kind regards,

Peter Kriens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
topweb3twitterchannels

Latest Threads

Top