Which one you will use to implement critical section?

Answers were Sorted based on User's Feedback



Which one you will use to implement critical section?..

Answer / nirmalraj

Critical Section comes in single process environment they
didn't share accross process boundary.

In C if you wish to implement criticalsection you have to
use windows datastructure CRITICAL_SECTION and create a
object to access its members.

Initialize it
InitializeCriticalSection(&cs);
------------
-----------
function to call();
------------
DeleteCriticalSection(&cs);
.
.
call()
{
}

Is This Answer Correct ?    1 Yes 0 No

Which one you will use to implement critical section?..

Answer / svinto

Now sure what is asked but anyway:
1. If the question is how would you implement critical
section mechanism then the answer is to use a mutex.
2. If the question is to show how to use the critical
section then the following code fragment adresses that:
//
// Global variable or a member of some
// dynamically allocated structure, usualy within
// the data access to which it is protecting.
//
CRITICAL_SECTION cs;

VOID Init(VOID) {
InitializeCriticalSection( &cs );
}

VOID SomeCall(VOID) {
EnterCriticalSection( &cs );
//
// Thread-safe block of code protected by critical
section.
//
LeaveCriticalSection( &cs );
}

VOID
UnInit(VOID) {
DeleteCriticalSection( &cs );
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Windows Threads Interview Questions

Can you explain too many times when I click on a sentence a caption comes on grr a pop up blocker maybe blockiing--however I have pushed the turn off pop upblocker. This only happens on google it does not happen on att.net?

0 Answers  


Hi, I'm now using windows 7 in my desktop. I have used a lot of audio recording and editing software but most of then doesn't support the compatibility of win7 and often disturbs. So can anyone tell me which one would be the best audio recording and editing software for win7? Thanks Emanali

1 Answers  


how do u share printer through FTP(fire transfer protocol)?

1 Answers  


How to Kill a Particular Process in windows?

5 Answers   Tomax,


Purposes, features and functions of windows 98 and xp. i am struggling with this because i have to compare their strenths and weaknesses, please can i get help?

0 Answers  






Explain difference between ntfs4 and ntfs5?

0 Answers  


What is thread safety? How do you achieve it?

0 Answers  


How do I kill a program without task manager?

0 Answers  


In window xp which are the threads. Actually I wanna know if ms word is a process which are the threads? Is spell check is a thread?

0 Answers  


What is the difference between a computer process and thread?

0 Answers  


1.Can anyone tell how to install os manually? and is there any problem to install os? 2. Can anyone tell how to resolve the blue screen error to install os

6 Answers   Wipro,


Can you explain too many times when I click on a sentence a caption comes on grr a pop up blocker maybe blocking--however I have pushed the turn off pop up blocker. This only happens on google it does not happen on att.net?

0 Answers  


Categories