ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Operating Systems  >>  Windows  >>  Windows Threads
 
 


 

 
 SDK interview questions  SDK Interview Questions
 Windows Threads interview questions  Windows Threads Interview Questions
 Windows AllOther interview questions  Windows AllOther Interview Questions
Question
Which one you will use to implement critical section?
 Question Submitted By :: Tribhuvan Sharma
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Which one you will use to implement critical section?
Answer
# 1
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 ?    0 Yes 0 No
Nirmalraj
 
  Re: Which one you will use to implement critical section?
Answer
# 2
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 ?    0 Yes 0 No
Svinto
 
 
 

 
 
 
Other Windows Threads Interview Questions
 
  Question Asked @ Answers
 
How to Kill a Particular Process in windows? Tomax3
Which one you will use to implement critical section? HCL2
Which one is not needed for Multi-program enviornment? 1) virtual memory 2) security 3) time sharing 4) none of the above. Siemens5
semaphore variable is different from ordinary variable by ?  2
WHAT IS A DAEMON? IBM3
 
For more Windows Threads Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com