My Rambling Thoughts

What-if 80386 paging

The design of 80386 paging mechanism is elegant and impeccable.

It has a 4 kB Page Directory containing 1,024 entries, each pointing to a 4 kB Page Table that contains 1,024 entries, each of which points to a 4 kB page. The symmetry is just elegant.

Except, the page size is too small — even in 1985, arguably.

Even by 1985 standards, very few programs use as little as 4 kB of code and 4 kB of data. There was no need to be granular to this degree.

Intel must have realized too, because they added large pages (4 MB) in Pentium in 1993. That was just 8 years apart. 4 MB was too large for general use, though.

Even in 1985, I'll say 16 kB would have been a better choice. 16 kB is still a reasonable — though considered the minimum — size today, imagine that.

The case against bigger page is that you waste half a page per allocation on average. This is internal fragmentation. The smaller the allocation, the more potential for waste. However, system-level allocations are usually big — run-time libraries allocate 64 kB or bigger at a time and parcel them out. Even system-level disk buffers are seldom smaller than 16 kB.

A 16 kB Page Table contains 4,096 entries (16 kB / 4) and points up to 64 MB of memory. The Page Directory contains only 64 entries.

|Bits|#bits|Purpose|
|---|---|+--|
|26 - 31|6|Page Directory|
|14 - 25|12|Page Table|
|0 - 13|14|Offset|

Large page

If we follow Pentium's approach and drop Page Table translation, we get 64 MB large page. That is way too big! (Most of the time.)

A good large size is 64 kB or 256 kB. 64 kB is kind of small for a 'large page', 256 kB barely qualifies — it is big, not large.

Format of a 256 kB page:

|Bits|#bits|Purpose|
|---|---|+--|
|26 - 31|6|Page Directory|
|18 - 25|8|Page Table|
|0 - 17|18|Offset|

The type of page is determined at the Page Directory level, so 256 kB pages must be aligned at physical 64 MB boundary and there are only 64 such regions. Once a 64 MB region is designated to use 256 kB page, the entire region must use 256 kB pages.

A big-page Page Table has only 256 entries. It is quite wasteful.

Can we support variable-size pages? Yes, but maybe in the future.

A case for >4 GB address space

4 GB is big for a single process, but we can still run short of memory in a multi-process environment!

Pentium Pro, released in 1995, supports 36-bit address space, or 64 GB of physical memory.

We need to widen the page entry to 64-bit so that we can store the upper 4 address bits. This is a one-time change. In the future, we can widen the address to 40-bit, 48-bit or even longer — though these are more likely in 64-bit systems.

A Page Table now has 2,048 entries (16 kB / 8). The Page Directory has 128 entries. There is no need for third-level Page Directory Pointers.

|Bits|#bits|Purpose|
|---|---|+--|
|25 - 31|7|Page Directory|
|14 - 24|11|Page Table|
|0 - 13|14|Offset|

We can support 36-bit address space with just two levels of page tables — with a full Page Directory of 2,048 entries.

We finally need third level to support 40-bit address space, but that is a topic for another time. :-D

Defending against Meltdown

The TLB knows whether the page is privileged. The check is done before the read. This prevents speculative read that enables Meltdown attack. By doing this, there is no need for KPTI (Kernel Page-Table Isolation).

For complete defense, the TLB must have Process-Context Identifiers (PCID) to tag processes. This truly isolates processes. PCID was originally added to avoid flushing the TLB when switching between processes.

Without hardware support, the TLB must be flushed on every context switch. Every system call requires two flushes (to kernel and from kernel).

12K Sky at Dawn


A Thousand Miles of Wind, the Sky at Dawn: Part 1 (Book 5) [2026]

First impressions: the paper is really white! Font size is standard, double line spacing and wide margin.

I've read a few chapters and my initial impression is that it feels like it is written natively in English — it does not feel translated! The Tokyopop edition is generally good, but has some awkward phrasing sometimes.

Some readers may prefer a more literal translation to preserve the original meaning, though it may not read as smoothly.

Take the title, for example. It is translated literally. It is 风之万里 . 黎明之空 in Chinese.

Part 1 mostly sets up the story. All the exciting stuff is in Part 2. You don't miss much even if you skipped this.

LTA urges buyers to be prudent in COE bidding

LTA can only 'urge' buyers to be prudent because that's all it can do — it has no means to lower COE price. Whatever it did, it always made things worse because buyers moved from cat B to cat A, driving cat A price up.

(It is no-brainer with EV cars — they can be detuned easily, and they still feel powerful due to their high torque. Who knows if they are tuned back later? LTA is not checking, for sure. This is a semi-loophole, IMO. Detuned cars should not be allowed in cat A.)

High COE price also cause existing car owners to renew their COE, hence reducing the quota for new cars. (Though you can argue that if they scrap their car and buy a new one, they will consume one quota anyway.)

If you determine whether a car is affordable based on monthly installment, then it is still affordable. A $200k car at 2.5% annual flat interest is $250k over 10 years, or $2,083 monthly. If you earn $4k and above, you will feel it is 'affordable'. $4k is not a very high bar.

Let's compare it against two other metrics.

First, price of car vs your annual income, especially your take-home pay. If the car costs the same as your annual income, it means one year out of ten years of your pay goes to your car. This is generally considered to be affordable — though still a little on the high side.

Currently, this means earning $200k per year. This is around 90th percentile. You need to be at 90th percentile to comfortably afford a car. If you earn $100k/year (70th percentile), it is two years out of ten years. If you earn $50k/year (52th percentile), that's four years — no one should be so crazy, I hope.

The second way to look at it is how long it takes you to save this amount of money. If you save $30k/year, it will take you 6.7 years to reach $200k! That's a pretty long time. Can you save $30k a year in the first place?

(It works out to be $2.5k/mth. Normally you plan to save/invest 30% of your pay.)

COE is 'efficient'. Its price is determined purely by how much people are willing to pay.

But there are two problems. First, financing that allows 'affordable' monthly installments, while ignoring total cost. Second, commercial uses that generate revenue and 'offset' the high price.

Murdoku he cross


Murdoku: 80 Murder Mystery Logic Puzzles (Vol 1) [2025]

Can see it is derived from Sudoku. Has Sudoku-like mechanics and deduction. No ongoing story, pure deduction.


Case 1

In color, very pretty! No wonder the book costs more. :lol:

There are 80 puzzles. The first seven are 6x6 tutorial grids. After one 7x7 grid, they are mainly 8x8 and 9x9 with some non-square, with the final four 12x12.

According to the author, 1 – 20 are very easy to easy, 21 – 40 are medium, 41 – 70 are hard, 71 – 80 are expert level.

A clue gives you a list of possible squares a person can be on. With every clue, you narrow down the squares. There can only be one person per row and per column. Once you are certain, you can cross out the rest of the row/column. Sometimes, all possible squares for one person are in a single row, so no one else can be on that row.

There are no hints, but the solution can be used to unblock stuck steps, because the solving sequence is usually fixed. The name of the murderer is printed right at the top, but it is not much of a spoiler — you just want to solve the puzzle logically!

Maybe because it uses visual elements and is in color, I enjoy solving this over Murdle. I'm shallow. :-P

Online puzzles

Its website has 24 playable puzzles and 22 printable puzzles. Don't know if they are refreshed periodically.

Murdling logic

The author has a Math, English literature and MFA (Master of Fine Arts) degree. Can tell from the book. It combines math logic with witty descriptions and has a running story.


Murdle Murder Mystery Logic Puzzles (Book 1) [2023]

There are 100 puzzles with four difficulty levels. If stumbled, each puzzle offers a hint.

Hint: there are hints and solutions for other puzzles on the same page, be sure to cover them to avoid spoiling the next puzzle.

Easy has 3 suspects, 3 weapons and 3 locations. 5 – 6 clues are given, including the murder location. A basic clue either confirms or denies a fact. If it says A is at X, it rules out him being elsewhere and other people at this place — one person at one place having one object. A denial is like, A does not have P. There are more complicated clues, such as, either M or N is true.

Deduction is of the style, A is at X, X has P, thus A has P. Or, if A is not at X or Y, he must be at Z. Reminds you of Sudoku or Clue?

Medium has 2 clues and 3 statements, one of which is false (from the murderer). It has no murder location.

Hard has 4 suspects, 4 weapons, 4 locations and 4 motives. It has 9 – 10 clues, including murder location.

Impossible has 5 – 9 clues and 4 statements, one of which is false. It has no murder location.

Solving

I find it quite easy to make mistakes. To help me backtrack, I write the clue number beside a tick or cross, and whether it is deduced. Suppose I get it wrong from clue 3, I can then erase everything marked 3 and above and continue.

You do not need to fill up all the squares. As long as you fill the entire grid horizontally or vertically, you have all the info already.

Daily dose

It has its own website with daily puzzle.