Click here to Skip to main content
15,916,318 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWTL CListView Pin
Luke Murray8-Jan-03 20:29
Luke Murray8-Jan-03 20:29 
GeneralRegarding Port Pin
San8-Jan-03 18:30
San8-Jan-03 18:30 
GeneralRe: Regarding Port Pin
xxhimanshu8-Jan-03 21:09
xxhimanshu8-Jan-03 21:09 
Generaldialogs in dll's Pin
l a u r e n8-Jan-03 18:13
l a u r e n8-Jan-03 18:13 
GeneralRe: dialogs in dll's Pin
Rage8-Jan-03 22:34
professionalRage8-Jan-03 22:34 
GeneralRe: dialogs in dll's Pin
xxhimanshu8-Jan-03 23:37
xxhimanshu8-Jan-03 23:37 
QuestionCan anyone help me about using Softice. Pin
sonshiro8-Jan-03 17:05
sonshiro8-Jan-03 17:05 
GeneralFaster mutex implementation Pin
Brian Tietz8-Jan-03 14:56
Brian Tietz8-Jan-03 14:56 
Back in my BeOS days, I was exposed to a faster mutex implemenation which coupled an atomic_add with a semaphore. The implementation was (in pseudo code):

Mutex constructor:
int_avail_count = 1;
sem_avail_count = 0;

Lock:
atomic_add( &int_avail_count, -1 )
if int_avail_count was 1: return
else (someone else held the mutex): wait on semaphore; for first waiter, sem_avail_count goes to -1

Unlock:
atomic_add( &int_avail_count, 1 )
if int_avail_count was 0: return
else (someone else was or would soon be waiting on the semaphore): release the semaphore; for last waiter, sem_avail_count goes to 0 again

I just encountered a situation in a Win32 app where I have a body of data which must be protected by a critical section, but will be hit often from a high-priority thread. There will be very little if any contention for this data so it's a prime candidate for this construct, which saves a trip into the kernel for a mutex acquisition. I'm therefore looking into using InterlockedIncrement/InterlockedDecrement, CreateEvent/SetEvent/WaitForSingleObject to implement this design for windows. But... On BeOS, mutexes and events were implemented as generic semaphores involving a count. It was perfectly legitimate for a thread to release a semaphore even if it doesn't own it (that was the client's responsibility to enforce). But since ReleaseMutex is documented with: "The ReleaseMutex function fails if the calling thread does not own the mutex object" it requires the use of an event. To use this design on Windows requires an event, not a mutex, and would depend on a behavior, so now the question:

First, if multiple threads are blocked on an event and a single call is made to SetEvent, does one waiting thread unblock, or all? If all, this design is not feasible. If one, on to the next question...

Second, if multiple threads are blocked on an event, and a single call is made to SetEvent, are they released in FIFO order, or arbitrary? Hopefully FIFO, as the design also depends on that behavior.
GeneralRe: Faster mutex implementation Pin
Michael Dunn8-Jan-03 15:24
sitebuilderMichael Dunn8-Jan-03 15:24 
GeneralRe: Faster mutex implementation Pin
Brian Tietz8-Jan-03 15:54
Brian Tietz8-Jan-03 15:54 
QuestionListView does not set item position property in icon view... bug? Pin
Hiusing8-Jan-03 14:34
Hiusing8-Jan-03 14:34 
AnswerRe: ListView does not set item position property in icon view... bug? Pin
Rage8-Jan-03 22:39
professionalRage8-Jan-03 22:39 
AnswerRe: ListView does not set item position property in icon view... bug? Pin
KaЯl9-Jan-03 0:17
KaЯl9-Jan-03 0:17 
QuestionHow to convert data in MFC object to XML Pin
The_wind8-Jan-03 14:33
The_wind8-Jan-03 14:33 
AnswerRe: How to convert data in MFC object to XML Pin
Christian Graus8-Jan-03 14:58
protectorChristian Graus8-Jan-03 14:58 
GeneralImplicit vs Explicit Linking of DLLs Pin
VanHlebar8-Jan-03 14:24
VanHlebar8-Jan-03 14:24 
GeneralRe: Implicit vs Explicit Linking of DLLs Pin
Chris Losinger8-Jan-03 14:33
professionalChris Losinger8-Jan-03 14:33 
GeneralRe: Implicit vs Explicit Linking of DLLs Pin
VanHlebar8-Jan-03 16:06
VanHlebar8-Jan-03 16:06 
GeneralRe: Implicit vs Explicit Linking of DLLs Pin
Chris Losinger8-Jan-03 16:31
professionalChris Losinger8-Jan-03 16:31 
GeneralRe: Implicit vs Explicit Linking of DLLs Pin
Roger Allen8-Jan-03 22:15
Roger Allen8-Jan-03 22:15 
GeneralLocking computer from user input. Pin
Daeriel8-Jan-03 14:19
Daeriel8-Jan-03 14:19 
GeneralRe: Locking computer from user input. Pin
Michael Dunn8-Jan-03 15:26
sitebuilderMichael Dunn8-Jan-03 15:26 
GeneralRe: Locking computer from user input. Pin
Daeriel8-Jan-03 15:53
Daeriel8-Jan-03 15:53 
Questionstatic .lib size with VC++ 6 / 7 ?? Pin
CAE8-Jan-03 12:19
CAE8-Jan-03 12:19 
AnswerRe: static .lib size with VC++ 6 / 7 ?? Pin
Chris Losinger8-Jan-03 13:10
professionalChris Losinger8-Jan-03 13:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.