Why is RSC string data word-aligned?
> The unaligned data in a .rsc file is, I agree, unfortunate, as it could > have been aligned relatively easily and then data could have been > copied into memory a word at a time. Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)? 1. The array ORG.str itself is word-aligned, because... - Modules.AllocPtr is word-aligned (see Modules.Load) - Modules.DescSize is a multiple of 4, so mod.data is word-aligned - All type descriptors are word-aligned (see ORG.BuildTD) - All variables are word-aligned (see ORG.Declarations) - All strings are word-aligned (see ORG.MakeStringItem) 2. ORG.MakeStringItem WHILE strx MOD 4 # 0 DO str[strx] := 0X; INC(strx) END 3. ORP.Declarations IF sym = ORS.var THEN ... IF tp.size > 1 THEN varsize := (varsize + 3) DIV 4 * 4 (*align*) END ; … END ; varsize := (varsize + 3) DIV 4 * 4;
Yes, it is word-aligned in the compiler and in the .rsc file, but for strings we CAN NOT take benefit of it during file reading, as the endianess is not defined. Once in memory, we can copy words as the undefined endianess does not interfere anymore. br. Jörg
Am 31.01.2021 um 11:11 schrieb Andreas Pirklbauer <andreas_pirklbauer@yahoo.com>:
The unaligned data in a .rsc file is, I agree, unfortunate, as it could have been aligned relatively easily and then data could have been copied into memory a word at a time.
Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)?
1. The array ORG.str itself is word-aligned, because...
- Modules.AllocPtr is word-aligned (see Modules.Load) - Modules.DescSize is a multiple of 4, so mod.data is word-aligned - All type descriptors are word-aligned (see ORG.BuildTD) - All variables are word-aligned (see ORG.Declarations) - All strings are word-aligned (see ORG.MakeStringItem)
2. ORG.MakeStringItem
WHILE strx MOD 4 # 0 DO str[strx] := 0X; INC(strx) END
3. ORP.Declarations
IF sym = ORS.var THEN ... IF tp.size > 1 THEN varsize := (varsize + 3) DIV 4 * 4 (*align*) END ; … END ; varsize := (varsize + 3) DIV 4 * 4;
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Sorry, for my confusion mixing up „word-alignment“ and „multiple of four“. Indeed as Paul pointed out, the string block is not necessarily word-aligned in rsc file but the length of the string block is currently a multiple of four and can contain consecutive 0X. Firstly, the module loader reads several module names to be imported. The length of these names are not in multiple of four. The type descriptors, variable space and strings however are all items with length in multiple of four. As the destination address „p“ (where these blocks are stored in memory) is word-aligned the loader can just read these blocks without additional logic for word-alignment. If we decided to write the string block not in multiple of four, the loader would need additional code to guarantee word-alignment. Br, Jörg
Am 31.01.2021 um 11:42 schrieb Jörg <joerg.straube@iaeth.ch>: Yes, it is word-aligned in the compiler and in the .rsc file, but for strings we CAN NOT take benefit of it during file reading, as the endianess is not defined. Once in memory, we can copy words as the undefined endianess does not interfere anymore.
br. Jörg
Am 31.01.2021 um 11:11 schrieb Andreas Pirklbauer <andreas_pirklbauer@yahoo.com>:
The unaligned data in a .rsc file is, I agree, unfortunate, as it could have been aligned relatively easily and then data could have been copied into memory a word at a time.
Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)?
1. The array ORG.str itself is word-aligned, because...
- Modules.AllocPtr is word-aligned (see Modules.Load) - Modules.DescSize is a multiple of 4, so mod.data is word-aligned - All type descriptors are word-aligned (see ORG.BuildTD) - All variables are word-aligned (see ORG.Declarations) - All strings are word-aligned (see ORG.MakeStringItem)
2. ORG.MakeStringItem
WHILE strx MOD 4 # 0 DO str[strx] := 0X; INC(strx) END
3. ORP.Declarations
IF sym = ORS.var THEN ... IF tp.size > 1 THEN varsize := (varsize + 3) DIV 4 * 4 (*align*) END ; … END ; varsize := (varsize + 3) DIV 4 * 4;
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2021-01-31 10:11, Andreas Pirklbauer wrote:
Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)? ... - All type descriptors are word-aligned (see ORG.BuildTD) ... - All strings are word-aligned (see ORG.MakeStringItem)
Right, there are sections which *would* be (file) word-aligned, if other previous sections weren't variable (byte) length. Cheers, Paul
I think the source of the cognitive difference between .rsc files and in memory structures is that the .rsc file is a sequence of data read and written using the file reader and writer abstract data type, while the in-memory structures are records and arrays of values and blocks of code with constraints applied by the compiler. In Linux and many other Unix-based systems the structure of values on disk (e.g. behind the file ADT) is conflated with the in-memory representation because it can be memory-mapped (an excellent trick enabling many performant optimizations) entirely bypassing the encapsulation provided by the ADT. If we were to adjust the .rsc file for word alignment of strings, making the on-disk layout of values no longer agnostic to in-memory layout of data, I would go much further. I would make the on-disk layout exactly the same as an in-memory layout, enable demand paging of disk blocks to memory locations, just page in executable code as necessary (don't need an mmu for that if you start out by filling all page cache locations with an instruction that jumps to the 'paged out' handler) etc, etc, etc. but that is a much more complex system unsuitable for illustrating the core concepts of a single-user interactive workstation. My two cents. Chuck On Sun, Jan 31, 2021 at 7:14 AM Paul Reed <paulreed@paddedcell.com> wrote:
On 2021-01-31 10:11, Andreas Pirklbauer wrote:
Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)? ... - All type descriptors are word-aligned (see ORG.BuildTD) ... - All strings are word-aligned (see ORG.MakeStringItem)
Right, there are sections which *would* be (file) word-aligned, if other previous sections weren't variable (byte) length.
Cheers, Paul -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Chuck yes, but file would not be portable anymore because of endianess. br Jörg
Am 31.01.2021 um 16:52 schrieb Charles Perkins <chuck@kuracali.com>:
I think the source of the cognitive difference between .rsc files and in memory structures is that the .rsc file is a sequence of data read and written using the file reader and writer abstract data type, while the in-memory structures are records and arrays of values and blocks of code with constraints applied by the compiler.
In Linux and many other Unix-based systems the structure of values on disk (e.g. behind the file ADT) is conflated with the in-memory representation because it can be memory-mapped (an excellent trick enabling many performant optimizations) entirely bypassing the encapsulation provided by the ADT.
If we were to adjust the .rsc file for word alignment of strings, making the on-disk layout of values no longer agnostic to in-memory layout of data, I would go much further. I would make the on-disk layout exactly the same as an in-memory layout, enable demand paging of disk blocks to memory locations, just page in executable code as necessary (don't need an mmu for that if you start out by filling all page cache locations with an instruction that jumps to the 'paged out' handler) etc, etc, etc. but that is a much more complex system unsuitable for illustrating the core concepts of a single-user interactive workstation.
My two cents. Chuck
On Sun, Jan 31, 2021 at 7:14 AM Paul Reed <paulreed@paddedcell.com> wrote: On 2021-01-31 10:11, Andreas Pirklbauer wrote:
Isn’t any data - including string data . already word-aligned in the compiler (and therefore also in the .rsc file)? ... - All type descriptors are word-aligned (see ORG.BuildTD) ... - All strings are word-aligned (see ORG.MakeStringItem)
Right, there are sections which *would* be (file) word-aligned, if other previous sections weren't variable (byte) length.
Cheers, Paul -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Charles Perkins [chuck@kuracali.com] wrote:
"If we were to adjust the .rsc file for word alignment of strings, making the on-disk layout of values no longer agnostic to in-memory layout of data, I would go much further. I would make the on-disk layout exactly the same as an in-memory layout, enable demand paging of disk blocks to memory locations, just page in executable code as necessary (don't need an mmu for that if you start out by filling all page cache locations with an instruction that jumps to the 'paged out' handler) etc, etc, etc. but that is a much more complex system unsuitable for illustrating the core concepts of a single-user interactive workstation."
From my user perspective the file system speed optimizations are not even secondary. I would rather want to see a convenient file exchange between the RISC5 Oberon and Windows workstations. I would like to plug the Oberon SD into an SD card reader and easily copy files under Windows, from the V4 directory to the SD and vice versa, using the usual Windows drag and drop. I would like to do the same between the Oberon SD and the emulator.
I would like to use the entire SD card rather than a small portion of it. I do not mind "partitions", if partitions are visible and easily used under the emulator, the Windows host, and the Oberon workstation. I would like to add Linux and Mac to the list of hosts, though I am not using either. Present PC link is fine for small files or for the SW development. But it is not great for massive file exchange between Oberon and hosts, or Oberon and emulators. Is it unreasonable to expect easy and convenient file exchange with usual kind of Windows / Linux / Mac tools? Is it unreasonable to use the whole SD card? Concerning the speed under the Oberon, a boost would be provided with the QSPI interface rather than the present SPI interface. Arguing about the file reading speed without first replacing SPI with QSPI is funny. W.
The Mac emulator allows that, as Oberon files are Mac files. Or I use TFTP to exchange files with Windows computers. Jörg
Am 31.01.2021 um 21:30 schrieb Skulski, Wojciech <skulski@pas.rochester.edu>:
Charles Perkins [chuck@kuracali.com] wrote:
"If we were to adjust the .rsc file for word alignment of strings, making the on-disk layout of values no longer agnostic to in-memory layout of data, I would go much further. I would make the on-disk layout exactly the same as an in-memory layout, enable demand paging of disk blocks to memory locations, just page in executable code as necessary (don't need an mmu for that if you start out by filling all page cache locations with an instruction that jumps to the 'paged out' handler) etc, etc, etc. but that is a much more complex system unsuitable for illustrating the core concepts of a single-user interactive workstation."
From my user perspective the file system speed optimizations are not even secondary. I would rather want to see a convenient file exchange between the RISC5 Oberon and Windows workstations. I would like to plug the Oberon SD into an SD card reader and easily copy files under Windows, from the V4 directory to the SD and vice versa, using the usual Windows drag and drop. I would like to do the same between the Oberon SD and the emulator.
I would like to use the entire SD card rather than a small portion of it. I do not mind "partitions", if partitions are visible and easily used under the emulator, the Windows host, and the Oberon workstation. I would like to add Linux and Mac to the list of hosts, though I am not using either.
Present PC link is fine for small files or for the SW development. But it is not great for massive file exchange between Oberon and hosts, or Oberon and emulators.
Is it unreasonable to expect easy and convenient file exchange with usual kind of Windows / Linux / Mac tools? Is it unreasonable to use the whole SD card?
Concerning the speed under the Oberon, a boost would be provided with the QSPI interface rather than the present SPI interface. Arguing about the file reading speed without first replacing SPI with QSPI is funny.
W. -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
participants (6)
-
Andreas Pirklbauer -
Charles Perkins -
Joerg -
Jörg -
Paul Reed -
Skulski, Wojciech