Urgent.News

What's breaking now, across thousands of outlets.

Tech

What algorithm did Windows XP use to choose your initial user picture?

Windows XP utilized the RtlRandomEx random number generator to select an initial user picture from the %ALLUSERSPROFILE%\Application Data\Microsoft\User Account Pictures\Default Pictures directory. The generator began with the current value of GetTickCount() as the seed. The function employed a one-pass random selection algorithm, which was more efficient compared to the naïve two-pass algorithm that required counting all items and then randomly picking a number from 1 to n, followed by a second iteration to find the item at that index.

This one-pass algorithm avoided the need for multiple file system calls and prevented complications if the number of files in the directory changed during runtime. It functioned by first selecting an item randomly from the first n - 1 items and then switching to the nth item with a 1/n probability, following a recursive approach.

The algorithm concluded after sampling 100 pictures to prevent potential issues if the directory contained a large number of files.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Also reported by 1 other outlet

Read the original at devblogs.microsoft.com →

More in Tech

A Series of Unfortunate Jobs

You can't tell me Laravel queues haven't bitten you at least once. It's great that we get them out of the box, but man, they can be confusing as hell sometimes.

  • Reminder job failed due to retryUntil() evaluated at job dispatch, not execution.
  • Horizon defaults to zero retries for jobs, causing indefinite retries in production.
  • ShouldBeUnique ensures lock release upon processing start, not completion.

More from Thursday 10 September →