Notes for CSSAPP
2025-07-26
In C#, bool
uses 1 byte (not 1 bit) due to memory alignment. To store multiple flags efficiently, use bit masking:
byte flags = 0b_0000_1010; // 8 flags in 1 byte
bool flag2 = (flags & (1 << 1)) != 0; // check 2nd flag
bool flagN = (flags & (1 << N)) != 0; // check N-th flag, 0 <= N < 8
Chapter 3: Machine-Level Representation of Programs
- Each memory address is 8 bytes (64 bits) in modern systems.
- A 32-bit machine can only m ake use of around 4GB (2^32 bytes) of memory.
- A 64-bit machine can address up to 16 exabytes (2^64 bytes), but practically it is 2^48 bytes (256 TB) due to OS limitations. Given the development of AI and demand for large context windows. It is needed to use all 64 bits for memory addressing.