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


Please Help Members By Posting Answers For Below Questions

Which protocol is working behind dhcp server? And what exactly dora does?

589


Explain which one you will use to implement critical section?

535


What is the difference between a computer process and thread?

570


Where is taskkill located?

549


Is kill ping a virus?

536






what are the different types of codes in thread in windows os?

2681


Explain the reasons of rebooting the system?

529


Explain difference between ntfs4 and ntfs5?

606


Tell me when we browse internet system getting 500 error how will you solve the problem?

531


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?

546


Explain thread.sleep?

561


How do you kill a service?

540


What are three ways in which a thread can enter the waiting state?

566


Explain how to kill a particular process in windows?

528


if a min thread has finished execution what happens ? a) it exits b) it wait for other threads c) becomes inactive ... etc etc

3017