Dobi Posted November 21, 2012 Report Share Posted November 21, 2012 Hi,on different multicore PCs (I do not have this effect on single core machines.) Windows XP 32 bit (SP3) here behaves as follows:I run a small programm (like this in C++ for example) occupying the CPU and printing the time for one calculation step:#include <chrono>#include <iostream>#include <vector>void WasteTime(){std::vector<int> vec( 16777216, 42 );for ( int i( 0 ); i < 8; ++i ) for ( auto it( vec.begin() ); it != vec.end(); ++it ) *it = (*it + 13)/2;}int main( int argc, char* argv[] ){for (;;){ auto start(std::chrono::system_clock::now()); WasteTime(); auto end(std::chrono::system_clock::now()); int elapsed_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); std::cout << "elapsed time in ms: " << elapsed_milliseconds << "\n";}return 0;}Output:elapsed time in ms: 187elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 156elapsed time in ms: 156elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 156elapsed time in ms: 156elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 156elapsed time in ms: 171elapsed time in ms: 171But if I play sounds in between, e.g. with clicking here ( http://daiw.de/share/PlaySound.jpg ), my program sometimes is put to sleep for 500ms:elapsed time in ms: 171elapsed time in ms: 156elapsed time in ms: 156elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 656elapsed time in ms: 171elapsed time in ms: 171elapsed time in ms: 156elapsed time in ms: 656elapsed time in ms: 171elapsed time in ms: 656elapsed time in ms: 156elapsed time in ms: 171elapsed time in ms: 171The ugly lines (six hundred something) occur frequently when I hit the play button in a rapid succession.Do you know this phenomenon of even its cause? If you have a XP PC there, could you check if your machine behaves the same way? Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 22, 2012 Report Share Posted November 22, 2012 Hi. Welcome. on different multicore PCs (I do not have this effect on single core machines.) Windows XP 32 bit (SP3) That part is quite enough. The rest of the post makes my head go around like a windmill.If it doesn't happen on single core, you need to change the processor affinity for which ever program you are using I would think. It may of course not be that simple, but it is the only thing that comes to mind in the early hours of the morning when faced with a page of code that obviously is of interest to you, - but not me. "Older applications that were designed for single-core processors can behave irrationally — they may all of a sudden begin maxing out the CPU usage at 100 percent and appear to be locked up. In other circumstances, you might be able to achieve better overall performance from certain applications by configuring each of them to run on different processor cores."Mark Russinovich's "PsExec" is able to set processor affinity on Windows XP.Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i[session]][-c [-f|-v]][-w directory][-d][-][-a n,n,...] cmd [arguments]-a Separate processors on which the application can run withcommas where 1 is the lowest numbered CPU. For example,to run the application on CPU 2 and CPU 4, enter:"-a 2,4"Download it here: http://technet.micro...s/bb897553.aspxJohn. Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 22, 2012 Author Report Share Posted November 22, 2012 Hi John,thanks for your reply.Changing the CPU affinity of my program to arbitrary cores (you can also do this via the task manager) did not make any difference.The code I posted is of no interest to me. It is just a quickly written example for making it easier to confirm my observation. The same effect is visible with other programs and different compilers.In my test scenario I do not have many single core applicatations running at the same time. It is just this one loop calculating stuff. The other 3 cores have nothing to do, but as soon as I play a Windows sound (e.g. via the sound setting in the control panel), the app sleeps for 500ms.If somebody wants to try to reproduce this effect, and wants to use my test-app but can not compile it, here is a link to the executable: http://daiw.de/share...lationTimes.zip Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 23, 2012 Report Share Posted November 23, 2012 O.K. I think I get your point. So your requirement now is to do as you suggest ? - And we Just sit back and see if someone understands your problem, and needs to reproduce this effect and confirm your observations.What sort of need would arise that anyone should want to do that ?I would think that the average reader / poster would be wondering why a 500ms delay would ever be a problem in their lives, and are probably wondering why it is a problem in yours.If I explained that when I hit a key on my Yamaha Piano used to control a VSTi plugin via MIDI and that there was a delay of 500ms (i.e Latency) I think people would soon see that if - " I strike a key on an electronic piano, and the sound coming out of the speakers is delayed." - There is a problem !In my explanation I have given both verbal information, and information on which they can visualise. ( Piano, Keys, Keyboard, Speakers)I have given, and coloured what I am trying to explain by means of a framework of that which I am trying to explain. This is known as putting things into - "Context"I would then be able to go on explain the effects of latency in a MidI / Audio situations, and go on to suggest http://tippach.busin...4all/intro.html "ASIO4ALL""ASIO4ALL is a hardware independent low latency ASIO driver for WDM audio devices. It uses WDM Kernel-Streaming and sometimes even more sophisticated methods to achieve its objectives."I personally use ASIO, - it works. - End of that particular story .I think that the lack of respondents to your posts may be due to them being unable to find any context to which they can relate, understand, or visualise.Would ASIO4ALL be of any use to you to use in curing your audio 500ms delay ? .Also there is a "FREE" DPC Latency checker that will work with XP and a lot of other Windows operating systems. "Thesycon’s DPC Latency Checker is a Windows tool that analyses the capabilities of a computer system to handle real-time data streams properly.may help to find the cause for in Interruptions in real-time audio and video streams, also known as drop-outs. The program supports Windows 7, Windows 7 x64, Windows Vista, Windows Vista x64, Windows Server 2003, Windows Server 2003 x64, Windows XP, Windows XP x64, Windows 2000."You can download that here: http://www.thesycon....ncy_check.shtmlWhy do you wish for your observations to be confirmed when you have plenty of software avaiable to confirm things for yourself ?I would describe what you are naming "Sleep", as a "Dropout" within or after 500ms. With the latency checker you will be able to prove this and find the cause.I am aware that you can change program- to- processor affinity from Task Manager, as are most people. Mark Russinovich wrote something that will do all that, and a little bit more. In all fairness you and people other than yourself may have been interested in that fact.People may now know a little bit more about audio latency, Asio drivers, latency measurement, and a few other things to their advantage. Many I would think will be scratching their heads having never felt the need to play "Windows Sounds" in the middle of running an application.Thanks for the post. Everyday is a learning day. Hopefully the links I've given will be useful.If not we will just have to wait until someone confirms your observations,John. Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 25, 2012 Report Share Posted November 25, 2012 Anyone out there still running XP who would care to confirm Dobi's observations ? Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 26, 2012 Author Report Share Posted November 26, 2012 Sorry that I did not make clear, why this is important to me. I wanted to reduce my problem to a minimum example, so that people can understand and recreate it easily. And I wanted to keep my post as short as possible to not get tldr responses. ;)Ok, so my problem is, that I am developing an object recognition software, that gets a camera image and has to produce a recognition result in about 300ms to 400ms. In general this works fine, but if some other application running on the same system plays sounds during this process, this lets my software freeze for 500ms (as mentioned only on XP multicore systems), and the recognition result comes too late for what has to be done afterwards.I was hoping someone will try to reproduce this, because it could be possible that I am making a simple mistake in the windows/drivers configuration or that this effect just occurs on my hardware. (All PCs I use for testing Fujitsu models.) So I was hoping to find out, where this problem come from, so I can possibly find a better solution than to just disable the sounds of the other applications (all come from my company). Why do these sometimes play sounds, you ask? Because they want to signalize special conditions about the processed object image acoustically.Besides this, the problem should be very easy to reproduce (or not) in just a minute or so, and I thought perhaps somebody would invest this minute just to help me or out or out of curiosity.I do not see how the Latency Checker tool is related to my problem. I do not deal with real time audio or video streams and the problem in my case is not that the playing of the sound is somewhat delayed.But I tried it anyway. It says "This machine should be able to handle real-time streaming of audio and/or video data without drop-outs." and the absolute maximum latency is only 12 microseconds, which I find surprisingly low. Its 117 microseconds on my Windows 7 PC. Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 26, 2012 Report Share Posted November 26, 2012 RESTRUCTURED POST ON BEHALF OF DOBI.I am developing an object recognition software, that gets a camera image and has to produce a recognition result in about 300ms to 400ms. In general this works fine, but if some other application that is running on the same system plays sounds during this process, this lets my software freeze for 500ms and the recognition result comes too late for what has to be done afterwards.I am hoping someone will try to reproduce this fault for me, because it could be possible that I am making a simple mistake in the windows/drivers configuration or that this effect just occurs on my hardware. If you have a XP PC there, could you check if your machine behaves the same way please ? (This effect does not show up on single core machines. - I am both running and developing this software on Windows XP 32 bit (SP3)It is necessary for sound to work for, and with this particular software, so turning off the sound in any way is not an option.If somebody wants to try to reproduce this effect, and wants to use my test-app but cannot compile it, here is a link to the executable: http://daiw.de/share...lationTimes.zip (Malware / Virus checked before posting.)( I have just realised that there is no help file or information with this application so will re-post as soon as possible, therefore giving you full knowledge of the product and it's associated uses.)Many thanks in advance for any help or ideas supplied.Dobi. Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 26, 2012 Author Report Share Posted November 26, 2012 The feeling, that you just want to nettle me, is rising in me, but OK, I play along. :)I do not have the impression that my posts are written so confusing, that you have to rearrange them in order to make them understandable, but obviously this is the case nevertheless. Perhaps the reason is, that I am not a native speaker, but I give my best to write clean. I am sorry if I am not always successful in doing so.The zip file I uploaded, is not updated with a readme.txt describing the programm briefly.Why all these details are important to you is still some kind of mystery to me, but I guess you are trying to teach me something according to the scheme you are describing in your signature twice. I hope you also have the willingness to learn, that you seem to demand from others. ;)btw:- I am not developing my object recognition software on Windows XP as you wrote. XP is just one of the target platforms.- Turning off the sound is an option (in contrast to what you wrote), it' just not the most elegant one. But at the moment I am doing exactly this.- I did not write "Many thanks in advance" because of the connotation mentioned in How To Ask Questions The Smart Way by Eric Steven Raymond. So:Thanks for your attention. Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 27, 2012 Report Share Posted November 27, 2012 Dobi, I did think that you were perhaps not a native speaker from some of www. addresses quoted in your posts. I re-wrote your post not to be pedantic but to put into context your problem, and make it more understandable to myself and others. Dobi: - Why all these details are important to you is still some kind of mystery to me. Obviously all details, and as much information as possible is necessary to the reader if you really wish to get answers.The zipped file. - You will find that most people are reluctant to open up executable files such as you posted without some sort of prior knowledge of what to expect.In previous posts you have mentioned your other applications, and you also mention your company. As a company owner I should have thought the dangers of opening unknown applications of this sort this was apparent, and hopefully a lesson in "Safe Computer Usage" that you would have passed on to your clients.I did open your application in a virtual machine (VM) but have to say that it led me no closer to any sort of understanding of your problem.No I was not trying to teach. Merely pointing out that if you wished anyone to "Confirm your observations" they would be a little less reluctant to open an executable if perhaps you had included a help file. (Something you have still not done !) So. - Still we have no knowledge of the product and it's associated uses.Dobi: - I am not developing my object recognition software on Windows XP as you wrote.Windows XP may well be just one of the target programs for which you develop, but the heading for your post in the first instance is: XP sleeps 500ms when calling PlaySound()?Throughout subsequent posts you have not made any reference or tried to correct the fact other than that you are developing on this platform only.Turning off the sound is an option (in contrast to what you wrote), it' just not the most elegant one.Elegant or not, turning off the sound is not an option for the finished product because " they (sounds) want to signalize special conditions about the processed object image acoustically."Dobi: - but OK, I play along. :)This is not a game. You posted previously on the cplusplus forum and got only one answer.( Your post. Your reference: http://www.cplusplus.../windows/85404/ )You have received a lot of genuine help on this particular forum (Windows Forum)I would suggest that the best way forward for you now is by using "Dependency Walker" and maybe doing so quietly and as a task on your own. In this way you may discover whether it is a coding error, or an operating system error."To use Dependency Walker (Depends) to investigate errors, use this procedure:Start Dependency Walker version 2.2.Click Open on the File menu to load the problem file into Dependency Walker.Next, on the View menu, click Start profiling. The Profile Module dialogue box appears.Type any switches and/or program arguments you want into the Program Argument window.Make sure that you have selected all other options that you want, and then click OK.""This profiles your application, listing modules loaded and files used. Dependency Walker injects Dwinject.dll just before the application error occurs. The resulting log will document exactly what the application was doing at the time of the error."You can Download Dependency Walker here: http://majorgeeks.co...alker_d227.html Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 27, 2012 Author Report Share Posted November 27, 2012 Is is not obvious to me why all details and as much information as possible is necessary to the reader. I think the fact, that I encoutered the problem while developing an object recognition software is not of importance, because the problem is a more general one. The sceduler of operating system running on a multicore CPU should not put single applications to sleep just because some other app plays a sound.Imagine you are playing, lets say an ego shooter, online and have your messenger software running in the background. Every time someone sends you a message it says *pling* or something and your game always freezes for half a second then. I guess you would be quite annoyed, and if you would open a thread in the forum with your problem I would be happy if you had reduced your problem to something general and easy to reproduce and test, so that I did not have to bother with what version of Game or Messenger or whatever you are running.I know that opening an executable is risky and thus not done gladly. That is why I posted the source code for self compilaton only in the first place.Regarding you asking for the help file again: What is wrong with the readme.txt I added yesterday to the zip file directly after you suggested it? You could just have downloaded the zip file again and you would have seen the new text file. If you tried this and did not see a readme.txt in the zip, the cache of your browser/downloader perhaps gave you the old version again. But to make it easier, here is the context of the readme.txt again: http://shorttext.com/p1XCoNBqTurning of the sound *is* an option, because the acoustic signals are not that important and can be abandoned of necessary.Up to now I did not receive help with my problem here, just with formulating it in a way that you think is better. Nevertheless I appreciate the time you are spending with this, even though we seem to misunderstand each other in some points, and thus progressing quite slowly.I do not see why the other target platforms or my developement platform are important. The problem is XP only and has nothing to do with my object recognition software, because it can be reproduced with just the small independant test programm as well.The fact that you recommend dependendy walker shows to me, that you have not understood my problem at all yet. I will try to explain it better: There is no error I have to trace. On the PCs I have here, I can run any simple program that does something trivial. The Windows sceduler will not give CPU time slices to the program for 500ms when Windows has to play a simple sound, while this program is running.I included an example program and a screenshot to a way to play sounds. Here a more detailed fomulated manual of how to try to reproduce my observation:1) run PrintCalculationTimes.exe (It can be downloaded here: http://daiw.de/share...lationTimes.zip)2) see how it outputs times like for example 187, 171, 156 etc. into the console window.3) play windows sounds via your sound settings dialog in the windows control panel (like so: http://daiw.de/share/PlaySound.jpg)4) see if the output times of the test programm changed while doing this. Did they stay at 187,, 171, 156 etc, or did they change to something like 187, 656, 156?5) If some of them increased by roughly 500 you have reproduced my problem. If they did not, your machine seems to not have the problem. Quote Link to comment Share on other sites More sharing options...
MANEMAN Posted November 27, 2012 Report Share Posted November 27, 2012 Dobi: Up to now I did not receive help with my problem here, just with formulating it in a way that you think is better. The main area of help that you have received here apart from the posts and suggestions I have made, is of course the fact that I have kept your post alive and at the top of "The Playlist" here on the forum, therefore giving a greater chance of someone seeing your post and answering it. A pleasantry I have noticed that was denied to you over at the CPLUSPLUS FORUM:(http://www.cplusplus.../windows/85404/)There was no intent at "Better" - Just helpful.Since you have written your appreciation, for which I thank you, but you very obviously think that my efforts have been of no help, and that we are "progressing quite slowly," It would be prudent for me at this stage to step aside for our mutual benefit, - and, whilst your post is still at the top of the list, let someone else who is at your level of expertise take over with answers.Good luck with your quest Dobi.John. .=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.=.Just a quick reminder to anyone reading, of the other things we all may have had a chance to learn about in this thread so far.Setting Processor Affinity - Another way of doing it: http://technet.micro...s/bb897553.aspxA hardware independent low latency driver for WDM audio devices: http://tippach.busin...4all/intro.htmlA Windows tool that analyses the capabilities of a computer system to handle real-time data streams properly:http://www.thesycon....ncy_check.shtmlA free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules:http://majorgeeks.co...alker_d227.html Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 27, 2012 Author Report Share Posted November 27, 2012 Just out of curiosity: Have you understood what my problem is in the meantime with my last explanation? If this is not the case, I perhaps can not expect many others to get my point either. Quote Link to comment Share on other sites More sharing options...
Dobi Posted November 28, 2012 Author Report Share Posted November 28, 2012 Sorry for double posting, but the forum does not allow me to edit my post that late after creating it.I made two screenshots to show the problem visually:http://daiw.de/share...ithoutSound.pnghttp://daiw.de/share...Annotations.pngI now also see, that is was not the smartest thing of me to post a C++ source code in a non programmer Windows forum. I did not mean to crosspost in the first place (I just got no answer in the other forum, so i tried it here.), but it was not correct to just copy my post, that was originally created for the C++ forum. I apologize for that and for being a straining conversation partner.Now I am trying my luck here ( http://social.techne...fa-d967d82d5529 ) with a hopefully easier to understand formulation of my problem. ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.