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. RealTime Priority?

RealTime Priority?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
10 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.
  • M Offline
    M Offline
    Manikandan
    wrote on last edited by
    #1

    I wanna set real time priority to my application. At first a loader program runs myapp. Then I want to get the process id using exe name. With exe name i must be able to set its priority to REALTIME. My concept may sound correct but i dont know how to program it. Anybody can help me;P

    A A G 3 Replies Last reply
    0
    • M Manikandan

      I wanna set real time priority to my application. At first a loader program runs myapp. Then I want to get the process id using exe name. With exe name i must be able to set its priority to REALTIME. My concept may sound correct but i dont know how to program it. Anybody can help me;P

      A Offline
      A Offline
      Arsalan Malik
      wrote on last edited by
      #2

      SetThreadPriority(...)[^]:)  ARSALAN MALIK

      1 Reply Last reply
      0
      • M Manikandan

        I wanna set real time priority to my application. At first a loader program runs myapp. Then I want to get the process id using exe name. With exe name i must be able to set its priority to REALTIME. My concept may sound correct but i dont know how to program it. Anybody can help me;P

        A Offline
        A Offline
        Antony M Kancidrowski
        wrote on last edited by
        #3

        If you have control over the loader program you can use CreateProcess() to launch your application and use REALTIME_PRIORITY_CLASS in the creation flag. Otherwise use SetPriorityClass()within your application to REALTIME_PRIORITY_CLASS - this will ensure that your application runs at Realtime priority always. I would be carefull when creating programs that run at realtime as they *will* hog the processor and you can easily prevent other applications from responding. Ant. I'm hard, yet soft.
        I'm coloured, yet clear.
        I'm fruity and sweet.
        I'm jelly, what am I? Muse on it further, I shall return!
        - David Williams (Little Britain)

        M 1 Reply Last reply
        0
        • A Antony M Kancidrowski

          If you have control over the loader program you can use CreateProcess() to launch your application and use REALTIME_PRIORITY_CLASS in the creation flag. Otherwise use SetPriorityClass()within your application to REALTIME_PRIORITY_CLASS - this will ensure that your application runs at Realtime priority always. I would be carefull when creating programs that run at realtime as they *will* hog the processor and you can easily prevent other applications from responding. Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Williams (Little Britain)

          M Offline
          M Offline
          Manikandan
          wrote on last edited by
          #4

          I tried...but it doesn't work. I am in VC6. Does this stuffs work under VC6? In the loader program i am using the below code, STARTUPINFO suInfo; PROCESS_INFORMATION procInfo; CString m_Process; m_Process.Format(_T("%s\\my.exe"),curDir); memset (&suInfo, 0, sizeof(suInfo)); suInfo.cb = sizeof(suInfo); ::CreateProcess(m_Process, NULL, // can also be NULL NULL, NULL, FALSE, REALTIME_PRIORITY_CLASS, NULL, NULL, &suInfo, &procInfo); if (procInfo.dwThreadId == NULL) { AfxMessageBox("nope"); } else { ::SetThreadPriority(&procInfo.dwThreadId,THREAD_PRIORITY_HIGHEST); } When I check in process viewer the class priority is "Very High", the thread priority remain "normal". Also when a thread runs in "my.exe" it's not given the highest priorities, i am free to access other programs.

          A 1 Reply Last reply
          0
          • M Manikandan

            I tried...but it doesn't work. I am in VC6. Does this stuffs work under VC6? In the loader program i am using the below code, STARTUPINFO suInfo; PROCESS_INFORMATION procInfo; CString m_Process; m_Process.Format(_T("%s\\my.exe"),curDir); memset (&suInfo, 0, sizeof(suInfo)); suInfo.cb = sizeof(suInfo); ::CreateProcess(m_Process, NULL, // can also be NULL NULL, NULL, FALSE, REALTIME_PRIORITY_CLASS, NULL, NULL, &suInfo, &procInfo); if (procInfo.dwThreadId == NULL) { AfxMessageBox("nope"); } else { ::SetThreadPriority(&procInfo.dwThreadId,THREAD_PRIORITY_HIGHEST); } When I check in process viewer the class priority is "Very High", the thread priority remain "normal". Also when a thread runs in "my.exe" it's not given the highest priorities, i am free to access other programs.

            A Offline
            A Offline
            Antony M Kancidrowski
            wrote on last edited by
            #5

            Manikandan wrote: i am free to access other programs You will always be able to access other programs even with Realtime priority set. NOTE: Running under windows you can not set the application to have exclusive use of the processor. I am puzzled, why would you want to do this? Ant. I'm hard, yet soft.
            I'm coloured, yet clear.
            I'm fruity and sweet.
            I'm jelly, what am I? Muse on it further, I shall return!
            - David Williams (Little Britain)

            M 1 Reply Last reply
            0
            • A Antony M Kancidrowski

              Manikandan wrote: i am free to access other programs You will always be able to access other programs even with Realtime priority set. NOTE: Running under windows you can not set the application to have exclusive use of the processor. I am puzzled, why would you want to do this? Ant. I'm hard, yet soft.
              I'm coloured, yet clear.
              I'm fruity and sweet.
              I'm jelly, what am I? Muse on it further, I shall return!
              - David Williams (Little Britain)

              M Offline
              M Offline
              Manikandan
              wrote on last edited by
              #6

              Hi Ant, my application is time sensitive. even mouse move will affect its normal operation. This is why i have to suspend other programs when my exe run a thread. Actually i found a standalone program in the net that list out all the running programs (I give you the link asap). When i set the priority to real time (24). I found my program running fine while i cant even access the mouse. But i want to do this programmatically.

              A 1 Reply Last reply
              0
              • M Manikandan

                Hi Ant, my application is time sensitive. even mouse move will affect its normal operation. This is why i have to suspend other programs when my exe run a thread. Actually i found a standalone program in the net that list out all the running programs (I give you the link asap). When i set the priority to real time (24). I found my program running fine while i cant even access the mouse. But i want to do this programmatically.

                A Offline
                A Offline
                Antony M Kancidrowski
                wrote on last edited by
                #7

                Manikandan wrote: But i want to do this programmatically I would have thought that my suggested launching would have worked. If I think of anything else you could try I will let you know. Ant. I'm hard, yet soft.
                I'm coloured, yet clear.
                I'm fruity and sweet.
                I'm jelly, what am I? Muse on it further, I shall return!
                - David Williams (Little Britain)

                1 Reply Last reply
                0
                • M Manikandan

                  I wanna set real time priority to my application. At first a loader program runs myapp. Then I want to get the process id using exe name. With exe name i must be able to set its priority to REALTIME. My concept may sound correct but i dont know how to program it. Anybody can help me;P

                  G Offline
                  G Offline
                  geo_m
                  wrote on last edited by
                  #8

                  Well, just a notice - Windows are not realtime OS, if you really need the RT features (for RT controlling a device or something like that) you better to go by some specialized RT OS or get some RT plugin for NT that replaces the standard scheduler. Even if you set the process realtime priority and thread realtime priority the time scheduler can interrupt your process and will do it usually in the worsest possible time.

                  M 1 Reply Last reply
                  0
                  • G geo_m

                    Well, just a notice - Windows are not realtime OS, if you really need the RT features (for RT controlling a device or something like that) you better to go by some specialized RT OS or get some RT plugin for NT that replaces the standard scheduler. Even if you set the process realtime priority and thread realtime priority the time scheduler can interrupt your process and will do it usually in the worsest possible time.

                    M Offline
                    M Offline
                    Manikandan
                    wrote on last edited by
                    #9

                    hi thanks for you idea, i did a google search with the string "Real Time plug in for NT" but i couldn't come across any windows compatible plug in's. would you please refer me one :rolleyes:

                    G 1 Reply Last reply
                    0
                    • M Manikandan

                      hi thanks for you idea, i did a google search with the string "Real Time plug in for NT" but i couldn't come across any windows compatible plug in's. would you please refer me one :rolleyes:

                      G Offline
                      G Offline
                      geo_m
                      wrote on last edited by
                      #10

                      just googled for "RealTime NT" and got some results

                      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