Results 1 to 6 of 6

Thread: thread priority

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Resolved thread priority

    Hello,
    I've been reading a book that has a section about threading. In this section, it discussed how you can set the priority of each thread such that some threads get more processing time that others. The thought occurs... is there a way to tell windows to give an app a higher priority such that it gives the app more attention than it would give to other programs (of normal priority) running at the same time? I'm not talking about multiple threads within an app. I mean have the OS give the VB.NET exe (or any other exe for that matter) a higher priority in the list of all the open programs.
    Thanks.
    Last edited by rickford66; Jun 22nd, 2005 at 08:18 PM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: thread priority

    Sure, make it active. I believe the active program always has a slightly higher priority than any of the others. Other than that, if you think about it, you will realize that there would be a problem with such a thing. If there were global priorities, and two were set at the highest level, what would happen? The OS would have to determine which one would get the highest priority, or else they would both have high priority. In such a situation, there would be a slight incentive for some programs to be labeled as less than the highest priority (but you can do that already by making a lower priority thread), and a great incentive for ALL other programs to be tagged with the highest priority. After all, who would accept a 'normal' priority level for their program knowing that it would perform at a potentially unacceptable level on systems that have 'high' priority apps running?

    Basically, you are at the highest priority unless you say otherwise, because that is how it would end up. Having said that, there are other things you can do, like grab exclusive control of the display (which renders all other GUI driven programs automatically lower priority), and there are system processes that are at a higher priority.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Re: thread priority

    Hmmm.... I guess that is logical. In the book I have, there is a window that it says you can pull up (I haven't tried it yet) that shows all the apps/threads currently running and most of them showed a priority level of normal. I think there was only 2 or 3 that had a high priority. As for the OS determining which has highest, I don't know much about that. I'm new to this stuff, but I did do some programming a number of years ago in which I set priorities in a custom C environment. I could set as many high as I wanted and as many low as I wanted. The way it worked is that it would go through all the high priority items, then execute a low priority item, then through all the high priority items, then a low... and so on. I wondered if Windows did something similar... but I am learning so it's nice to have you folks out there to answer questions like this.
    Thanks.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: thread priority [resolved]

    You can always set the priority of the CurrentThread in a single threaded app, although I agree whole-heartedly that you should not set your app to run at anything above Normal priority without very good reason. I have written a few single-purpose utilities recently that take hours to complete their tasks. I have actually set their CurrentThread priority to BelowNormal for the period of the task so that the machine on which they were running would remain responsive to the user. Have you ever been using a machine when the virus scanner kicks in and everything you do has a delay? Annoying, right?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2005
    Posts
    530

    Re: thread priority

    I frequently work with data acquisition. I have an app running that reads data in from the USB and on some slower cumputers, the buffer will overflow. I was wondering if anyone has any feel for how setting the priority to above normal will affect the system responsiveness. It doesn't have to respond quickly as if nothing else is running, but the user should still be able to use it. That is, they should still be able to click the buttons that start and stop acquisition. I can try it, but it will be at least 2 weeks before I can. I don't want to set it so high that it crashes the computer either. Anyone have a feel for this?
    Thanks.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: thread priority

    I can't speak for your particular situation, but those utilities I mentioned would retrieve relatively large amounts of data and/or automate an instance of Excel. I found that, even with them running at Normal priority, the machine was useable but extremely frustrating. I'd have to think that if their priority had been higher I would have had great difficulty accomplishing anything else at the same time. On a slower computer, my guess is that prioritising your app would make the machine unuseable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width