473,323 Members | 1,551 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,323 software developers and data experts.

Managing CPU usage

When I run a given application and monitor its cpu usage with the windows
task manager I see that it uses 50% of the available cpu resources (the other
50% going to the system idle process).

In an attempt to speed-up the process I split into two threads but still the
entire process only consumes 50% of cpu resources.

How can I make my application consume a significantly higher percentage of
resources.

Here's my actual code for the threaded process (my processor is a
hyperthreading model).

Public Function Hypermultiply(ByVal A_matrix As Double(,), ByVal
B_matrix As Double(,)) As Double(,)
Dim task1 As New threadmultiply
task1.set_matrixA(A_matrix)
task1.set_matrixB(B_matrix)

Dim m As Integer = A_matrix.GetLength(0) - 2
Dim n As Integer = B_matrix.GetLength(1) - 2
Dim p As Integer = A_matrix.GetLength(1) - 2
If (A_matrix.GetLength(1) - 2) <> (B_matrix.GetLength(0) -
2) Then
Throw (New ApplicationException("for A X B, columns in A
and rows in B must be equal"))
End If
task1.Dimension_matrixC(m, n)
'Dim result(m + 1, n + 1) As Double
Dim result As Double(,)
Dim thread1 As New Threading.Thread(AddressOf
task1.process_i_the_1st_half)
Dim thread2 As New Threading.Thread(AddressOf
task1.process_i_the_2nd_half)
thread1.Start()
thread2.Start()
thread1.Join()
thread2.Join()
result = task1.resultC
Return result
End Function

Public Class threadmultiply
Dim arrA As Double(,)
Dim arrB As Double(,)
Dim m As Integer
Dim n As Integer
Dim p As Integer
Dim result As Double(,)
Public ReadOnly Property arrayA() As Double(,)
Get
Return arrA
End Get
End Property
Public Sub set_matrixA(ByVal Source_array As Double(,))
m = Source_array.GetLength(0) - 2
p = Source_array.GetLength(1) - 2
ReDim arrA(m + 1, p + 1)
Array.Copy(Source_array, arrayA(), Source_array.Length)
End Sub
Public ReadOnly Property arrayB() As Double(,)
Get
Return arrB
End Get
End Property
Public Sub set_matrixB(ByVal Source_array As Double(,))
p = Source_array.GetLength(0) - 2
n = Source_array.GetLength(1) - 2
ReDim arrB(p + 1, n + 1)
Array.Copy(Source_array, arrayB(), Source_array.Length)
End Sub
Public ReadOnly Property resultC() As Double(,)
Get
Return result
End Get
End Property
Public Sub Dimension_matrixC(ByVal m As Integer, ByVal n As
Integer)
ReDim result(m + 1, n + 1)
End Sub
Public Sub process_i_the_1st_half()
Dim i, j, k As Integer
For i = 1 To CInt(Floor(m / 2))
For k = 1 To p
For j = 1 To n
result(i, j) = arrayA(i, k) * arrayB(k, j) +
result(i, j)
Next
Next
Next
End Sub
Public Sub process_i_the_2nd_half()
Dim i, j, k As Integer
For i = CInt(Floor(m / 2) + 1) To m
For k = 1 To p
For j = 1 To n
result(i, j) = arrayA(i, k) * arrayB(k, j) +
result(i, j)
Next
Next
Next
End Sub
End Class
--
mark b
Nov 21 '05 #1
1 1111
> When I run a given application and monitor its cpu usage with the windows
task manager I see that it uses 50% of the available cpu resources (the
other
50% going to the system idle process).

In an attempt to speed-up the process I split into two threads but still
the
entire process only consumes 50% of cpu resources.

How can I make my application consume a significantly higher percentage of
resources.


You can right-click the process name in the task manager and goto [Set
Priority] -> [High]. WARNING: Do NOT set it to "Realtime" or you deserve
all the evil that falls on you.

You can also place some API calls so that the application can
programmatically set it's priority to high by modifying it's
PROCESS_ATTRIBUTES struct. (I forget what the API function is though)
--
Peace & happy computing,

Mike Labosh, MCSD
"Musha ring dum a doo dum a da!" -- James Hetfield
Nov 21 '05 #2

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

Similar topics

3
by: Torsten Wiebesiek | last post by:
Hi, I am currently working on a computer vision system. At the moment I'm adding support for firewire cameras. Since there is only one firewire system on a computer, I have writen a firewire...
21
by: dub | last post by:
Hello web folks... I've been desigining web pages for 13 years using my trusty text editor (UltraEdit) and in depth knowledge of HTML. I'm truly a text editor ninja at this point. I am frequently...
4
by: cantabile | last post by:
Hi, I have a class (a gui) with buttons and other controls. A button, for example, has a callback method, so that writing b = Button(label, OnClick) will call the global OnClick method. ...
7
by: tgh003 | last post by:
I would be interested to hear how others are managing their javascript (.js) files from the original code vs the obfuscated version they publish to their site/webapp. I currently manage 2 files,...
2
by: fariba123 | last post by:
i have designed an employee information site. there is an option to generate pay slip. how can i show the employee related data based on the drop down list. i have found code example for...
1
by: Screenbert | last post by:
After finding nothing anywhere in google I am posting this so everyone can benefit by it. The formating is not pretty since I copied it from my word document, but you should benefit by it. ...
0
by: screenbert | last post by:
Managing DHCP Servers using C# They said it was impossible. It couldn't be done. But you can in fact manage DHCP servers using C#. This includes creating and deleting Scopes, SuperScopes,...
2
by: james | last post by:
Hi Guys, Would anyone mind recommending some packages for managing changes in databases? I have used Ruby on Rails Migrations, but have not found something similar for .Net. As far as I know...
12
by: helveticus | last post by:
Because of licensing reasons, I plan on using ASP.NET 3.5 /Access 2K for a specific site.. What tools could I use to remotely manage the Access 2K DB? Would a simple ODBC connection be adequate?...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.