473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

limit CPU usage in C#

good day...

i noticed that when moving 750mb (multiple) files, it only used about
20% of the CPU usage...

i thought i could also do this 1 to my application, so that it wont eat
up much of my CPU usage and hang up eventually...

do you have codes for this 1??? hope someone here can give me this...
thanks....

Nov 17 '05 #1
5 13336
Hi,

Moving files is an OS feature.
If OS is configured properly and drives are proper and OS is in good mood
then moving files around won't eat your CPU time.
Just use File.Copy.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"tracernet_v2" <hy******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
good day...

i noticed that when moving 750mb (multiple) files, it only used about
20% of the CPU usage...

i thought i could also do this 1 to my application, so that it wont eat
up much of my CPU usage and hang up eventually...

do you have codes for this 1??? hope someone here can give me this...
thanks....

Nov 17 '05 #2

"tracernet_v2" <hy******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
good day...

i noticed that when moving 750mb (multiple) files, it only used about
20% of the CPU usage...

i thought i could also do this 1 to my application, so that it wont eat
up much of my CPU usage and hang up eventually...

do you have codes for this 1??? hope someone here can give me this...
thanks....


Moving files is an IO bound operation, not a CPU intensive one. The fact
that only 20% of the time is spent executing instructions is because most of
the time the CPU is waiting for IO completion.
A CPU bound application, that is an application that continiously executes
instructions without some explicit waits (say sleep) or without performing
IO operations, will use the CPU for close to 100%. There is nothing in the
system that can set a CPU quota per process, all you can do is give up your
CPU slice by inserting wait's in your program, but again why would you do
this, CPU's are meant to execute instructions not to wait.

Willy.
Nov 17 '05 #3
> There is nothing in the
system that can set a CPU quota per process, all you can do is give up your
CPU slice by inserting wait's in your program, but again why would you do
this, CPU's are meant to execute instructions not to wait.

Willy.


If you have a long-running CPU-intensive task, you might want to limit
the impact on the rest of the system by using just 80% (or so) of the
available cycles.

Hans Kesting
Nov 17 '05 #4
Hans Kesting wrote:
There is nothing in the
system that can set a CPU quota per process, all you can do is give up your
CPU slice by inserting wait's in your program, but again why would you do
this, CPU's are meant to execute instructions not to wait.


If you have a long-running CPU-intensive task, you might want to limit
the impact on the rest of the system by using just 80% (or so) of the
available cycles.


The normal way of doing this is by setting the priorities of the
various threads to be low. That means that when other things need
doing, they can take the CPU - but when there aren't, the CPU-intensive
code can run at full speed. There's no point in only using 80% of the
CPU time when nothing else needs to run.

Jon

Nov 17 '05 #5

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:mn***********************@spamgourmet.com...
There is nothing in the system that can set a CPU quota per process, all
you can do is give up your CPU slice by inserting wait's in your program,
but again why would you do this, CPU's are meant to execute instructions
not to wait.

Willy.


If you have a long-running CPU-intensive task, you might want to limit the
impact on the rest of the system by using just 80% (or so) of the
available cycles.

Hans Kesting


If there are ready to run threads in the system, they will get their share
of the CPU even if you have a long running CPU intensive task running, this
is how the scheduler works.
If you need to give more CPU time to other tasks that the long running task,
you can lower the active thread's priority, but doing so will not restrict
the CPU time to a certain level, all depends on the level of activity of the
other threads, if they are also CPU bound your thread's share will drop far
below 80%, if there are no realy active threads in the system, your thread
will still occupy most of the CPU time.
In short, you can't say I want this thread to be at most 80% on the CPU.
Note that it's not impossible to implement a kind of watch dog that changes
the thread(s) priority or reduces the thread's quantum of a process
depending on it's current activity and as such limit it's share of the
CPU's, SQL server has this so called throttle/governor built-in to prevent
tasks from consuming more than x resources (CPU and others).

Willy.
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: mmf | last post by:
Hi. My problem: How can I make sure that a Python process does not use more that 30% of the CPU at any time. I only want that the process never uses more, but I don't want the process being...
3
by: Jay K | last post by:
Hi, I have multiple queries like this: SELECT col1, col2, col3, col4 FROM table1, table2 where table1.col1 = table2.col1 and table1.col2 = 1 ORDER BY col3 desc LIMIT 5 and
2
by: Brian | last post by:
SQL Server 2000 SP3 on a Dell dual 2.4GHz Xeon box 3GB RAM Windows 2K SP4. Two aplication dbs, each less than 2GB in size. Had a problem where we would run Solomon queries and what not against...
2
by: Mike | last post by:
New to PHP and MySQL. Using PHP5 and MySQL 4.1 Windows XP Pro IIS 5.1 I'm trying to page a recordset, and am using a LIMIT clause to fetch a defined range of records from my db. However, the...
10
by: VM | last post by:
How can I limit the use of the PC's virtual memory? I'm running a process that basically takes a txt file and loads it to a datatable. The problem is that the file is over 400,000 lines long (77...
16
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
1
by: michaelpyles | last post by:
IIS6 (x86) - Classic ASP application - I am downloading files via calls to BinaryWrite from a C++ COM component. The ASP DLL doesn't seem to do a good job limiting memory usage based on the...
5
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
1
by: Tiger Boon | last post by:
Anyone knows how to overcome the following problem? And also, I belive Crystal Report has a limit of 75 print job. How do we check the current usage? The maximum report processing jobs limit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.