code from Modern Operating Systems by Andrew S. Tanenbaum