multthrd.c sample program

The multthrd.c sample program illustrates a number of Open Server multithreaded programming features, including:

A service thread logs all the language queries received by this Open Server application.

In the application’s language handler, the client thread reads the query from a client and sends a message to the service thread, known as the “logger,” with the query as the message data. Then, the client thread waits (srv_sleep). When the service thread gets the message, it wakes up the client thread (srv_wakeup). The logger thus continuously loops, waiting for messages. When it receives a message, it prints the contents of the query to a file and wakes up the sender.

The logger and client threads install SRV_C_RESUME, SRV_C_SUSPEND, SRV_C_TIMESLICE, and SRV_C_EXIT callback handlers to print scheduling information. The multthrd.c program installs a SRV_START handler, a SRV_LANGUAGE handler, a SRV_CONNECT handler, and callback handlers.