Hi,
I have to create a recursive critical section using wince 5.0 API. Here is
the following code that I tried. Is the logic right?
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#define MAX 25
int count = 0;
CRITICAL_SECTION cs[MAX];
CRITICAL_SECTION guard;
void os_enter_cs(void);
void os_exit_cs(void);
int _tmain(void)
{
InitializeCriticalSection(&guard);
return 0;
}
void os_enter_cs(void)
{
// guard it
EnterCriticalSection(&guard); // guard
{
count++;
InitializeCriticalSection(&cs[count]);
}
LeaveCriticalSection(&guard); // guard
EnterCriticalSection(&cs[count]);
}
void os_exit_cs(void)
{
EnterCriticalSection(&guard); // guard
{
count--;
LeaveCriticalSection(&cs[count+1]);
DeleteCriticalSection(&cs[count+1]);
}
LeaveCriticalSection(&guard); // guard
}
Paul T.
You removed so much code that this doesn't make any sense at all. Your
functions **never** get called. I also cannot find any reason for you to
have an array of critical sections. From what little you show us, you could
do it with a single critical section.
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT Eurotech DOT com
My BLOG http://geekswithblogs.net/bruceeitman
Eurotech Inc.
www.Eurotech.com
"newbie_wince" <newbie...@discussions.microsoft.com> wrote in message
news:55ADD952-794B-4430...@microsoft.com...
"Bruce Eitman [eMVP]" wrote:
> .
>
"Bruce Eitman [eMVP]" wrote:
> .
>