limite the use of CPU by threads.

V

VirtualDev

i want to know how to limite the use of CPU by threads using C++. can
you help me please?
 
P

Puppet_Sock

VirtualDev said:
i want to know how to limite the use of CPU by threads using C++. can
you help me please?

You need to ask this in a news group specific to your compiler
and operating system. Since you don't even mention what CPU
you are using, it's pretty difficult to even begin to guess what
news group that might be. Try groups.google.com and do some
searching for your platform.

Here we only talk about the standard C++ language, and that
does not include any notion of a thread, never mind doing any
sort of limiting the CPU in a thread.
Socks
 
P

Phlip

VirtualDev said:
i want to know how to limite the use of CPU by threads using C++. can
you help me please?

You are asking how to set the scheduler priority of threads.

You need to use Google to find a forum dedicated to your threading library.
This forum is only qualified to discuss the C++ language itself, which
doesn't come with a portable thread solution.

Further, both the need to have threads and the need to schedule their
priorities are signs of a poor design. Entry-level programmers often use
threads instead of building an event-driven architecture. So you might
think about simplifying your design, too.
 
D

damjan

Puppet_Sock said:
You need to ask this in a news group specific to your compiler
and operating system. Since you don't even mention what CPU
you are using, it's pretty difficult to even begin to guess what
news group that might be. Try groups.google.com and do some
searching for your platform.

Here we only talk about the standard C++ language, and that
does not include any notion of a thread, never mind doing any
sort of limiting the CPU in a thread.
Socks

Can someone please explain to me this standard C/C++ vs. platform
dependent issue. Considering threads, the C run-time library includes a
function __beginthread. Under Windows (pardon me for saying) this is in
a file libcmt.lib. If I link with that library or call functions from it
(e.g. the aforementioned beginthread), does that mean my source won't
port to linux?

Then how do i know what is and what isn't a part of standard C/C++, that
is, which functions i mustn't call if i want to retain portability?

Dumb question, i know, but the "this is not a standard c++ topic" kind
of replies seem to exuberate here.
 
V

Victor Bazarov

damjan said:
[..]
Can someone please explain to me this standard C/C++ vs. platform
dependent issue. Considering threads, the C run-time library includes
a function __beginthread.

Here is your explanation: the C run-time library only includes that
function on _your_ *particular* platform. It doesn't on many others.
That's what it means "platform-dependent".
Under Windows (pardon me for saying) this
is in a file libcmt.lib. If I link with that library or call
functions from it (e.g. the aforementioned beginthread), does that
mean my source won't port to linux?

It might. Or it might not. You need to ask in a Linux newsgroup.
Then how do i know what is and what isn't a part of standard C/C++,
that is, which functions i mustn't call if i want to retain
portability?

RTFM. If it does not specify which functions are ANSI (ISO) standard
library functions, then get a better M.
Dumb question, i know, but the "this is not a standard c++ topic" kind
of replies seem to exuberate here.

Unfortunately. Many first-time posters simply do not understand that the
library they are using consists of two parts: the standard part and the
platform-specific part. They often confuse the two. The same with the
language. There is the standard part and there are extensions. Every
compiler provides some. We in comp.lang.c++ only discuss standard parts
of both the langauge and the library. For compiler-specific extensions
there are compiler-specific newsgroups. For platform-specific library
portions there are platform newsgroups. Easy? I say. But seems far too
complicated for some posters.

V
 
K

kwikius

Phlip said:
You are asking how to set the scheduler priority of threads.

You need to use Google to find a forum dedicated to your threading library.
This forum is only qualified to discuss the C++ language itself, which
doesn't come with a portable thread solution.

Further, both the need to have threads and the need to schedule their
priorities are signs of a poor design.

Are you saying that use of threads is poor design?
Are you saying that setting priority of a thread is a sign of poor
design?

Entry-level programmers often use
threads instead of building an event-driven architecture. So you might
think about simplifying your design, too.

Are you saying that a system using threads is an alternative to an
event driven system?

regards
Andy Little
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top