When is segmentation a good idea?
Many people would say never. This is not true. Segmentation is
a good idea for large assembly-based projects. It's not a good
idea for C projects, since C wasn't constructed with segmentation
in mind.
Here is a list of the advantages (compared to flat memory
model)
- Major data structures can be protected (high level of
protection)
- 16-bit offsets can be used instead of 32-bit in many
cases (smaller executables)
- 16-bit near calls can be used instead of 32-bit near
calls (smaller executables)
- Data segments cannot be executed (security)
- Stack corruption is likely to protection fault in the
module causing the error (easier to debug)
- Returns to invalid code is caught at return instruction
(easier to debug)
Here is a list of disadvantages (compared to flat memory
model)
- Loading selectors takes time. In a assembler project,
this isn't very common, so it doesn't affect performance
too much.
Objections
None registered this far ;-)
Disagree?
Send a mail. If
it's relevant, I will put it under objections.