Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to limit and change CPU and memory of a thread?

Reply
Thread Tools

How to limit and change CPU and memory of a thread?

 
 
Ulrich Scholz
Guest
Posts: n/a
 
      10-29-2007
Dear all,

is it possible to create a thread with limited memory and limited
clock cycles? I guess this is highly dependent on the operating
system and the virtual machine.

For example, it seems to be possible to pose a memory limit if a Java
program is started from the console under Linux (options -Xmx and -
Xss). What other possibilities are there?

Thank you,

Ulrich

 
Reply With Quote
 
 
 
 
Kenneth P. Turvey
Guest
Posts: n/a
 
      10-29-2007
On Mon, 29 Oct 2007 09:20:14 -0700, Ulrich Scholz wrote:

> Dear all,
>
> is it possible to create a thread with limited memory and limited
> clock cycles? I guess this is highly dependent on the operating
> system and the virtual machine.
>
> For example, it seems to be possible to pose a memory limit if a Java
> program is started from the console under Linux (options -Xmx and -
> Xss). What other possibilities are there?
>
> Thank you,
>
> Ulrich


You can limit the heap size when you start the JVM, but not memory used by
an individual thread. Memory isn't really owned by a thread. Once
allocated any thread can access it. As far as CPU goes.. there really
isn't any way to limit it. You could have a second thread that watches
how much CPU has been used and does some action if it gets past a certain
limit, but I don't think you are looking for this.

What you probably want is for a thread to use no more than 10% of the CPU
over some time interval. I don't think there is a way to do this in Java.

I've been looking at some of these same issues myself and Java just
doesn't have a lot of capability when it comes to severely limiting a
process.

I did figure out a way to limit a Java process to only one thread. You
create a custom class loader for it and check for the class
"java.lang.Thread". If it tries to instantiate one then throw an
exception. I haven't actually tried it, but I think it would work.

You are probably writing the code you are trying to limit, so this doesn't
really apply to you.

Good luck.



--
Kenneth P. Turvey <kt->
 
Reply With Quote
 
 
 
 
Ulrich Scholz
Guest
Posts: n/a
 
      10-30-2007
On Oct 29, 7:53 pm, "Kenneth P. Turvey" <kt-use...@squeakydolphin.com>
wrote:
>
> What you probably want is for a thread to use no more than 10% of the CPU
> over some time interval. I don't think there is a way to do this in Java.


that's bad

> You are probably writing the code you are trying to limit, so this doesn't
> really apply to you.


Actually, I don't write the programs I'd like to limit. As part of
the EU project MUSIC (www.music-ist.eu), I'm developing a method,
called divide and conquer (D&C), to distribute (parts of) applications
onto an ensemble of devices. As a result, otherwise unrelated, third-
party applications can end up on the same device, thus competing for
memory and CPU. (Check out Publications > Publications related to
MUSIC > Divide and Conquer on the MUSIC portal).

D&C will assign resources to applications. Because control is better
than confidence, it is desirable that D&C can limit the resources and
is able to change these limits later on. Of course, for the purpose
of research it is OK to simply assign the limits and assume that the
applications will follow them. But I'd prefer to have at least one
demonstrator with actual control over the resources, even if this
would work only for one specific hardware/software combination.

Any suggestions welcome.

Ulrich







 
Reply With Quote
 
Ingo Menger
Guest
Posts: n/a
 
      10-30-2007
On 30 Okt., 10:37, Ulrich Scholz <d...@thispla.net> wrote:

> Any suggestions welcome.


Since you write "any": I remember having read about research concerned
with the fitness of Java for real time applications. Perhaps the
search engine of your choice finds something for +java +real +time.
(Mine does).



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      10-30-2007
On Mon, 29 Oct 2007 09:20:14 -0700, Ulrich Scholz <>
wrote, quoted or indirectly quoted someone who said :

>is it possible to create a thread with limited memory and limited
>clock cycles? I guess this is highly dependent on the operating
>system and the virtual machine.


Objects don't belong to threads. There is a common pool of objects.

To get the effect you want you would have to put a quota system into
your various constructors.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Ulrich Scholz
Guest
Posts: n/a
 
      10-31-2007
TOn Oct 30, 10:58 am, Ingo Menger <quetzalc...@consultant.com> wrote:
> On 30 Okt., 10:37, Ulrich Scholz <d...@thispla.net> wrote:
>
> > Any suggestions welcome.

>
> Since you write "any": I remember having read about research concerned
> with the fitness of Java for real time applications. Perhaps the
> search engine of your choice finds something for +java +real +time.
> (Mine does).


Thanks for pointing me to Java SE Real Time. That seems to be what I
need. I started a new thread with questions about Java SE Real Time
but feel free to point me to other information within this thread.

Thank you,

Ulrich

 
Reply With Quote
 
Ingo Menger
Guest
Posts: n/a
 
      10-31-2007
On 31 Okt., 11:15, Ulrich Scholz <d...@thispla.net> wrote:

> Thanks for pointing me to Java SE Real Time. That seems to be what I
> need. I started a new thread with questions about Java SE Real Time
> but feel free to point me to other information within this thread.


Unfortunately I can't. The only thing I know is that something like
"Java SE Real Time" exists (though I forgot the exact name) and that
"real time" somehow implies management of CPU ressources. So I thought
I could suggest you research in that direction. Hope you find
something useful.


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      10-31-2007
Ingo Menger wrote:
> Unfortunately I can't. The only thing I know is that something like
> "Java SE Real Time" exists (though I forgot the exact name) and that
> "real time" somehow implies management of CPU ressources. So I thought
> I could suggest you research in that direction. Hope you find
> something useful.


Just to add to the store of knowledge, strictly speaking a "real-time" system
is one that makes guarantees about service time. Thus you know that a context
switch can take no more than some time epsilon, for example. That epsilon
could be large as long as it's guaranteed. Naturally the shorter the epsilon,
the more responsive and generally useful is the real-time system.

The key feature of real-time systems is determinism. For non-real-time
systems, no matter how long the wait, something can take longer. You just
cannot be sure. With real-time systems you are sure.

--
Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Some shareware has a time limit and the software will not work after the time limit has expired. anthony crowder Computer Support 20 01-16-2007 10:01 AM
c program, file size limit, how to solve? 2G bytes limit. guru.slt@gmail.com C++ 1 06-27-2005 11:05 PM
cpu usage limit mmf Python 9 05-30-2005 05:54 AM
Abit BH6 motherboards ( donated to a charity ) - what is CPU limit if using a Socket 370 convertor ??? no-name Computer Support 2 05-30-2004 03:43 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57