Wine, WineLib and "Programming Applications for Windows"
Last updated: 2001/3/1
Description
This example is an instance of the classic multiple writer,
multiple reader problem. Two 'writer' threads add/modify the color
of balls in a bucket. Three 'reader' threads count the balls and
display the result, each in its own list. The problem is that the
ball counts are hidden by the scrollbar (even with normal fonts)
which makes it impossible to follow what is going on.
This example uses three synchronization object types: mutex,
semaphore and a manual-reset event.
Wine tests
Winelib tests
Tested API
- KERNEL32
CloseHandle, CreateEventA, CreateMutexA, CreateSemaphoreA, GetModuleHandleA, GetStartupInfoA, InterlockedIncrement, ReleaseMutex, ReleaseSemaphore, ResetEvent, SetEvent, Sleep, WaitForMultipleObjects, WaitForSingleObject, lstrlenA
- MSVCRT20
_XcptFilter, __getmainargs, __p__acmdln, __p__commode, __p__fmode, _beginthreadex, _controlfp, _except_handler3, _exit, _initterm, exit, rand, sprintf
- USER32
DialogBoxParamA, EndDialog, GetDlgCtrlID, GetDlgItem, GetDlgItemInt, GetScrollPos, GetScrollRange, GetWindowLongA, LoadIconA, SendMessageA, SetClassLongA, SetDlgItemInt, SetScrollPos, SetScrollRange
Last updated: 2001/3/1
Description
This application demonstrates the use of critical sections. For
this is uses three threads. The first one handles the graphical
interface. The second one takes the content of a string global
variable, converts it to an integer, increments it, and puts the
value back. The third one samples the values in the string global
variable and displays them in a list. The graphical interface allows
you to choose whether critical sections should be used or not, to
pause the execution, and change the relative priorities of the
threads. If access to the string global variable is not synchronized
you will quickly notice that the values are not in increasing
order!
The windows smooth-scroll is really painful to watch as it slows
down the application by a factor of at least 10 (maybe a 100).
Fortunately it gets turned off after some time.
Wine tests
- The thread controlling the graphical
interface seems to be getting no CPU time. The problem is so
accute that the graphical interface is not fully displayed
initially and that you may not be able to use its controls at
all.
- The above bug prevented me from doing any test.
Winelib tests
Tested API
- KERNEL32
DeleteCriticalSection, EnterCriticalSection, GetCurrentProcess, GetModuleHandleA, GetStartupInfoA, InitializeCriticalSection, LeaveCriticalSection, ResumeThread, SetPriorityClass, SetThreadPriority, Sleep, SuspendThread, TerminateThread
- MSVCRT20
_XcptFilter, __getmainargs, __p__acmdln, __p__commode, __p__fmode, _beginthreadex, _controlfp, _except_handler3, _exit, _initterm, _strrev, exit, sprintf, sscanf
- USER32
DialogBoxParamA, EndDialog, GetDlgItem, GetWindowLongA, IsDlgButtonChecked, LoadIconA, SendMessageA, SetClassLongA
Last updated: 2001/3/1
Description
Demonstrates the use of auto-reset events. Counts the characters,
words and lines of the text file specified on the command line. A
main thread reads the file chunk by chunk and notifies three worker
threads using events each time a chunk is ready. The threads in turn
notify the main thread when they are done so that it can read the
next chunk of data.
Wine tests
Winelib tests
Tested API
- KERNEL32
CloseHandle, CreateEventA, CreateFileA, GetCommandLineA, GetExitCodeThread, GetModuleHandleA, GetStartupInfoA, ReadFile, SetEvent, WaitForMultipleObjects, WaitForSingleObject
- MSVCRT20
_XcptFilter, __getmainargs, __p__acmdln, __p__commode, __p__fmode, _beginthreadex, _controlfp, _except_handler3, _exit, _initterm, exit, sprintf, strchr
- USER32
IsCharAlphaA, MessageBoxA
Last updated: 2001/3/1
Description
This is the same application as critsecs
but implemented with mutexes.
Wine tests
- The thread controlling the graphical
interface seems to be getting no CPU time. The problem is so
accute that the graphical interface is not fully displayed
initially and that you may not be able to use its controls at
all.
- The following tests were performed with an older version of Wine
were the graphical interface was more responsive.
- The responsiveness of the graphical
interface is much better although it is still sluggish: 5
seconds delays are not uncommon
- The redisplay of the list is incorrect.
Only the last two/three lines are updated, even once the counters
are paused. On Windows one sees the list being scrolled on the
whole length and its display is always coherent.
- Adjusting the process/thread priorities
has no effect
Winelib tests
Tested API
- KERNEL32
CloseHandle, CreateMutexA, GetCurrentProcess, GetModuleHandleA, GetStartupInfoA, ReleaseMutex, ResumeThread, SetPriorityClass, SetThreadPriority, Sleep, SuspendThread, TerminateThread, WaitForSingleObject
- MSVCRT20
_XcptFilter, __getmainargs, __p__acmdln, __p__commode, __p__fmode, _beginthreadex, _controlfp, _except_handler3, _exit, _initterm, _strrev, exit, sprintf, sscanf
- USER32
DialogBoxParamA, EndDialog, GetDlgItem, GetWindowLongA, IsDlgButtonChecked, LoadIconA, SendMessageA, SetClassLongA
Last updated: 2001/3/1
Description
Demonstrates the use of Semaphores by running a supermarket
simulation this time. The process creates one thread per client and
runs the simulation until the supermarket is empty again.
Wine tests
- Just like on Windows, only much faster because we don't have
the smooth-scroll.
Winelib tests
Tested API
- KERNEL32
CloseHandle, CreateMutexA, CreateSemaphoreA, GetCurrentProcess, GetModuleHandleA, GetStartupInfoA, GetTickCount, ReleaseMutex, ReleaseSemaphore, SetPriorityClass, Sleep, WaitForSingleObject
- MSVCRT20
_XcptFilter, __getmainargs, __p__acmdln, __p__commode, __p__fmode, _beginthreadex, _controlfp, _except_handler3, _exit, _initterm, exit, rand, sprintf, vsprintf
- USER32
DialogBoxParamA, EnableWindow, EndDialog, GetDlgItem, GetFocus, GetScrollPos, GetScrollRange, GetWindow, GetWindowLongA, LoadIconA, SendMessageA, SetClassLongA, SetFocus, SetScrollPos, SetScrollRange, SetWindowTextA