HeadlinesBriefing favicon HeadlinesBriefing.com

Windows XP User Picture Selection Algorithm Explained

Hacker News •
×

Windows XP selected initial user pictures at random from the Default Pictures directory using the RtlRandomEx function seeded by GetTickCount(). The algorithm employed a one-pass reservoir sampling technique (k=1) to avoid multiple file system calls and handle directory changes during execution. It iterates through files, selecting each with probability 1/count, ensuring uniform randomness.

A safety limit of 100 pictures prevents performance issues with large directories. Raymond Chen, a long-time Windows engineer and author of The Old New Thing, explained the efficiency and correctness of this approach, noting its advantages over two-pass methods and its basis in recursive probability theory.