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                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 


 

Company >> Atos Origin >> Interview Questions >> MFC Interview Questions
 
  Call Centre AllOther Interview Questions (1)   MM Interview Questions (1)   ABAP Interview Questions (10)
  ASP.NET Interview Questions (1)   MFC Interview Questions (1)
 
Back to Questions Page
Question   What is Thread ?(VC++)What is the difference between Cmutex and Csemaphone? Rank Answer Posted By  
 Interview Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
An object of class CMutex represents a "mutex" ? a 
synchronization object that allows one thread mutually 
exclusive access to a resource. Mutexes are useful when 
only one thread at a time can be allowed to modify data or 
some other controlled resource. For example, adding nodes 
to a linked list is a process that should only be allowed 
by one thread at a time. By using a CMutex object to 
control the linked list, only one thread at a time can gain 
access to the list.
An object of class CSemaphore represents a "semaphore" ? a 
synchronization object that allows a limited number of 
threads in one or more processes to access a resource. A 
CSemaphore object maintains a count of the number of 
threads currently accessing a specified resource.
 
0 Jitendra
 
 
Answer
Thread is the smallest set of instructions that can be 
executed.

Cmutex and Csemaphore are the ways used for synchronization 
purpose.

the difference between the above two is..Cmutex is a single 
lock where as csemaphore is a multilock..


mutex is used for mutual exclusion while semaphore is a 
synchonozation variabl
 
0 Dhanya Shajit
 
 
Answer
CMutex                          CSemaphore
                        
Allows at most one thread  allows more than one thread to 
access the resource(RES)   Access the RES simultaneousl     
y        

Prevents more than one               It allows more that 
one thread 2        
Thread to access the res             access the resource

Using mutex, we can                 Using semaphore, we can 
sync 
Synchronize one/more threads   threads with in the process
In different process or with in
Process.

CMutex is a single lock                CSemaphore is a 
multilock.

CMutex Implementation          CSemaphore Implementation
API’s in CMutex Dev:
::Create Mutex()                        ::CreateSemaphore()
::WaitForSinglrObject()               ::WaitForSinglrObject
()
::WaitForMultipleObject
()             ::WaitForMultipleObject()    
::Release Mutex()                       ::Release Semaphore
()
                                                 ::CloseHand
le()
 
0 Zero Zero
 
 
 
 
Back to Questions Page
 
 
 
 
 
   
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