-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add post on realms vs kernels #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+83
−0
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3a0e0a2
feat: add post on realms vs kernels
mvertes 373b251
Apply suggestions from code review
mvertes cf87369
Update posts/2025-05-12_kernel_realm/README.md
mvertes 253b3fa
Update posts/2025-05-12_kernel_realm/README.md
mvertes 99fe590
Edits for the post
michelleellen 9bc55d0
Apply suggestions from code review
mvertes 46b0d6c
Reformat paragraphs. No change of content
mvertes fa3719e
Apply suggestions from code review
mvertes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| publication_date: 2025-05-12T13:17:22Z | ||
| slug: kernel and realm | ||
| tags: [kernel, process, realm] | ||
| authors: [mvertes] | ||
| --- | ||
|
|
||
| # Gno realms vs system kernels | ||
|
|
||
| Let's explore the analogy between Gno and operating systems. | ||
|
|
||
| In computers, the role of the operating system is to isolate each process from | ||
| the others, for memory integrity and security, and to control access to | ||
| system resources, including time sharing access to the CPU. It also lets processes | ||
| communicate with others, or externally through the network. | ||
|
|
||
| The operating system provides those capabilities through the kernel, which | ||
| executes system calls. When invoked by a user process, the kernel switches the | ||
| CPU into a priviledged mode, to perform the services outside user reach. Each | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| resource located outside of the process private user memory must be manipulated | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| through system calls, under the strict supervision of the kernel, which acts as | ||
| a neutral trusted facilitator between untrusted processes. On bare metal | ||
| systems, this is enforced by the hardware itself. | ||
|
|
||
| Gno is a distributed multi-user virtual computer implemented on top of the | ||
| blockchain, so that every operation occurs in a deterministic way. User program | ||
| code and memory states are made tamper-proof by the use of merkle trees and | ||
| consensus-based verification, all provided by the underlying blockchain storage | ||
| layer, itself distributed. | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
|
|
||
| In Gno, the equivalent of computer processes are *realms*. Each realm is like an | ||
| always-active process, running forever, like for example a web server. In a | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| regular system, a live process is defined by its PID, its memory, and the set | ||
| of system resources it uses at a given time (files, connections, etc). | ||
| Similarly in Gno, a realm is defined by its identity (a unique crypto address), | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| its global memory state (the content of memory when the realm is at rest), | ||
| which may contain for example the amount of coins it retains. | ||
|
|
||
| A realm may provide services to other realms through the exported public | ||
| functions it declares, and it may use services provided by other realms by | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| importing another realm's functions and directly calling the other realm function | ||
| in its code. The way of declaring exported functions, and importing them is | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| exactly identical to the way that packages are defined in the Go language. A | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| realm is a Gno process, but is a also a package (in the Go sense). | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
|
|
||
| Functions in packages can be pure (in the functional programming sense: the | ||
| function has no side effect and operates only on temporary local variables | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| which are disgarded at return), or not: some variable outside of the function | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| scope is modified. In that case, the modified variable must be defined in the | ||
| same package as the function. Functions can only write global variables | ||
| declared inside their own package space (assuming variables are unexported), | ||
| and it is always enforced, as in Go, by static code analysis. | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
|
|
||
| But because realms are also stateful processes with their own identity and | ||
| protected space, and that a process can only write in its own space, calling a | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| non-pure function imported from another realm means that the caller realm would | ||
| attempt to write in the callee realm space, which is forbidden! | ||
|
|
||
| To resolve this, the current realm identity is switched from the caller to the | ||
| callee until the function returns, like when crossing the user-kernel boundary | ||
| in a regular system call. From the system point of view, the current realm is | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| set to the callee, the previous realm to the caller. At function return, the | ||
| current realm and previous realm are restored to their original value. | ||
|
|
||
| So non-pure exported functions act exactly like a system call: they provide the | ||
| ability to write outside the calling realm space, by crossing the realm | ||
| boundary. A realm doesn't need to trust a caller realm: only itself can write in | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| its own space. A realm doesn`t need to trust an external kernel: it is its own | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| kernel, it decides exactly how its data can be accessed and/or modified by | ||
| caller realms. | ||
|
|
||
| Gno unifies the concepts of Go package and Unix process in a single simple | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
| concept: the realm. The kernel is decentralized and put back in control of | ||
| package developers. The operating system itself becomes transparent: realm | ||
| processes are both resource users and providers, with full control and | ||
| accountability. | ||
|
|
||
| In Gno, programs are processes are packages are realms. | ||
|
mvertes marked this conversation as resolved.
Outdated
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.