Service threads

You can create Open Server threads that run independently of any client connection. Such threads are called service threads because the routines they execute usually perform services for event-driven client threads. Unlike a client thread, a service thread is not activated by events. Instead, you supply a routine for the thread to execute when you create it. The server puts it in the run queue immediately. A service thread disappears once the routine it was created to execute returns.

An application can use service threads to accomplish a variety of tasks in an Open Server application. In fact, the Open Server runtime system is composed of service threads running server management routines. Service threads cannot be used to perform client I/O—that is, to read in client commands and return results.

Open Server schedules event code to run when an event is triggered. By contrast, an application must explicitly schedule service thread code using the srv_wakeup, srv_sleep, srv_yield routines, and it must schedule message queues when not running in preemptive mode.