Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to achive application load balancing in win32 application

How to achive application load balancing in win32 application

Scheduled Pinned Locked Moved C / C++ / MFC
questiondesigntutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hemant kulkarni
    wrote on last edited by
    #1

    Hi, My application is having two threads. One is UI thread doing all UI operations. The another thread is doing some heavy work like writing to disk. How I can achive that only when the system have a light load then only the disk writer thread will run and in heavy load cases it will not schedule or scheduled for very low time? How can I know that when system is not heavily loaded and when it is heavily loaded? Is the "Load Balancing" word correct here or it is misleading? Regards, Hemant.

    S 1 Reply Last reply
    0
    • H Hemant kulkarni

      Hi, My application is having two threads. One is UI thread doing all UI operations. The another thread is doing some heavy work like writing to disk. How I can achive that only when the system have a light load then only the disk writer thread will run and in heavy load cases it will not schedule or scheduled for very low time? How can I know that when system is not heavily loaded and when it is heavily loaded? Is the "Load Balancing" word correct here or it is misleading? Regards, Hemant.

      S Offline
      S Offline
      Scott Holt
      wrote on last edited by
      #2

      I don't know that you can perform load-balancing as directly as you want to. However, the Windows API offers the 'CreateThread()' and 'SetThreadPriority()' functions, which allow you to create a thread and set its priority. For example, we can create a thread and set its priority to LOW, in which case the operating system will AUTOMATICALLY schedule the thread for execution in such a way that other, higher priority threads will receive more CPU cycles. This is probably the best way to handle this anyway, as the operating system can allocate CPU cycles more efficiently that you could. In your example, the disk writer thread would be given a low priority. As other tasks are invoked, such as user interface actions, Windows will automatically suspend the desk writer thread and give priority to the user interface. Check out the documentation on 'CreateThread()' and 'setThreadPriority()' for a better description. Scott

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups