[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CriticalSection in VisaulC++ in C



Oyvind Teig wrote:

> Dear all
>
> I'm porting SPoC to Microsoft Visual C++. It seems like libraries
> as well as TIMER now function. (I need this to replace
> the transputer plug-in board in a new product where we want
> occam code reuse).
>
> It's all exclusively in the C domain. No C++.
> In order to insert time ticks, I spawn a thread with the
> _beginthread macro. That thread mostly sleeps, but wakes up
> to set new time and verify front of timer queue. If a waiting
> process is AFTER, an event flag is signalled.
>
> I should not have any race condition with the SPoC occam code,
> hand-investigation "proves" this. Should I decide not to trust
> this, would any of you know how a straight critical section
> could be added in VC++'s C-world? In process.h I only have
> semaphores, and I wouldn't want to semaphorize the rest of
> SPoC. Any suggestions?
>

>From a book I bought a couple of years ago: Windows 95 Programming Nuts
& Bolts.  The book covers only direct Win32 calls.  It mentions (but
provides no example uses of) three functions:

InitializeCriticalSection()
EnterCriticalSection()
LeaveCriticalSection()

no details of parameters or anthing though - perhaps this is what you
are looking for?


Jim
--
Jim.Moores, Quickstone Systems.

>
> --
> Oyvind
> (------------------------------------------------------------------(
> )       Oyvind Teig )          oyvind.teig@xxxxxxxxxxxx ) Tel: +47 )
> ( Navia Maritime AS (          oyvind.teig@xxxxxxxxxxxx ( 73581268 (
> )    div. Autronica )                                   ) Fax: +47 )
> (    7005 Trondheim (           http://www.autronica.no ( 73919320 (
> )            Norway )                                   )          )
> (------------------------------------------------------------------(
> )                    http://www.autronica.no/pub/tech/rd/index.htm )
> (------------------------------------------------------------------(