3 ms·
you don't need megabytes to allocate your strings dynamically, microsoft basic did it on the altair in 4k "/bin/sh\0" or "\7\0/bin/sh" is less than 14 bytes, n
by kragen 4y ago
you don't need megabytes to allocate your strings dynamically, microsoft basic did it on the altair in 4k
"/bin/sh\0" or "\7\0/bin/sh" is less than 14 bytes, not more, even including a pointer or two
the real issue is that anything you try to allocate dynamically can fail, so you need a failure path, and your failure path needs to reliably free all the other dynamically allocated resources
early unix kind of sucked at handling failures
a fixed-size buffer isn't more efficient but it is simpler
ms-dos used cp/m's filesystem, which had fixed-size filename and ext fields, which i think it copied from rt-11, which i think got them from various pdp-8 systems
fixed-size string buffers make more sense on a word-oriented machine, or arguably in a filesystem, where pointers require some kind of hack
i'd like to blame radix50 but i don't think we can because then the limit would be 9.3 or 6.3 rather than 8.3. there have been some 6.3 filesystems (3 16-bit words per filename with rad50) but cp/m fat (and thus ms-dos) are not among them
- tinus_hn 4y agoA great and easy idea, as long as you never need to release anything. Otherwise you end up with holes in your memory and you need to do compaction, and reserve the memory you need to be able to do that.
- kragen 4y agoor you can just have memory fragmentation compaction doesn't require a lot of memory but it's slow and intrusive; it has to know where all your buffer pointers are
- tinus_hn 4y agoObviously permanently wasting memory on fragmentation is not an option on a device that typically has 24kb memory. Especially not just so you can specify long filenames for the shell, when the filesystem doesn’t even support those filenames.
- kragen 4y agothe alternative they chose was to permanently waste memory on fixed-size struct fields, so i guess it was actually an option malloc on the pdp-11 never compacted of course the filesystem supported 14 characters for the basename, but evidently we're talking about code with a 14-character limit on the pathname, not the basename
- tinus_hn 4y agoYou don’t need compaction to reuse fixed size structures. I presume their priorities were with creating a working system, not one that answers to the ‘requirements’ of 50 years into the future.
- kragen 4y agoyou don't need compaction to reuse heap-allocated memory either wasted memory due to heap fragmentation is very similar to wasted memory due to slack space in fixed-size structure fields
- Zardoz84 4y agoPerhaps I wrong, but FAT and CP/M filesystems, aren't the same. CP/M filesystem never had directories. When the original FAT even predates QDOS as was used by Microsoft on his BASIC in 1977
- kragen 4y agohmm, i thought fat came from cp/m, not basic-80, but it looks like i was wrong about that thanks for the correction https://www.informit.com/articles/article.aspx?p=25878&seqNum=3 https://www.informit.com/articles/article.aspx?p=25878&seqNu... fat didn't have subdirectories in qdos or ms-dos pre-2 either