I'd like to understand how callback functions in a windowing application (like FreeGLUT, GLFW) work.
How many times they check for keyboard/mouse/resize events per second?
Does it depend on the frame rate, is it constant or maybe operation system specific?
Speaking generally, without getting into specifics for Unix or Windows implementations, callbacks are invoked from a main event loop which looks roughly like this:
Loop forever {
Get a message from the event queue.
Process the message
}
The stage of "Get a message" will have a very small sleep if it waits for a message to appear in the queue, probably less than a millisecond. The event queue will contain every message relevant to the application, including things like mouse button presses, mouse motion events, keyboard events, and window events like resize and expose.
The "Process the message" step will take an event and dispatch it to whatever is relevant for the event. So for example, a mouse click might result in the callback for a Button widget being called. Or if your OpenGL drawing area has an input handler callback set up, the mouse click would result in that function being called.
Here are a couple of resources to learn more about the process:
For Windows: http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows
For X/Motif: http://www.unix.com/man-page/all/3x/XtAppMainLoop/
If you want to see the specific steps along the way (there are many), you might try setting a breakpoint in a function you're interested in, such as your main OpenGL draw routine or an input callback function. Then the call stack will show you how you got there.