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 the differences between ntfs4 and ntfs5?
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?
Explain cannot copy (file name)- access is denied?
if thread a,b,c have Max,Min,Normal priorty what is N0. in below set they correspond to.Something like (2,0,1)
What is thread injection?
How would you implement a thread pool?
How do you kill tasks?
Is kill ping a virus?
What's the difference in using runnable and extends in threads?
How do you kill a process using pid?
How to share printer through ftp(fire transfer protocol)?
Explain how to kill a particular process in windows?
Which protocol is working behind dhcp server? And what exactly dora does?
How do I kill a process?
Where is taskkill located?