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 is the difference between a computer process and thread?
What is wait() and notify()?
Explain thread.sleep?
Explain what is the impact if dns server fails?
Explain what is windows daemon?
How do we create threads?
Tell me how to share printer through ftp(fire transfer protocol)?
How do I kill a program without task manager?
What's the difference in using runnable and extends in threads?
Explain which protocol is working behind dhcp server? And what exactly dora does?
can any one know about NIC (National Informatics Centre) questions Patterns and full detail about written exam, and interview send to softshikha2005@yahoo.com.in Thank you
Explain which one is not needed for multi-program environment?
What are multithreading models?
What is multi programming?
How do you kill a process using pid?