Path: chuka.playstation.co.uk!news From: Alex Herbert Newsgroups: scee.yaroze.programming.libraries Subject: Re: A critical question Date: Wed, 04 Feb 1998 20:32:38 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 58 Message-ID: <34D8D066.2F8D65CB@ndirect.co.uk> References: <344478C2.6263@dial.pipex.com> Reply-To: aherbert@ndirect.co.uk NNTP-Posting-Host: dialin2-19.ndirect.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04 [en] (Win95; I) Chris Chadwick wrote: > Hi, > > Can someone help clear up in my mind the use of the EnterCriticalSection() > and ExitCriticalSection() functions. I realize, presumably, the point > of entering a critical section is so that a piece of code can be > allowed to execute at maximum speed, having surpressed the vsync > interrupt. Does this simply mean then that CallBack functions are > disabled? What other interrupts etc. are surpressed when calling > EnterCriticalSection()? > > I ask because my experience of running code within a critical > section is a bit baffling: The first piece of code I tried it > on had to do alot of number crunching (to anti-alias the display > image) which took quite a few vsyncs to complete. I got quite > a significant speed improvement when running this code in a > critical section. I also tried it on a piece of code that handled > collision detection - which obviously has to execute within > a single vsync - but actual got a degradation in speed. > > Does this mean I can expect *no* advantage running code in a > critical section unless it takes considerably longer than 1 vsync > to execute in the first place? > > And lastly (I promise!), the User Guide says than a program is > automatically *in* a critical section when first run!!!!!! > Given that most library functions arent supposed to execute > reliably if called from a critical section, whats going on? (a typo?) > > Someone sort my head out, please :) > Have I got *totally* the wrong idea about all this? > > Cheers 4 now, > > Chris I know it's a long time since this was posted, but I thought this info might be useful. Whilst in a CriticalSection, the GTE seems to halt. (Well, OT drawing seems to get held up.) Hence no perfomance increase in most cases. (Code is faster, graphics transfere slower.) Whilst on the point of optimising... It is worth finding out how much time (in hsyncs) there is between just before you call DrawSync() and after. If this is consistently higher than 2 or 3 scanlines, then your code is quicker than the GTE, in which case, optimising the code is futile - you still have to wait for the GTE. I'm sure someone will contradict me as I'm only a novice (had my Yaroze 6 days!). Alex