473,809 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13373
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.goo glegroups.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.goo glegroups.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.co m...
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
4925
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 killed when it reaches the limit (like it can be done with resource module). Can you help me?
3
2628
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
11563
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 the box. It had 2GB RAM, and sqlserv.exe would take up to 1.85GB of RAM, exhausting the physical RAM on the box. SQL would choke and the Solomon users would have problems, and I would have to restart the SQL service. I added another GB of...
2
1760
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 returned dataset is not limited to the range I have in the SQL clause. Here's the code:
10
3837
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 MB) and after a while I get the Windows message saying that the virtual memory's getting really low. Plus the machine gets really sluggish (with multi-threading). Is it possible to use the virtual memory until it reaches a certain limit and then use...
16
4991
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 set the POST limit in php.ini to 8 megs. What reasons, other than the POST limit, would a large upload fail?
1
1902
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 bandwidth and latency of the network. When streaming very large files, memory usage approaches to 2GB limit and sometimes results in out-of-memory errors. I'm considering writing my own throttle in my C++ component that polls private bytes. The only...
5
12653
by: Max2006 | last post by:
Hi, What is the limit for memory that a .NET process or AppDomain can use? Thank you, Max
1
5049
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 configured by your system administrator has been reached. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10378
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.