Wine, WineLib and "Programming Applications for Windows"





2.4.1. Chapter 9 - bucket

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

2.4.2. Chapter 9 - critsecs

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

Winelib tests

Tested API

2.4.3. Chapter 9 - docstats

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

2.4.4. Chapter 9 - mutexes

Last updated: 2001/3/1

Description

This is the same application as critsecs but implemented with mutexes.

Wine tests

Winelib tests

Tested API

2.4.5. Chapter 9 - sprmrkt

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

Winelib tests

Tested API

fgouget@free.fr This page is hosted for free by Free.fr