multithreading question

I drive my game's physics engine using a simple loop running on its own 
thread. It invokes Thread.Sleep(1)  when processing takes little or no time 
(under 4ms) to allow real time to catch up. For heavier loads the loop uses 
bigger timeslices, up to 20ms, with no sleeps.

Since this is a multithreaded application, I decided to break out CHESS to 
test the object (render) buffer for problems. But CHESS hates 
Thread.Sleep() - it fails any test that hits one, calls it a livelock.

I ended up switching out the original realtime loop with a high resolution 
multimedia timer, but I don't feel like it was a design improvement. I know 
sleeping threads should generally be avoided, but what about in games? Using 
a timer seems more... clumsy.

Paul 


0
PJ6
11/29/2009 12:28:02 AM
dotnet.languages.vb 830 articles. 0 followers. Follow

1 Replies
848 Views

Similar Articles

[PageSpeed] 58

Never mind, dumb question. I needed to pump the engine directly from a 
thread created in the test. The holistic test was cool but not what I 
needed.

"PJ6" <noone@nowhere.net> wrote in message 
news:%23mS2VrIcKHA.1592@TK2MSFTNGP06.phx.gbl...
>I drive my game's physics engine using a simple loop running on its own 
>thread. It invokes Thread.Sleep(1)  when processing takes little or no time 
>(under 4ms) to allow real time to catch up. For heavier loads the loop uses 
>bigger timeslices, up to 20ms, with no sleeps.
>
> Since this is a multithreaded application, I decided to break out CHESS to 
> test the object (render) buffer for problems. But CHESS hates 
> Thread.Sleep() - it fails any test that hits one, calls it a livelock.
>
> I ended up switching out the original realtime loop with a high resolution 
> multimedia timer, but I don't feel like it was a design improvement. I 
> know sleeping threads should generally be avoided, but what about in 
> games? Using a timer seems more... clumsy.
>
> Paul
> 


0
PJ6
11/29/2009 3:06:33 PM
Reply:

Similar Artilces:

Outlook Connector question
I'm using this with Outlook 2007; is there any way to get new messages to show up in Unread Mail instead of just in the email address's Inbox? Thanks, John No, not with the other unreads in your mailbox. You can have a search folder for the msn inbox though. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Outlook Tips: http://www.outlook-tips.net/ Out...

Question about menu's.
Hi, I am currently subclassing the main window of the MSN messenger (7 beta). I have added a menuitem to the contextmenu, however I do not get a WM_COMMAND for my added menu item. There are several menuitems that do generate a WM_COMMAND message but some of them don't. For instance: 'Send an instant message' generates a WM_COMMAND message and 'Block' does not. Can anybody tell me what the difference is between these two menuitems that reside in the samen popupmenu, it's a complete mistery to me. I can also Create a complete new menu, but it would be best to ext...

A MultiThreading problem with mfc SendMessage
Hi, i have done my own video player which support lot's of video format.....throught direct show or own source code.... but i have a small problem with a SendMessage... User can perform 3 actions Play, Pause and Stop..... * Play launch a thread and an SetEvent(E_PAUSE) to release it because thread loop begin with a WaitForMultipleObject of E_PAUSE or E_KILL * Pause ResetEvent(E_PAUSE) * Stop ResetEvent(E_PAUSE) and SetEvent(E_KILL) and wait for Thread Terminaison throught a WaitForSingleObject of E_END The thread could be describe as : do { WaitForMultipleObject of E_PAUSE or E_KILL ...

WEEKNUM() Question
The results of WEEKNUM() don't correspond with the calendaring system I want. My first question is simple: How does the WEEKNUM() algorithm work? If I can figure out what it's based on, I can probably match it to the calendar I'm using. It looks like it's anywhere from 1 day off to 2 days off from my calendar, depending on when my week decides to start. The calendar I have starts on Mondays and assigns WEEK-1 to the first week of January with at least 4 days in it. So if WEEKDAY(DATE(YEAR,1,1),2) is 5 (Friday) or greater, then the week doesn't start until WEEKDAY() y...

Outlook 2003 Attachments Question
Good Morning, I'm having a problem in Outlook 2003. When I have the reading pane open I am able to double click on an attachment and it opens normally. If I double click on the email and have it open, THEN try to open the attachment it tells me it cannot find the program associated with this attachment. Another problem is this: If I am in Word and go to File-Send to-EMail recipient as Attachment. It cannot find Outlook to send the message. However I am able to open Outlook and attach the file to a new email and send it. Any help would be greatly appriciated. Thank you! ~Michael ...

Quick Question #3
I have a workbook that is basically made up of 2 worksheets, a importing data sheet and a chart. Everything works great, timely refreshes and its rather simple. The problem I have is this: The chart is basically a seating chart and does not change at all(static). The 2nd worksheet continuosly updates the chart and will sometimes add new values(dynamic). Well, my formulas that I have for each cell points to the dynamic sheet and the values will change on occasion, unpredictablely. How can I write the formulas pointing to certain values in the data sheet(dynamic) and lock the cells. Then any ne...

SendMessage Question/Problem
I have a dialog box with a toolbar subclassed in it that has a combo box. I have embedded the toolbar in a static control on the dialog box. When an item in the combo box is selected, I am getting the OnSelChange message being triggered in the subclassed tool bar class. I then get the item that was selected and call GetOwner()->SendMessage(WM_NOTIFY......) In the dialog box I have a ON_NOTIFY message command for the IDR_TOOLBAR. when I debug the OnSelChange method in the subclassed toolbar class, I can see it setting up the call, but when I place my cursor and do run to cursor in the O...

easy OnLButtonDblClk() question
Hi, I've created a MFC application. It has the standard window where information is displayed. I have recently copied some code from another applcation someone made for me, so that I have a dockable window that attaches to the main document. The code for this class it as follows: class CMarkerZoom : public CWnd { // Construction public: CMarkerZoom(); // Overrides // ClassWizard generated virtual function overrides file://{{AFX_VIRTUAL(CMarkerZoom) file://}}AFX_VIRTUAL // Implementation public: virtual ~CMarkerZoom(); // Generated message map functions protected: file://{{AFX_...

Excel question #11
How do I lock a row of cells so that anything I type in them will be in upper case? ...

Filter Question 05-20-07
I have a List Box from a query on my form that has a field ClientID and 2 other fields and on my form I have one ClientID, How can I filter the list box to only show the two other fields with the same ClientID in the list Box, Thanks for any Help ...

CFileDialog question
I am using CFileDialog and using this is it possible to capture right click? For my requirement I do not want to process right click. Please let me know if there is a way to do this... Thanks Suchrithaa ...

Recursion Question
I have the following simple recursion and as I unwind the call stack (stepping through it), I am trying figure out where the eventual return value is being stored. Any help is appreciated. Thanks Mike namespace Factorial { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { label1.Text = Factorial(5).ToString(); } public int Factorial(int n) { if(n==0) return 1; ...

Multithread (3)
I've been told that if DLL exported function is thread safe (i.e. doesn't use global scope variables), than I can call that DLL function from my EXE using multiple threads. I want now to ask what about internal DLL functions (that exported DLL function calls)? Example: __declspec( dllexport ) int MyDLLFunc(int val) { addOne(val); } int addOne(int val) { return ++val; } What if multiple MyDLLFunc() (multiple threads) calls addOne()? Is this thread safe? yes, it's thread safe.....the only one problem which could occured is that your function change a data stati...

text function question
Hi all, Hopefully my confuse is not so difficult to help. I have text arrays in column A2:A100 (much datas) which are filled with "n" and such as "loose end", "soft". I want in the column A1 is containing the text excludes "n". Due to of my poor function knowledge i tried to use CONCATENATE function but this is too long ..what should i use the proper formula. txs in advance 4 any helps One guess .. Assuming you want to extract text within A2:A100 that does not contain the letter "n", give this set up a try: Put in B2: =IF(A2=""...

RAID Question
Hi, Can you tell me, for a single Exchange 2003 server, which is better? Two drives configured to RAID 1 or RAID 10 for the entire server or RAID 1 on the system partition and RAID 5 for the rest? Thanks Jeff The answer: It Depends.... and Need More Information! It's fairly impossible to simply give a blanket statement that one is better than the other. There are too many other considerations you have to take into account. What you really need to do is get an accurate measurement of IOPS/user that you will need, and then base your storage needs off that (leaving room for grow...

Vlookup question #4
i have on sheet1 a list of reference data in two columns. column a) has a part code in it and column b) has a piece of data relating to it. in a few examples (infact probably the majority of cases) the code in cell a) is repeated a few times but with different data in cell b) on each occasion. is it possible to do a lookup where it finds and brings back data in column b)on all occasions when a code is found in column a, not just the first of last? does that make sense? cheers Rob Hi you may try downloadind Alan Beban's array functions (http://home.pacbell.net/beban) They'll includ...

Searching Column Question
Hi All, I'm having a problem searching some of my excel sheets and hope someone might have a way to do this. I need to search a workbook with multiple sheets for a specific value only in one column. For an example I have a inventory workbook with lots of sheets. All sheets have a column for barcodes (column F) and I need to search this column for a specific barcode number on all sheets simultaneously. Can this be done? Thanks. Brad --- Message posted from http://www.ExcelForum.com/ Brad I don't believe you can limit your search to only one column on each sheet without VB...

Cryptic question
I apologize for not being more descriptive in my first question money would not copy to CD. I was trying to put the file not money itself onto CD. What I would like to do is put the file to CD and then run money off to CD. I hope I'm wording this right as I am new to computers. It will not copy to a floppy disk neither. But it backs up just fine to CD ...

Simple Question?
I have a form with a command button connected to a query that returns a recordset in datasheet view. One of the fields is EmployeeID which corresponds to tblEmployee.EmployeeID which likewise corresponds to tblEmployee.FirstName and tblEmployee.LastName. As it stands, when I run the query, I have field EmployeeID in the returned recordset. I would like to have the employee's concatenated full name instead. Is this possible? Thanks, Tim Just write "Select tblEmployee.FirstName & " " & tblEmployee.LastName from tblEmployee" tbrogdon@gmail.com wrote: >I ...

WritePrivateProfile multithreaded?
I'm curious if the WritePrivateProfileString function works from various threads and processes? If I have multiple threads accessing (reading/writing) a single .ini file, are there any issues? Or, does the OS handle this properly? Thanks DanB As in any multi-threaded solution, it's probably best that you use a critical section or mutex object to synchronize access to the file between the threads. "Dan Baker" <dbmail> wrote in message news:%23Vo4o%23DLGHA.2780@tk2msftngp13.phx.gbl... > I'm curious if the WritePrivateProfileString function works from vari...

REPOST: basic question re select
Sorry, did the accidental keystroke for send message....oops So how do I select records from a table where a field has a value or is null. I tried : select * from tbl_article where lift in(1 ,null) but that didn't work... AussieRules select * from tbl_article where lift =1 OR lift IS NULL "AussieRules" <nospam@nospam.com> wrote in message news:ezTLn6c8KHA.1424@TK2MSFTNGP04.phx.gbl... > Sorry, did the accidental keystroke for send message....oops > > So how do I select records from a table where a field has a value o...

report question
how can we make a report to see the cash sales detail and credit card sales detail? Hope someone can help me.. Try the Tender Summary Report in Reports --> Miscellaneous --> Tender Summary. There is some additional Tender Summary reports in the Reports Library, one includes Transaction Number. You need to have access to Customer Source in order to download the file. Tender Summary with Transaction Number http://tinyurl.com/9gt4d - Report http://tinyurl.com/djreu - Preview (pdf file) Rob "HOJIN" wrote: > how can we make a report to see the cash sales detail and cred...

xmldocument.preservewhite space question
I have an xmldocument and need to set the preservewhitespace to true as after processing the document I want to write out the xml (using outerxml/innerxml) and have the identations preserved for readability. However with the preservewhite space option set code such as: foreach (XmlNode node in ParentNode) { } fails as the whitespace seems to confuse the parser, how can I work around this? robert@orisoft.co.uk wrote: > I have an xmldocument and need to set the preservewhitespace to true as > after processing the document I want to write out the xml ...

Online Banking Question
I just installed Money 2004 and learned that although my bank has online banking it is not on their list of Financial Institutions. Does anyone know how who I might contact to get it added? Thanks! In microsoft.public.money, Sheesh wrote: >I just installed Money 2004 and learned that although my >bank has online banking it is not on their list of >Financial Institutions. Does anyone know how who I might >contact to get it added? Thanks! You could refer your bank to http://www.microsoft.com/money/partner/default.asp Who is the bank? Hi... it doesn't have to be on...

Notes question
Hello, Which form is GP Notes based on? If you attach a external file, where does it get stored? SQL Server or to a file system with a pointer in the database? Thanks, gsvi OLE notes are stored in a file in the OLE folder under your GP folder. The folder address is defined in the INI file on each workstation and, for them to work correctly, should all be pointing to the same shared folder. -- Richard L. Whaley Author / Consultant / MVP http://www.AccoladePublications.com Documentation for Software Users "gsvi" wrote: > Hello, > > Which form is GP Notes based on?...