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. Interrupt under windows???

Interrupt under windows???

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsgame-devhelp
7 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
    Mr Freeze
    wrote on last edited by
    #1

    Hi, I was wondering if there's something like interrupts in a window application that I can use?? I mean a real interrupt (nothing to do with all the messages an application can get). In my application which is always busy (openGL window which is constantly refreshed) I would like to be able to respond very quickly to some requests coming from another application (which should actualize (read, modify and write) about 100 values in the first application, and this many times a second) How can I solve this problem in an elegant way?? Thanks :)

    T M R 3 Replies Last reply
    0
    • M Mr Freeze

      Hi, I was wondering if there's something like interrupts in a window application that I can use?? I mean a real interrupt (nothing to do with all the messages an application can get). In my application which is always busy (openGL window which is constantly refreshed) I would like to be able to respond very quickly to some requests coming from another application (which should actualize (read, modify and write) about 100 values in the first application, and this many times a second) How can I solve this problem in an elegant way?? Thanks :)

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      Use multiple threads. You can move the rendering code onto separate worker thread, as well as the code which is going to respond to the external requests. How do you communicate with other app? Tomasz Sowinski -- http://www.shooltz.com

      M 1 Reply Last reply
      0
      • M Mr Freeze

        Hi, I was wondering if there's something like interrupts in a window application that I can use?? I mean a real interrupt (nothing to do with all the messages an application can get). In my application which is always busy (openGL window which is constantly refreshed) I would like to be able to respond very quickly to some requests coming from another application (which should actualize (read, modify and write) about 100 values in the first application, and this many times a second) How can I solve this problem in an elegant way?? Thanks :)

        M Offline
        M Offline
        Mike Nordell
        wrote on last edited by
        #3

        In my application which is always busy (openGL window which is constantly refreshed) I'd say this is design error #1. Imagine an infinite fast machine. If you "constantly refreshed" the view (not the window) I'd say you have a bug in your program, since no program needs to update faster than the screen can update. That said, are you really sure you need "interrupts"? Note that e.g. DirectX let you wait for vblank. Also note that current drivers (e.g. NVidia) spin-lock on these, giving no other part of the system a chance to "do its stuff", all to make 3D games look good in benchmarking (i.e. 300 FPS on a screen that still only do 85Hz). /Mike

        M 1 Reply Last reply
        0
        • T Tomasz Sowinski

          Use multiple threads. You can move the rendering code onto separate worker thread, as well as the code which is going to respond to the external requests. How do you communicate with other app? Tomasz Sowinski -- http://www.shooltz.com

          M Offline
          M Offline
          Mr Freeze
          wrote on last edited by
          #4

          Aahhhh, I think I understand now. Please correct me if I'm wrong: An application with only one thread will never interrupt itself in the middle of a portion of code to execute another portion of the application's code. An application with more than one thread can stop in the middle of a portion of code to execute another portion of code from the other threads. Is this right? (of course windows can interrupt an application anytime to continue with another application) So if I do it like you proposed it, I will use a second thread only to respond to other program's requests. I communicate with other applications through a dll with a shared data segment. But I'm trying to use the "Postmessage" command. Thanks for your advice :)

          1 Reply Last reply
          0
          • M Mike Nordell

            In my application which is always busy (openGL window which is constantly refreshed) I'd say this is design error #1. Imagine an infinite fast machine. If you "constantly refreshed" the view (not the window) I'd say you have a bug in your program, since no program needs to update faster than the screen can update. That said, are you really sure you need "interrupts"? Note that e.g. DirectX let you wait for vblank. Also note that current drivers (e.g. NVidia) spin-lock on these, giving no other part of the system a chance to "do its stuff", all to make 3D games look good in benchmarking (i.e. 300 FPS on a screen that still only do 85Hz). /Mike

            M Offline
            M Offline
            Mr Freeze
            wrote on last edited by
            #5

            Ok, I understand. But if I don't have a lot more than 30 different frames per second, I think there's no wast of time. But your're right. It might be ok on my slow computer, but on others there would be a waste of computing time. I know I'm not very good at programming... :(( Thanks:)

            M 1 Reply Last reply
            0
            • M Mr Freeze

              Ok, I understand. But if I don't have a lot more than 30 different frames per second, I think there's no wast of time. But your're right. It might be ok on my slow computer, but on others there would be a waste of computing time. I know I'm not very good at programming... :(( Thanks:)

              M Offline
              M Offline
              Mike Nordell
              wrote on last edited by
              #6

              Ok, I understand. Great! Now on to a possible solution. :-) If you have a batch of 100 variables to update every request (and you have pretty tight time demands) I'd go for mutextes and a memory mapped "file". One mutex signalling to the supplying application "Please provide data", the supplying app writes the data to the mempry mapped section and the signalling the other mutex "Done, go ahead and read the data". Without some _really_ fancy stuff this is AFAIK as fast as you can go using Win32. ++luck /Mike

              1 Reply Last reply
              0
              • M Mr Freeze

                Hi, I was wondering if there's something like interrupts in a window application that I can use?? I mean a real interrupt (nothing to do with all the messages an application can get). In my application which is always busy (openGL window which is constantly refreshed) I would like to be able to respond very quickly to some requests coming from another application (which should actualize (read, modify and write) about 100 values in the first application, and this many times a second) How can I solve this problem in an elegant way?? Thanks :)

                R Offline
                R Offline
                Rassman
                wrote on last edited by
                #7

                'scuse me for interrupting. Its just the 'communications' between your two halves. In the Windows world I may be a naughty boy suggesting this. The thing is that I've been programming unix since the old queen died (god rest his soul) and used to have the same communicate-between-threads-especially-at-speed headaches until I discovered the joys of services. The nature of most of my programs (factory control stuff) is very modular, though not entirely independant. I devised a packet system that all of my programs understand (to varrying degrees depending on their need), I stole a service port number and bounce messages off that. I'm sure you Mr Freeze are able to understand how its done, but for the sake of others let me give a briefing on it. //The packets. These are C structs but you can use classes just as //well, or better, I just have to take into account programs I //wrote //a million years ago and have misplaced the source. struct { UINT StructSize; UINT DataSize; /*Because i use a shared service number I need each program to have an ID. So that others receiving the packets know if this is one there need to listen to.*/ UINT ProgramID; /*even if its the right progam, will I understand it? */ UINT ProgramVersion; /* for real time apps time can be important. BETTERTIME is just a 'union' of mine which holds time in a DWORD format as well as being able to get at the elements in byte form. (usefull for sorting and comparison)*/ BETTERTIME Time; /*Command/Type of information contained. It does not need to be globally understood, though for the sake of future proofing I tend to make it unique across applications. If this message isn't for this thread then we do not get as far as checking this*/ UINT Command; void* Data }; Each program is able to be server or client. It starts by sending a Welcome message. If no one replies then it assumes the role of server. As server it keeps a list of all clients that come online and reflects all messages to all clients. I also added the ability to pass this client information to 'prime' clients so that is a server is lost another can take over without much loss. It can of cause be changed such that a dedicated server is present, but the orriginal point was that I wanted all threads/programs to be able to talk to all others. Also I didn't want to be in a situation where data is not collected because there is no server present. As I said, its my first day on this list and I'm not certain yet what level of information to

                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