Which one you will use to implement critical section?
Answer Posted / 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 View All Answers
What are types of threads?
who among the following is responsible for establishing IS Audit function in the organisation?
What is the default kill signal?
How do I kill a program without task manager?
Explain cannot copy (file name)- access is denied?
explain readers-writers problem?
What is thread safety?
How do we create threads?
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?
How to stop a thread?
Tell me when we browse internet system getting 500 error how will you solve the problem?
What are the different ways in which a thread can enter into waiting state?
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?
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?
What are the different identifier states of a thread?