Multi-threading and minimizing underutilization of the processor

Posted on 2005-03-01
Medium Priority
Last Modified: 2010-04-16
I'm about to add a second thread to my Windows app. in order to process larger jobs in the background, while providing instant user interface response time in the GUI.  But I'd like to have a maximal amount of processor cycles available to work on that larger job, to bring it to completion sooner rather than later.

My question is, can I allocate 80% (or so) or the processor's time to the larger process, since most of the time spent waiting for user interactions will be time lost?  Or does the ratio come implicitly by design?

I'd love to hear your reply.

Question by:ba272
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Accepted Solution

Thandava Vallepalli earned 2000 total points
ID: 13436202
You can't specify in ratio or percentrage.  But you can specify as thread prority as below.

       Thread threadOne = new Thread(startDelegate);
        threadTwo.Priority = ThreadPriority.Highest;

The Thread can be scheduled before threads with any other priority.

The Thread can be scheduled after threads with Highest priority and before those with Normal priority.

The Thread can be scheduled after threads with Normal priority and before those with Lowest priority.

The Thread can be scheduled after threads with any other priority.

The Thread can be scheduled after threads with AboveNormal priority and before those with BelowNormal priority. Threads have Normal priority by default.

ThreadPriority defines the set of all possible values for a thread priority. Thread priorities specify the relative priority of one thread versus another.

Every thread has an assigned priority. Threads created within the runtime are initially assigned the Normal priority, while threads created outside the runtime retain their previous priority when they enter the runtime. You can get and set the priority of a thread by accessing its Priority property.

Threads are scheduled for execution based on their priority. The scheduling algorithm used to determine the order of thread execution varies with each operating system. The operating system can also adjust the thread priority dynamically as the user interface's focus is moved between the foreground and the background.

The priority of a thread does not affect the thread's state; the state of the thread must be Running before the operating system can schedule it.


Author Comment

ID: 13436235
Thanks for the input.  But what priority would the user interface get?  If a thread with infinite amount of work has a higher priority, what is it that eventually gives the control to a lower priority thread.  Relative accrued wait time?


Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question