சனி, 20 பிப்ரவரி, 2010

C- QUESTIONS

1. What does static variable mean?
2. What is a pointer?
3. What is a structure?
4. What are the differences between structures and arrays?
5. In header files whether functions are declared or defined?
6. What are the differences between malloc() and calloc()?
7. What are macros? what are its advantages and disadvantages?
8. Difference between pass by reference and pass by value?
9. What is static identifier?
10. Where are the auto variables stored?
11. Where does global, static, local, register variables, free memory and C Program instructions get stored?
12. Difference between arrays and linked list?
13. What are enumerations?
14. Describe about storage allocation and scope of global, extern, static, local and register variables?
15. What are register variables? What are the advantage of using register variables?
16. What is the use of typedef?
17. Can we specify variable field width in a scanf() format string? If possible how?
18. Out of fgets() and gets() which function is safe to use and why?
19. Difference between strdup and strcpy?
20. What is recursion?
21. Differentiate between a for loop and a while loop? What are it uses?
22. What are the different storage classes in C?
23. Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
24. What is difference between Structure and Unions?
25. What the advantages of using Unions?
26. What are the advantages of using pointers in a program?
27. What is the difference between Strings and Arrays?
28. In a header file whether functions are declared or defined?
29. What is a far pointer? where we use it?
30. How will you declare an array of three function pointers where each function receives two ints and returns a float?
31. what is a NULL Pointer? Whether it is same as an uninitialized pointer?
32. What is a NULL Macro? What is the difference between a NULL Pointer and a NULL Macro?
33. What does the error 'Null Pointer Assignment' mean and what causes this error?
34. What is near, far and huge pointers? How many bytes are occupied by them?
35. How would you obtain segment and offset addresses from a far address of a memory location?
36. Are the expressions arr and &arr same for an array of integers?
37. Does mentioning the array name gives the base address in all the contexts?
38. Explain one method to process an entire string as one unit?
39. What is the similarity between a Structure, Union and enumeration?
40. Can a Structure contain a Pointer to itself?
41. How can we check whether the contents of two structure variables are same or not?
42. How are Structure passing and returning implemented by the complier?
43. How can we read/write Structures from/to data files?
44. What is the difference between an enumeration and a set of pre-processor # defines?
45. what do the 'c' and 'v' in argc and argv stand for?
46. Are the variables argc and argv are local to main?
47. What is the maximum combined length of command line arguments including the space between adjacent arguments?
48. If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
49. Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?
50. What are bit fields? What is the use of bit fields in a Structure declaration?
51. To which numbering system can the binary number 1101100100111100 be easily converted to?
52. Which bit wise operator is suitable for checking whether a particular bit is on or off?
53. Which bit wise operator is suitable for turning off a particular bit in a number?
54. Which bit wise operator is suitable for putting on a particular bit in a number?
55. Which bit wise operator is suitable for checking whether a particular bit is on or off?
56. which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
57. Write a program to compare two strings without using the strcmp() function.
58. Write a program to concatenate two strings.
59. Write a program to interchange 2 variables without using the third one.
60. Write programs for String Reversal & Palindrome check
61. Write a program to find the Factorial of a number
62. Write a program to generate the Fibinocci Series
63. Write a program which employs Recursion
64. Write a program which uses Command Line Arguments
65. Write a program which uses functions like strcmp(), strcpy()? etc
66. What are the advantages of using typedef in a program?
67. How would you dynamically allocate a one-dimensional and two-dimensional array of integers?
68. How can you increase the size of a dynamically allocated array?
69. How can you increase the size of a statically allocated array?
70. When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
71. Which function should be used to free the memory allocated by calloc()?
72. How much maximum can you allocate in a single call to malloc()?
73. Can you dynamically allocate arrays in expanded memory?
74. What is object file? How can you access object file?
75. Which header file should you include if you are to develop a function which can accept variable number of arguments?
76. Can you write a function similar to printf()?
77. How can a called function determine the number of arguments that have been passed to it?
78. Can there be at least some solution to determine the number of arguments passed to a variable argument list function?
79. How do you declare the following:
o An array of three pointers to chars
o An array of three char pointers
o A pointer to array of three chars
o A pointer to function which receives an int pointer and returns a float pointer
o A pointer to a function which receives nothing and returns nothing
80. What do the functions atoi(), itoa() and gcvt() do?
81. Does there exist any other function which can be used to convert an integer or a float to a string?
82. How would you use qsort() function to sort an array of structures?
83. How would you use qsort() function to sort the name stored in an array of pointers to string?
84. How would you use bsearch() function to search a name stored in array of pointers to string?
85. How would you use the functions sin(), pow(), sqrt()?
86. How would you use the functions memcpy(), memset(), memmove()?
87. How would you use the functions fseek(), freed(), fwrite() and ftell()?
88. How would you obtain the current time and difference between two times?
89. How would you use the functions randomize() and random()?
90. How would you implement a substr() function that extracts a sub string from a given string?
91. What is the difference between the functions rand(), random(), srand() and randomize()?
92. What is the difference between the functions memmove() and memcpy()?
93. How do you print a string on the printer?
94. Can you use the function fprintf() to display the output on the screen?

C++- QUESTIONS

C++- Questions

  1. What is a class?
  2. What is an object?
  3. What is the difference between an object and a class?
  4. What is the difference between class and structure?
  5. What is public, protected, private?
  6. What are virtual functions?
  7. What is friend function?
  8. What is a scope resolution operator?
  9. What do you mean by inheritance?
  10. What is abstraction?
  11. What is polymorphism? Explain with an example.
  12. What is encapsulation?
  13. What do you mean by binding of data and functions?
  14. What is function overloading and operator overloading?
  15. What is virtual class and friend class?
  16. What do you mean by inline function?
  17. What do you mean by public, private, protected and friendly?
  18. When is an object created and what is its lifetime?
  19. What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
  20. Difference between realloc() and free?
  21. What is a template?
  22. What are the main differences between procedure oriented languages and object oriented languages?
  23. What is R T T I ?
  24. What are generic functions and generic classes?
  25. What is namespace?
  26. What is the difference between pass by reference and pass by value?
  27. Why do we use virtual functions?
  28. What do you mean by pure virtual functions?
  29. What are virtual classes?
  30. Does c++ support multilevel and multiple inheritance?
  31. What are the advantages of inheritance?
  32. When is a memory allocated to a class?
  33. What is the difference between declaration and definition?
  34. What is virtual constructors/destructors?
  35. In c++ there is only virtual destructors, no constructors. Why?
  36. What is late bound function call and early bound function call? Differentiate.
  37. How is exception handling carried out in c++?
  38. When will a constructor executed?
  39. What is Dynamic Polymorphism?
Write a macro for swapping integers.

What are the basic functions of an operating system?

  1. What are the basic functions of an operating system?
  2. Explain briefly about, processor, assembler, compiler, loader, linker and the functions executed by them.
  3. What are the difference phases of software development? Explain briefly?
  4. Differentiate between RAM and ROM?
  5. What is DRAM? In which form does it store data?
  6. What is cache memory?
  7. What is hard disk and what is its purpose?
  8. Differentiate between Complier and Interpreter?
  9. What are the different tasks of Lexical analysis?
  10. What are the different functions of Syntax phase, Sheduler?
  11. What are the main difference between Micro-Controller and Micro- Processor?
  12. Describe different job scheduling in operating systems.
  13. What is a Real-Time System ?
  14. What is the difference between Hard and Soft real-time systems ?
  15. What is a mission critical system ?
  16. What is the important aspect of a real-time system ?
  17. If two processes which shares same system memory and system clock in a distributed system, What is it called?
  18. What is the state of the processor, when a process is waiting for some event to occur?
  19. What do you mean by deadlock?
  20. Explain the difference between microkernel and macro kernel.
  21. Give an example of microkernel.
  22. When would you choose bottom up methodology?
  23. When would you choose top down methodology?
  24. Write a small dc shell script to find number of FF in the design.
  25. Why paging is used ?
  26. Which is the best page replacement algorithm and Why? How much time is spent usually in each phases and why?
  27. Difference between Primary storage and secondary storage?
  28. What is multi tasking, multi programming, multi threading?
  29. Difference between multi threading and multi tasking?
  30. What is software life cycle?
  31. Demand paging, page faults, replacement algorithms, thrashing, etc.
  32. Explain about paged segmentation and segment paging
  33. While running DOS on a PC, which command would be used to duplicate the entire diskette?

Windows Questions.

  1. Explain the windows Architecture
  2. What is Create Window API?
  3. What is the use of Create Window API?
  4. What is the use of Get Message?
  5. What is the use of Translate Message?
  6. What is the use of Dispatch Message?
  7. What is paint structure?
  8. What is Device context?
  9. What is Get DC and Release DC
  10. What is Window Procedure?
  11. What is Window class?

Microsoft Windows programming interview questions

Windows interview questions
1. Which controls can not be placed in MDI ?
2. List out controls which does not have events
3. Which property of textbox cannot be changed at runtime. What is the max size of textbox?
4. How many system controls are available
5. ___,_____ and ____ container objects.
6. strech___ Property is to compress a image in image control.
7. ___,___ and __ are difference between image and picture controls.
8. Is it possible to set a shortcut key for label.
9. What is the default property of data control?
10. ___,__,___ are the type of combo box?
11. __ no of controls in form.
12. OLE is used for _______
13. What is the need of tabindex property is label control.
14. ___ is the control used to call a windows application.
15. Clear property is available in ____,___ control.
16. ___ Property is used to count no. of items in a combobox.
17. ___ is a property to resize a label control according to your caption.
18. Which controls have refresh method.
19. ___ property is used to change to ___ value to access a identity column in datacontrols.
20. _____ is the property to ___,____,____ are valid for recordsource property of dat control.
21. To find the current record position in data control.
22. Timer control contains ________ no. of events.
23. ____ property is used to lock a textbox to enter data.
24. What is the need of z-order method?
25. ____ is the difference between Listindex and Tab index.
26. ____ property of menu cannot be set at run time.
27. Can you create a tabletype of recordset in Jet - connected ODBC dbengine.
28. Difference between listbox and combo box.
29. What are the new events in textbox that has been included in VB
30. 0
31. Can you create a Updatecascade, Deletecascade relation in Ms- Access? If no, give on eample.
32. _____ collection in recordset used to assign a value from textbox to table columns without making abinding in datacontrol.
33. ____ argument can be used to make a menu item into bold.
34. What is the difference between Msgbox Statement and MsgboxQ function?
35. What is.the difference between queryunload and unload in form?
36. ___,___ arguments will be used to run a executable program in shell function
37. ___ property used to add a menus at runtime.
38. What is the difference between modal and module-less window?
39. ___ VB constant make the menu item in centre.
40. ___ method used to move a recordset pointer in nth position in DAG.
41. To validate a range of values for a property whenever the property values changes,which type of property procedure you use?
42. What are 3 main differences between flexgrid control and dbgrid control?
43. What is the difference between change event in normal combobox and dbcombobox?
44. To populate a single column value which dbcontrols you to use?
45. What is ODBC?
46. Parts of ODBC?
47. What is DSN?
48. What is DAO?
49. Types of cursors in DAO?
50. Types of LockEdits in DAO? 51 .Types of Recordsets.
51. Difference between Tabletype and Snapshot?
52. Draw Sequence Modal of DAO? Explain.
53. Difference between Dynaset and Snapshot?
54. Difference between Recordset and Querydef?
55. What is the use of Tabledef?
56. Default cursor Type and LockEdit type in DAO?
57. What is the default workspace?
58. 1s it posible to Create Tables Through Querydef?
59. It is possible to access Text (x.txt) files? Explain.
60. What is ODBC Direct and Microsoft Jet Database Engine ?
61. Is it possible to Manipulate data through flexgrid? Explain.
62. Types of DBCombo boxes
63. What do you mean by Databound Controls? Explain.
64. What is RDO?
65. Types of cursors in RDO.
66. Types of LockEdits in RDO.
67. Types of LockEdits in RDO.
68. Types of Resultsets.
69. Difference between Recordset and Resultsets.
70. Explain Default cursor Type and LockEdits type in RDO
71. Draw Sequence Modal of RDO? Explain.
72. What is meant by Establish Connection in RDO?
73. Is it possible to Access BackEnd procedures? Explain.
74. What is OLE? Explain.
75. What is DDE?
76. Difference between Linked Object and Embedded Object?
77. Explain OLE Drag and Drop.
78. Difference between DDE and OLE.
79. What is the difference between Object and Class?
80. Give brief description about class?
81. Does VB support object-oriented concepts? Explain..
82. Difference between Class Module and Standard Module?
83. Explain Get, Let, Set Properties.
84. Difference Types of Procedures in VB?
85. What is the use of NEW Keyword? Explain.
86. What is constructors and distructors.
87. Types of Modal windows in VB.
88. What is ActiveX? Explain.
89. Types of ActiveX Components in VB?
90. Difference between ActiveX Control and Standard Control.
91. Difference between ActiveX Exe and Dll.
92. What is instantiating?
93. Advantage of ActiveX Dll over Active Exe.
94. Difference Types of Instancing Property in ActiveX Dll and Exe.
95. What is ActiveX Dll and ActiveX Exe?
96. Write the steps in Creating ActiveX Dll and Active Exe?
97. Explain the differences between ActiveX Dll and ActiveX Exe?
98. How would you use ActiveX Dll and ActiveX Exe in your application?
99. How would you access objects created in ActiveX Exe and ActiveX D1T
100. What is the use of ActiveX Documents?
101. What is ActiveX Document?
102. What is the use of Visual Basic Document file?
103. What is hyperlink?
104. How would you create Visual basic Document file?
105. What is Internet Explorer and its uses?
106. How would you navigate between one document to another document in Internet Explorer ?
107. How would you run your ActiveX Document Dll?
108. How would you view html code in Active Server Pages?
109. How would you cre.ate your application in DHTML?
110. What is ActiveX Control?
111. Write the Steps in Creating an ActiveX Control?
112. How would you attach an ActiveX control in Your Application?
113. How would you create properties in ActiveX Control?
114. What is the-use of property page Wizard in ActiveX Control?
115. How would you add elements in TreevieW Control.
116. What are the types of line styles available in Treeview Control?
117. What is the use of Imagelist Controls
118. How would you attach pictures in Treeview Control?
119. What are the uses of List View Control?
120. Explain the types of Views in Listview Control.
121. How would you attach pictures in column headers of List View Control?
122. How would you add column headers in listview control?
123. How would you add elements and pictures to listitems in listview control?
124. How would you activate animation control?
125. What is the use of progress Bar Control?
126. How would you find out the value property in Slider Bar Control?
127. What is the use of Data Form Wizard?
128. How would you map properties to controls by using ActiveX Control Interface Wizard?
129. How would you convert a form into document?
130. How would you Create a Query Builder and Explain its uses
131. How would you create properties by using class Builder Wizard?
132. HTML stands for What? Use of HTML ?
133. Whether HTML supports multimedia: and document links?
134. DHTML Is used for what?
135. What do you mean by HTTP?
136. What is the use of Hyperlink control for DHTML applications?
137. How can you Navigate from the DHTML application to another DHTML application? .
138. What are the Internet tools available in VB
139. 0?
140. Explain the usage of Web Browser Control?
141. What do you mean by ADO?
142. What is the difference Between ADO and other data access objects0
143. What is OLEDB?
144. What are the important components of OLEDB?
145. Through which protocol OLEDB components are interfaced?
146. It possible to call OLEDB’s Features directly in VB without using any control?
147. What type of databases you can access through AD I Data Access Object?
148. How many objects resides in ADO ?
.
149. What is the use of Connection object?
150. What is the use of command Object?
151. Record set object consists of what?
152. What is the use of parameters collection?
153. Which type of object requires this object?
154. Is it possible to call backend procedures with ADO control?
155. Is there any Edit method in ADO Data Access method?
156. How can you check whether a record is valid record or Invalid record using ADO control or Object?
157. What do you mean by provider?
158. What type of record sets are available in ADO?
159. Is it possible to call oracle database through ADO control or Object?
160. How many File System Controls are there ? Explain.
161. How can you filter out specific type of file using file system controls?
162. How can you get selected file from file system Control?
163. How many ways we can access file using VB?
164. Which method is preferred to save data like database to the disk?
165. How to get free file location in memory?
166. How to find size of the file. Which method or function is used to occomplish this?
167. Using which type we can access file line by line?
168. Which method is used to write context Into file?
169. How can you read content from file?
170. Binary Access-method is used to access file in which manner?
171. How can you check Beginning and End of the file?
172. What is the use of Scalewidth and ScaleHeight Proeperty?
173. What is the use of Active Control Property?
174. How can you save and Get data from Clipboard/
175. What are the types of Error?
176. In which areas the Error occurs?
177. What are the tools available for Debug in VB?
178. What is the use of Immediate, Local Window?
179. What is the use of debug Window?
180. How can you Implement windows functionality in VB?
181. How many types of API functions are available in VB?
182. How can you Add API functions to your Application?
183. How to get Cursor position using API?
184. Is it possible to change menu runtime using API? If yes? Specify the function names.
185. What are the types of API Types.
186. Scope of API’s can be of types, what are they? Why API functions are Required?

Windows programming interview questions

Windows, C++ interview questions
1. What are kernel objects? - - Several types of kernel objects, such as access token objects, event objects, file objects, file-mapping objects, I/O completion port objects, job objects, mailslot objects, mutex objects, pipe objects, process objects, semaphore objects, thread objects, and waitable timer objects.
2. What is a kernel object? - Each kernel object is simply a memory block allocated by the kernel and is accessible only by the kernel. This memory block is a data structure whose members maintain information about the object. Some members (security descriptor, usage count, and so on) are the same across all object types, but most are specific to a particular object type. For example, a process object has a process ID, a base priority, and an exit code, whereas a file object has a byte offset, a sharing mode, and an open mode.
3. User can access these kernel objects structures? - Kernel object data structures are accessible only by the kernel
4. If we cannot alter these Kernel Object structures directly, how do our applications manipulate these kernel objects? - The answer is that Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object.
5. How owns the Kernel Object? - Kernel objects are owned by the kernel, not by a process
6. How does the kernel object outlive the process that created it? - If your process calls a function that creates a kernel object and then your process terminates, the kernel object is not necessarily destroyed. Under most circumstances, the object will be destroyed; but if another process is using the kernel object your process created, the kernel knows not to destroy the object until the other process has stopped using it
7. Which is the data member common to all the kernel object and what is the use of it? -
The usage count is one of the data members common to all kernel object types
8. How to identify the difference between the kernel object and user object? -
The easiest way to determine whether an object is a kernel object is to examine the function that creates the object. Almost all functions that create kernel objects have a parameter that allows you to specify security attribute information.
9. What is the purpose of Process Handle Table? -
When a process is initialized, the system allocates a handle table for it. This handle table is used only for kernel objects, not for User objects or GDI objects. When a process first initializes, its handle table is empty. Then when a thread in the process calls a function that creates a kernel object, such as CreateFileMapping , the kernel allocates a block of memory for the object and initializes it; the kernel then scans the process’s handle table for an empty entry
10. Name few functions that create Kernel Objects? - HANDLE CreateThread(…),HANDLE CreateFile(..),HANDLE CreateFileMapping(..)HANDLE CreateSemaphore(..)etcAll functions that create kernel objects return process-relative handles that can be used successfully by any and all threads that are running in the same process.
11. What is handle? - Handle value is actually the index into the process’s handle table that identifies where the kernel object’s information is stored.
12. How the handle helps in manipulating the kernel objects? - Whenever you call a function that accepts a kernel object handle as an argument, you pass the value returned by one of the Create* functions. Internally, the function looks in your process’s handle table to get the address of the kernel object you want to manipulate and then manipulates the object’s data structure in a well-defined fashion.
13. What happens when the CloseHandle(handle) is called? - This function first checks the calling process’s handle table to ensure that the index (handle) passed to it identifies an object that the process does in fact have access to. If the index is valid, the system gets the address of the kernel object’s data structure and decrements the usage count member in the structure; if the count is zero, the kernel destroys the kernel object from memory.
14. You forget to call CloseHandle - will there be a memory leak? - Well, yes and no. It is possible for a process to leak resources (such as kernel objects) while the process runs. However, when the process terminates, the operating system ensures that any and all resources used by the process are freed—this is guaranteed. For kernel objects, the system performs the following actions: When your process terminates, the system automatically scans the process’s handle table. If the table has any valid entries (objects that you didn’t close before terminating), the system closes these object handles for you. If the usage count of any of these objects goes to zero, the kernel destroys the object.
15. What is the need of process relative handles? - The most important reason was robustness. If kernel object handles were system-wide values, one process could easily obtain the handle to an object that another process was using and wreak havoc on that process. Another reason for process-relative handles is security. Kernel objects are protected with security, and a process must request permission to manipulate an object before attempting to manipulate it. The creator of the object can prevent an unauthorized user from touching the object simply by denying access to it
16. How the handles are handled in the child process? - The operating system creates the new child process but does not allow the child process to begin executing its code right away. Of course, the system creates a new, empty process handle table for the child process—just as it would for any new process. But because you passed TRUE to CreateProcess’s bInheritHandles parameter, the system does one more thing: it walks the parent process’s handle table, and for each entry it finds that contains a valid inheritable handle, the system copies the entry exactly into the child process’s handle table. The entry is copied to the exact same position in the child process’s handle table as in the parent’s handle table.
17. Why the entries in the parent process table and child table are same? - It means that the handle value that identifies a kernel object is identical in both the parent and the child processes.
18. What about the usage count in the parent child process tables? - The system increments the usage count of the kernel object because two processes are now using the object. For the kernel object to be destroyed, both the parent process and the child process must either call CloseHandle on the object or terminate.
19. What are Named Objects? - Method available for sharing kernel objects across process boundaries is to name the objects. Below are the kernel named objects 1) mutex, 2) Events, 3) semaphore, 4) waitableTimers, 5)file mapping, 6)job object. There are APIs to create these objects with last parameter as the object name.
20. What do you mean by unnamed object? - When you are creating the kernel objects with the help of API’s like CreateMutex(, , , ,pzname). And the Pzname parameter is NULL , you are indicating to the system that you want to create an unnamed (anonymous) kernel object. When you create an unnamed object, you can share the object across processes by using either inheritance or DuplicateHandle
21. What is DuplicateHandle (API)? - Takes an entry in one process’s handle table and makes a copy of the entry into another process’s handle table
22. What is a thread? - A thread describes a path of execution within a process. Every time a process is initialized, the system creates a primary thread. This thread begins executing with the C/C++ run-time library’s startup code, which in turn calls your entry-point function ( main , Wmain , WinMain , or WWinMain ) and continues executing until the entry-point function returns and the C/C++ run-time library’s startup code calls ExitProcess
23. What is the limit on per process for creating a thread? - The number of threads a process can create is limited by the available virtual memory and depends on the default stack size
24. What is Synchronization Objects? - Synchronization object s are use to co-ordinate the execution of multiple threads.
25. Which kernel objects are use for Thread Synchronization on different processes? - Event, Mutex, Semaphore
26. What is Event Object and why it is used? - Event is the thread synchronization object to set signaled state or non-signaled state.
27. What is signaled and non signaled state? - An event is in signaled state means that it has the capacity to release the threads waiting for this event to be signaled. An event is in non signaled state means that it will not release any thread that is waiting for this particular event.example in our project: when user clicks the image application icon double simultaneously. Two image application windows were created. so PAIG created an event and set it to non-signaled state. Then the image application will reset the event to signaled state, after this all the threads are released.
28. APIs for creating event and set and reset the events - CreateEvent-to create the event OpenEvent – to open already created event SetEvent – to set the event signaled stateRestEvent - To set the Event To non-Signaled State
29. What is Mutex Object and why it is used? - A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.
30. How do I create a Mutex? - A thread uses the CreateMutex function to create a mutex object. The creating thread can request immediate ownership of the mutex object and can also specify a name for the mutex object
31. How do other threads own the mutex? - Threads in other processes can open a handle to an existing named mutex object by specifying its name in a call to theOpenMutex - function. Any thread with a handle to a mutex object can use one of the wait functions to request ownership of the mutex object. If the mutex object is owned by another thread, the wait function blocks the requesting thread until the owning thread releases the mutex object using theReleaseMutex - function.
32. What is semaphores and why it is used? - A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value. The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore. When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled. The state of a semaphore is set to signaled when its count is greater than zero, and non-signaled when its count is zero. The semaphore object is useful in controlling a shared resource that can support a limited number of users. It acts as a gate that limits the number of threads sharing the resource to a specified maximum number. For example, an application might place a limit on the number of windows that it creates. It uses a semaphore with a maximum count equal to the window limit, decrementing the count whenever a window is created and incrementing it whenever a window is closed. The application specifies the semaphore object in call to one of the wait functions before each window is created. When the count is zero - indicating that the window limit has been reached - the wait function blocks execution of the window-creation code.

What Is CMutex ?

What Is CMutex ?

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.

To use a CMutex object, construct the CMutex object when it is needed. Specify the name of the mutex you wish to wait on, and that your application should initially own it. You can then access the mutex when the constructor returns. Call CSyncObject::Unlock when you are done accessing the controlled resource.

What is the difference between ASSERT and VERIFY?

The main difference between ASSERT and VERIFY is when you compile the release build of the program.

ASSERT will not be present in the release build version of the executables/dlls, and its expression that would have been evaluated will be deleted.

VERIFY will be present in the release build version of the executables/dlls but its expression that would have been evaluated will be left intact


what is the use of AFX_MANAGE_STATE ?

By default, MFC uses the resource handle of the main application to load the resource template. If you have an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is actually stored in the DLL module. You need to switch the module state for the correct handle to be used. You can do this by adding the following code to the beginning of the function:
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
This swaps the current module state with the state returned from AfxGetStaticModuleState until the end of the current scope.

If all your resources lies in the single DLL you can even change the default handle to the DLL handle with the help of AfxSetResourceHandle function.