next up previous contents index
Next: Run it in a Up: Updating screens without user-intervention Previous: Animated images as multipart   Contents   Index


Waiting for each other

With a client-server architecture the underlying database contains all the information that is necessary to describe what to put on a new page. The crucial question is when to update a page. When you use server-pull you have to anticipate after how many seconds you want a new page. Hence, this time interval should not be dependent on actions of other participants. However, with server-push actions of other participants may trigger an update of a page.

For instance, only after all users have entered a stage of an experiment, we want to update their screen and give them some information. Or, only after a player's opponent has made a choice, we can inform the player about the opponent's action.

An inefficient way to do this would be to have all cgi-scripts (we have one for each player) constantly checking, whether a certain condition that requires action (a server-push) has occured. Actively checking, however, requires resources.

A more efficient way to do this is to send all cgi-scripts to sleep and wake them up when the condition that requires action occurs.

In order to wake up we use signals. There are several signals2.1, most of them are used by the system, but the signal USR1 can be used by us.

The following C-fragment should clarify the procedure:


next up previous contents index
Next: Run it in a Up: Updating screens without user-intervention Previous: Animated images as multipart   Contents   Index
Oliver Kirchkamp