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. Can code be given exclusive CPU access in XP?

Can code be given exclusive CPU access in XP?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 4 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.
  • S Offline
    S Offline
    Simon Steel
    wrote on last edited by
    #1

    Hello everyone... Is there a way to give a piece of code exclusive access to the CPU without fear of interruption from Windows? Something similar to a critical section, but across processes -- not just threads. And in user space... not kernel level or anything. If not, I imagine it's for stability reasons... but I figured there'd at least be *something*. Any help would be very appreciated... thanks! - Som (I posted this in the Visual C++ because I'm using C to program this...)

    M R B 3 Replies Last reply
    0
    • S Simon Steel

      Hello everyone... Is there a way to give a piece of code exclusive access to the CPU without fear of interruption from Windows? Something similar to a critical section, but across processes -- not just threads. And in user space... not kernel level or anything. If not, I imagine it's for stability reasons... but I figured there'd at least be *something*. Any help would be very appreciated... thanks! - Som (I posted this in the Visual C++ because I'm using C to program this...)

      M Offline
      M Offline
      mbue
      wrote on last edited by
      #2

      No. Since OS's uses protected mode a program cannot use the processor exclusive (this is not a windows behavior). The function EnterCriticalSection can be used to protect code from reentering in another thread not for exclusive execution on the processor.

      1 Reply Last reply
      0
      • S Simon Steel

        Hello everyone... Is there a way to give a piece of code exclusive access to the CPU without fear of interruption from Windows? Something similar to a critical section, but across processes -- not just threads. And in user space... not kernel level or anything. If not, I imagine it's for stability reasons... but I figured there'd at least be *something*. Any help would be very appreciated... thanks! - Som (I posted this in the Visual C++ because I'm using C to program this...)

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        No.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        1 Reply Last reply
        0
        • S Simon Steel

          Hello everyone... Is there a way to give a piece of code exclusive access to the CPU without fear of interruption from Windows? Something similar to a critical section, but across processes -- not just threads. And in user space... not kernel level or anything. If not, I imagine it's for stability reasons... but I figured there'd at least be *something*. Any help would be very appreciated... thanks! - Som (I posted this in the Visual C++ because I'm using C to program this...)

          B Offline
          B Offline
          BadKarma
          wrote on last edited by
          #4

          Hi, You can try to increase your Thread priority. This sounds like the thing you wanted, but you have to be carefully though, because when doing this you could make the OS instable.

          BOOL SetThreadPriority(
            HANDLE hThread,
            int nPriority
          );
          

          Where hThread is the handle of the thread and nPriority is one of the following values: THREAD_PRIORITY_TIME_CRITICAL THREAD_PRIORITY_HIGHEST THREAD_PRIORITY_ABOVE_NORMAL THREAD_PRIORITY_NORMAL THREAD_PRIORITY_BELOW_NORMAL THREAD_PRIORITY_LOWEST THREAD_PRIORITY_IDLE codito ergo sum

          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