Pop-Up Threads

Pop-Up Threads

Threads are often useful in distributed systems. An important example is how incoming messages, for instance requests for service, are managed. The usual approach is to have a process or thread that is blocked on a receive system call waiting for an incoming message. When a message arrives, it accepts the message, unpacks it, inspects the contents, and processes it.

On the other hand, a totally different approach is also possible, in which the arrival of a message causes the system to create a new thread to handle the message. Such a thread is called a pop-up thread and is demonstrated in the following figure 1. A key advantage of pop-up threads is that since they are brand new, they do not have any history - registers, stack, whatever - that must be restored. Each one starts out fresh and each one is identical to all the others. This makes it possible to create such a thread rapidly. The new thread is given the incoming message to process. The result of using pop-up threads is that the delay between message arrival and the start of processing can be made very short.

Creation of a new thread when a message arrives

Some advance planning is required when pop-up threads are used. For instance, in which process does the thread run? If the system supports threads running in the kernel's context, the thread may run there (which is why we have not shown the kernel in above figure 1). Having the pop-up thread run in kernel space is generally easier and faster than putting it in user space. Also, a pop-up thread in kernel space can easily access all the kernel's tables and the I/O devices, which may be required for interrupt processing. However, a buggy kernel thread can do more damage than a buggy user thread. For instance, if it runs too long and there is no way to stop it, incoming data may be lost.


pop-up thread, thread, i/o devices