💾 Archived View for yonado.cities.yesterweb.org › writings › 27.6.2024.gmi captured on 2024-08-18 at 17:01:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-07-08)

-=-=-=-=-=-=-

Operating System Model

In my previous post, I talked about some problems I personally had with the UNIX operating system model. The one that runs 80% of the internet.

Well, in this post I wanna suggest a possibly better model, one that can be incredibly flexible. Let's just get into it.

The operating system has 3 system calls.

1. Add new definition into the system

2. Execute definition from the system

3. Remove definition from the system

These definitions would be stored somewhere in memory, possibly restricted from the user to access, for security reasons.

The first system call defines a definition. What constitutes a definition is executable code. And, the definition NEEDS to be written in some kind of language. It can be in any language, but the best language is one that's made specifically for the system.

Here's an example. Suppose that our language of choice is assembly. All that system call 1 does is takes a pointer to a string of assembly code. It then goes through that and turns it into executable code in memory. After that it makes it available for execution and if there were any errors in the code, it does not compile the definition.

Let's say this was our code:

definition_name
	mov rax, 20
	mov rdi, 'a'
END

The "END" denotes the end of the definition. The definition name is stated at the beginning.

Now let's get into the second system call. The second system call would simply take a string to code in the language of choice, one that executes a definition and ONLY code that executes a definition.

For example if our language was entirely based on functions, this would be code to do a function call. If our language was assembly, this would just be the label name.

This is where the model shines. For example in interoperation with every single other thing in the system. If you had one definition that lists files in the current directory, and another that looks through text to find a certain string, you could combine these by doing something like this:

find(list_files(), "hello");

Again, this depends on the language of the system. The more powerful the language, the more powerful the system. For example assembly wouldn't be able to do this, but C would.

The third system call is the simplest one. It simply removes a definition from memory to free up some space. Nothing much to it.

Here's an x64 assembly example of how defining these things would work:

mov rax, 1 ; System call 1
mov rsi, code ; takes pointer to code in RSI
syscall

jmp $ ; infinite loop

code:
	db "void hello(void) {", 10
	db "	print("Hello");", 10,
	db "}", 0 ; END OF DEFINITION

An example of executing:

mov rax, 2
mov rsi, code
syscall

jmp $

code: db "hello();", 0

Removing:

mov rax, 3
mov rsi, name
syscall

jmp $

code: db "hello", 0 ; This is the definition name

If you have any remarks about this or if you make something using this model, I would love to know. Again, the power of the system depends on the language being used.

../