Which one you will use to implement critical section?
Answers were Sorted based on User's Feedback
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 |
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 |
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
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?
Explain how to kill a particular process in windows?
What are types of threads?
What is thread safety?
What is the reason for getting the dialogue box (send this error to microsoft giving options as send to microsoft and dont send) when we abort from the any workwhen it was struck?
How do I kill a program without task manager?
Explain which protocol is working behind dhcp server? And what exactly dora does?
Which protocol is working behind dhcp server? And what exactly dora does?
What is the default kill signal?
How to share printer through ftp(fire transfer protocol)?
Tell me when we browse internet system getting 500 error how will you solve the problem?