-
Notifications
You must be signed in to change notification settings - Fork 3
Process Management #17
Comments
What kind of ABI are we going to use? Same as AtlasOS? |
I think we should abandon concepts such as an "assembler relocation table", because if the relocation table doesn't list a pointer which the program writes to, the entire system will fail over time. And also, the OS would have to scan through the program code before executing it to change the pointers to point to the virtual memory anyways, so can't it just detect when a program needs memory automatically? The only useful purpose of a relocation table on a 16-bit system would be to keep track of segments, but AtlasOS/2 doesn't use segments? |
@bungao: maybe more modular. one function for loading the process into a page, one for relocating it, one for creating the process list entry. system calls via interrupt, device access via file system. @VladVP: why not both. the automatic relocation has its restrictions. if you search the code for SET PC, 0xnnnn you may relocate data (when we are missing a data segment). A automatic relocation may work for short programs but not for more complex applications. Modern OSs still use relocation tables for libraries and ASR. Maybe we should use some kind of file header defining the application as self relocating, table relocatable or automatically relocatable. |
@noxer |
To me automatically scanning programs seems more likely to cause errors than a relocation table. at least a relocation table is pretty easy to create and use. |
@VladVP: :data Tell me how you find out you should relocate SET A, data and SET B, buffer but not SET C, 10... |
@bungao |
@noxer |
@VladVP: 1. Protip: The filthy HA hackes could simply enable interrupt queueing and wait for the DCPU to catch fire. @VladVP: 2. But the actual writing code may be part of the API and may run in the kernel or in a library. And what about self-modifing code? There is always a way around the relocation. The most secure way would be some kind of AtlasBASIC that is compiled on the DCPU where every memory access is checked. |
That is a completely unrelated security issue... what do the interrupt queuing vulnerability have to do with process management? If it's such a big problem, can't we just replace all IAS's with something that modifies something inside the actual interrupt handler which makes it jump to the place in VMEM which the program expects to be the interrupt handler? If the writing code is in the kernel or API, then the loader will know it, and if it's a part of a library, then what prevents the loader from scanning a function in the library? But self-modifying code sounds like a huge problem... how intelligent is the loader allowed to be? |
or we could use a relocation table since it works |
not always... |
example? |
@VladVP: My point was, that you can never ensure integrity when using pointers. We are unable to determine what is code and what is data (or what is data and will be code soon). We can make checks on OS functions if the addresses provided are valid but direct access will always be possible (we need some kind of memory management unit). My suggestion is to make the relocation modular. When parsing the file header the parser calls the matching relocation routine. Since most of the assemblers are able to generate a relocation table and it is the easiest approach we can implement it first. The automatich relocation includes the decoding of the DCPU bytecode which is more complicated. I would suggest coding this in C. |
@noxer: Well... then I guess we can have both...
I don't understand why you think it's that big of a deal... I mean all info we need about the DCPU-16 machine code is right here: |
that still doesn't get away from the fact that set a, label will be no different from set a, 0xabcd in the byte code. You would need to have a way to distinguish between the 2. A machine code decoder is just a disassembler, and unless you have debugging information as to what values are pointers and what values are just plain values, relocating code will be difficult. |
But it doesn't matter as long as the program doesn't use it as a pointer! |
that is my point. in your example SET A, 0x4d could be or not be a pointer to a data location within the program. If it is when you relocate the code you will have to offset 0x4d by some value. On the other hand 0x4d could be just a value used in some arithmatic or logic. SET A, label ADD A, 2 SET B, 0xcafe SET [A], B would set the memory location at label+2 to 0xcafe. now what if when compiled the memory location of 'label' was 0xcafe. The byte code for "set a, label" and "set b, 0xcafe" would be nearly identical 7C01 CAFE versus 7C21 CAFE.
Relocate the code? |
Wikipedia just explained to me how kernels like Linux and Windows NT handle self-modifying code. It's actually mighty simple 😆 Oh, well... but now that you've made me realize this issue... uhm... the part about relocation is probably the only issue... Offsetting of pointers can easily be detected by most smart program loaders. |
it not about winning and loosing. just what works. If you come up with a way of automatically relocating code that works then it would make sense to include it. |
It was meant with a rather comedic sense in mind 😉 |
Implement a process list and functions for loading, unloading and switching processes.
The text was updated successfully, but these errors were encountered: