Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Recursive critical section in wince 5.0

48 views
Skip to first unread message

newbie_wince

unread,
May 13, 2010, 12:20:01 PM5/13/10
to

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 G. Tobey [ eMVP ]

unread,
May 13, 2010, 4:03:01 PM5/13/10
to
What are you trying to *do*?

Paul T.

Bruce Eitman [eMVP]

unread,
May 14, 2010, 9:10:31 AM5/14/10
to
As Paul stated, what are you trying to do.

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...

newbie_wince

unread,
May 17, 2010, 11:13:02 AM5/17/10
to

Hi,
sorry Iam also unclear. I will post in detail later.

"Bruce Eitman [eMVP]" wrote:

> .
>

newbie_wince

unread,
May 17, 2010, 12:31:01 PM5/17/10
to
Hi,
I am also unclear. I will update the code and reply later.

"Bruce Eitman [eMVP]" wrote:

> .
>

0 new messages