#EvalynOS

1 messages · Page 12 of 1

rotund furnace
#

🔥

hazy saddle
#

where is my disk based swap

hollow crater
hazy saddle
#

If you need disk based swap it’s a krill issue

hollow crater
#

understandable

rotund furnace
#

I swap all my memory to disk

#

I have 10 pages of phys mem

#

I swap them in and out of disk like ram banks

hazy saddle
#

And tries to use the least amount of physical memory possible

#

I also need to buy a raspberry pi 4b to start on a aarch64 port

hollow crater
hazy saddle
rotund furnace
#
  • 1 page for user code
  • 1 page for kernel code (int handler blah blah blah)
  • 1 page for kernel stack
  • 1 page for kernel stack (user)
  • 1 page for user stack
  • 2 pages for nvme queues
hollow crater
#

heap where

hazy saddle
#

Would prolly have to be x86-32

rotund furnace
#

hm

hazy saddle
#

Wait nvme

rotund furnace
#

7 pages

hazy saddle
#

How you gonna fit the driver in there

rotund furnace
#

I'm prob missing ALOT

rotund furnace
#

but I'mma say you need like

#

1k pages

#

comfortably

hazy saddle
#

what if you did a network driver

#

and called the kernel iRAMos

rotund furnace
#

the worlds slowest os

#

100% disk usage idling

hazy saddle
#

The i-RAM was a PCI card-mounted, battery-backed RAM disk that behaved and was marketed as a solid-state storage device. It was produced by Gigabyte and released in June 2005, at a time when genuine solid-state storage solutions were generally still less affordable than an i-RAM product with superficially similar capabilities. The i-RAM utilised...

hollow crater
rotund furnace
#

what/???

#

OH SHIT

#

the page tables them self

#

oof

hollow crater
#

segmentation my beloved

rotund furnace
#

you kinda need pages

hazy saddle
#

fuck segmentation

rotund furnace
#

to trap them

sterile plank
#

hows project going

rotund furnace
#

and swap them

hazy saddle
#

VMM rewrite is doneish

rotund furnace
hazy saddle
#

gonna do heap next

hollow crater
hazy saddle
#

then redo syscalls

#

add vmm_free()

hollow crater
hazy saddle
#

and then let things actualy free memory

#

and not leak

#

because user tasks cannot be stopped/unleaked

hollow crater
hollow crater
hazy saddle
#

Real hardware is a go

#

This laptop has 8gb ram

#

7700mb/8000mb is pretty good

#

That reserved includes my PFNdb

#

And shit

rotund furnace
#

can it run on 4gbs of ddr3

#

?

hazy saddle
#

It runs on a VM with 96MB

rotund furnace
#

oh lmao

hazy saddle
#

And runs doom or bad apple before OOMing

#

Because not enough for both

#

Boot times are WAY better now tho

#

1GB lost on deck

#

But IIRC it by default reserves a chunk for vram?

#

May be that

#

@rotund furnace Once I do RB tree VMM il split it into paging setup and then VMM setup

#

To be proper

#

And then VMM setup will be after heap

#

It handles a large amount of memory on my 32gb ram system

sterile plank
#

I like it

hazy saddle
#

@rotund furnace @sterile plank hows this

sterile plank
#

That's also cool

rotund furnace
#

cool

#

but

#

the wording is a bit cooked

sterile plank
#

Though I would move those magic numbers away

hazy saddle
#

yeah 💀

sterile plank
#

like 0x1, 0x2, etc etc

#

I know you're checking bits but still

#

it'd be nice y'know

rotund furnace
#

mines just dead ass

sterile plank
#

and make them 1 << n instead of numbers like that

rotund furnace
#
int page_protection_violation = ((frame->error & 0b00000001) > 0);
int write_access = ((frame->error & 0b00000010) > 0);
int user_mode = ((frame->error & 0b00000100) > 0);
int reserved_bit = ((frame->error & 0b00001000) > 0);
int instruction_fetch = ((frame->error & 0b00010000) > 0);
int protection_key = ((frame->error & 0b00100000) > 0);
int shadow_stack = ((frame->error & 0b01000000) > 0);
int sgx = ((frame->error & 0b0100000000000000) > 0);
printf("Page fault @ 0x%016llx [ppv=%d, write=%d, ring3=%d, resv=%d, fetch=%d, pk=%d, ss=%d, sgx=%d, wp=%d, smap=%d]", __read_cr2(), page_protection_violation, write_access, user_mode, reserved_bit, instruction_fetch, protection_key, shadow_stack, sgx, arch_get_wp(), arch_get_uap());
    ```
sterile plank
rotund furnace
sterile plank
#

both work

rotund furnace
#

this code was before I knew what a free list was

#

so it's ass

sterile plank
#

okay okay we all have coding styles 🙏

rotund furnace
#

??

#

no this code is ass

#

I agree

hazy saddle
rotund furnace
#

the compiler will const fold it

hazy saddle
#

yes

#

but its still CPU work

rotund furnace
#

oh well

hazy saddle
#

im being pedantic

#

this better?

rotund furnace
#

"write and accesed" 😭

hazy saddle
#

i swear englush is my first langyage

#

😭

rotund furnace
#

oh and

#

if it's an if

#

"Kernel process instruction fetch accesed a non-present page"

hazy saddle
#

im bad at templating

#

😭

#

is this better

rotund furnace
#

why not like

urban mulch
#

Here's how I do it

rotund furnace
#

"[User Process|Kernel] tried to [read|write|execute] a [non present|read only|no execute] page"

rotund furnace
#

well

#

oh well

#

¯_(ツ)_/¯

hazy saddle
#

whats the error bit for NX?

rotund furnace
#

User Process|Kernel Task|Kernel

rotund furnace
#

"instruction fetch"

hazy saddle
#

the wiki is arse then

urban mulch
#

UNHANDLED EXCEPTION [code]
Running in [kernel|user] mode
[Exception name]
(While accessing [address]
[No memory at this location|Memory at this location: [permission flags]])

rotund furnace
#

FUCK

#

no

#

bit

#

4

#

whoops

#

I misread my code

hazy saddle
#

then i also check if its not others

rotund furnace
#

I jkust like

#

        if(reserved_bit) {
            printf("Reserved bit in page table entry\n");
        } if(protection_key) {
            printf("Protection key violation\n");
        } else {
            const char* who = user_mode ? "User Process" : "Kernel";
            const char* access = write_access ? "write" : "read";
            if(instruction_fetch) {
                access = "execute";
            }
            const char* reason = page_protection_violation ? "non-writeable" : "non-present";
            
            if(instruction_fetch) {
                reason = "non-executable";
            }

            printf("%s tried to %s a %s page\n", who, access, reason);
        }```
hazy saddle
#

i dont use PKs

#

or SGX

rotund furnace
#

I don't

#

but like

#

might as well

#

¯_(ツ)_/¯

hazy saddle
#

@rotund furnace

rotund furnace
hazy saddle
#

also @viral bison @rotund furnace i finnaly finexed the nanoprintf stuff

#

ya happy

hazy saddle
#

@viral bison how is dis

#

@rotund furnace hows the new VMM

hazy saddle
#

Why do I feel like I am not cut out for this at all

#

I am looking at a bunch of the methods for IPC but I keep running into walls

cyan bison
#

just implement unix pipes and be done with it

#

man pipe.7

hazy saddle
#

Like for a VFS server

cyan bison
#

AF_UNIX sockets

#

man unix.7

hazy saddle
#

I guess I can implement the abstract namespace?

cyan bison
#

is this a microkernel?

hazy saddle
#

I’m looking into such as it seems like a good idea

cyan bison
#

maybe try shared memory

hazy saddle
#

Thing are still atleast somewhat meldable at the very least for me to change course

cyan bison
#

im no microkernel expert

hazy saddle
#

/dev/shm or something

#

My original plan was a hybrid kernel but if I could go micro it could be nice

#

Not sure how @rotund furnace Is handling it though

#

We were talking about IPC

#

But if I were to do it in a proper POSIX way I’m not sure

cyan bison
#

if u havent done a monolithic kernel before i probably wouldnt do a microkernel

hazy saddle
#

True

#

But I have some free time to do some research

#

I should just do sockets and shared memory

#

And pipes

#

Not too hard

cyan bison
#

so maybe dont look at posix for IPC for a microkernel

hazy saddle
#

What

hazy saddle
#

I don’t think POSIX was made for such?

cyan bison
#

yeh

hazy saddle
#

So managarm has a POSIX server to call for POSIX things and other things use the managarm spesific IPC methods

#

This makes a lot more sense on why I was banging my head on the wall and getting nothing

#

💀

hazy saddle
cyan bison
#

something like that yeah

hazy saddle
#

This makes a lot more sense

#

Hybrid kernel it is then for now 100%

#

I want to do POSIX and not bang my head on the wall

cyan bison
#

oki

hazy saddle
#

Thank you @cyan bison

cyan bison
#

np

cyan bison
#

or just have some drivers in userspace

#

hybrid kernel is an iffy term imo

hazy saddle
#

Some drivers userspace

#

Like nvme drivers would be userspace

cyan bison
#

interesting

hazy saddle
#

Or audio drivers userspace

cyan bison
#

i call my shit a hybrid kernel because it has kernel module loading

hazy saddle
#

But like serial or PS/2 would be kernel

#

Because it’s dead simple

#

IPC would be more kernel space and VFS stuff would be kernel space because although more complex it’s faster or somthing

#

And easier to implement

cyan bison
#

ok well gl, and hf

#

i need to go write USB code nooo

hazy saddle
#

How hard is usb?

cyan bison
#

hope that answers your question

hazy saddle
#

God damn

cyan bison
#

i might even need to fill that form out

#

when im done

hazy saddle
#

I feel like I have imposter syndrome idk yaaar

#

My friends tell me I’m smart

#

But I feel like a total fucking dumbass

cyan bison
#

u r tht's y

#

as in

#

u r smart

#

whenever i feel dumb i look at stupid questions asked in this server and think to myself "ok nvm"

hazy saddle
#

Do I ask stupid questions?

cyan bison
#

no

hazy saddle
#

Okay yeah

#

😭

#

Maybe I am a little smarter

#

Than I think

#

May also be because this server is filled with really smart people

cyan bison
#

indeed

#

also if u ever feel like giving up on this project
||obos accepts PRs||

hazy saddle
#

I don’t think a dumbass could get a kernel in this kind of working state. I just have some gaps I need to fill

cyan bison
#

indeed

hazy saddle
#

I’m too addicted to coding it

cyan bison
#

it took me 5 rewrites until i got to my state

hazy saddle
#

Even if it hurts my physical and mental well being

#

Can I show you my first “kernel” from 2024

#

I made a bit of progress after that

#

But uhhhh

#

Thing was a pile of shit and I never used git

#

In 2025 I then started this one proper

cyan bison
hazy saddle
#

Trueeeee

hazy saddle
#

This is where I started

#

And now I am here kinda

opaque marten
#

i've written worse code.

cyan bison
#

efi kernel goes hard

cyan bison
hazy saddle
cyan bison
#

indeed

hazy saddle
#

Once I get this kernel to a decent state with x11 and other ports

#

I may start a new one

hazy saddle
cyan bison
hazy saddle
#

Jokes on you I’ve already had 2 major refactors

cyan bison
#

jokes on you it took me 5 full rewrites before i was able to get bash working

hazy saddle
cyan bison
#

i thought i would get it to work on the third, for reference

hazy saddle
#

Well

#

One can hope

cyan bison
#

indeed

hazy saddle
#

I’m pretty close to getting there

#

Atleast to bash

soft snow
hazy saddle
#

Just needs fork exec and a few things?

#
  • IPC
cyan bison
#

bash doesnt technically need ipc

hazy saddle
#

And probably a filesystem rewrite

cyan bison
hazy saddle
soft snow
opaque marten
cyan bison
#

mainly

hazy saddle
cyan bison
#

pselect might be difficult depending on how your I/O system works

opaque marten
hazy saddle
#

Exec just replaces the current processes right

soft snow
opaque marten
cyan bison
#

fork makes a copy of the current thread/process

#

pselect waits for one or more FDs to have an event signaled

#

(i needed to redo my I/O system to get pselect to work btw)

hazy saddle
#

My kernel is pretty clean in terms of code. So worst case WORST case. It should be okay with some minor reworking

hazy saddle
#

I don’t have one

#

At all

cyan bison
#

if all your reads/write are synchronous

#

and you have no way to get them to not block

#

then you'll have to make some changes

#

OR

#

you could stub pselect

#

and that'll work until you port something that uses it properly

opaque marten
hazy saddle
cyan bison
#

but what you could do is:

  • have a poll function that you can call to tell if a read/write would block
  • add a nonblocking and dry_operation argument to the read/write function
opaque marten
#

so my exec just spawns a new thread in the current process and does some other stuff, and before i added pthreads that was fine because there were no other threads i needed to kill, but i realized that rn if a process has multiple threads and a thread execs the other threads will continue running

hazy saddle
#

What’s an IRP

cyan bison
#

I/O request packet

opaque marten
#

although its an uncommon case because usually they fork so they're left with one running thread, its a possibility

hazy saddle
#

I only have in ram filesystems

#

So I’m not sure how that would work?

hazy saddle
cyan bison
#

if a read/write is non-blocking that means it will never block, and return an error code like EWOULDBLOCK if the operation would block

#

the dry_operation means that the function shouldn't actually do a read or a write, just if the function would return an error

hazy saddle
#

What does blocking mean exactly

cyan bison
#

if a syscall blocks it means that the thread will get suspended until something else wakes it (either because the syscall finished and the driver told it to wake up, or a signal interrupted it)

hollow crater
hazy saddle
#

Actualy I’m not sure how I’d making somthing block

#

If I call that

#

I assume that it would return back to where it left off?

#

After running it

#

@hollow crater my FDs are actually so fucking jank btw

#

The FD contains a pointer to the file data

#

And I malloc a part for it

#

And then copy the entire file there

hollow crater
#

im reporting this to the Unix police trl

opaque marten
rotund furnace
#

?????

#

the whole point of file descriptors is to not do that 😭

hollow crater
# hazy saddle Actualy I’m not sure how I’d making somthing block

well afaik a sleeping thread is supposed to be able to wait on some event
like u put it on a wait queue
and when that event signals completion
say a mutex, shared resource, driver event etc
the threads waiting for them are then put on ready queues for running
and they just get scheduled as normal (u restore the execution context and continue execution from there)

rotund furnace
#

yeah

#

I just have a sys_wait syscall

#

and the thread will block until one of any handle(s) passed in recv some data

#

everything else returns SUCCESS or WOULD_BLOCK

hollow crater
hazy saddle
soft snow
#

not even me i have such a stupid impl

#

or well mine is not even per proc and trash so maybe i shouldnt say anything lol

soft snow
#

its the worst part of my whole OS

#

100%

hazy saddle
#

How AM I meant to do file descriptors

#

They link to inodes or some shit

#

And then that’s part of the backing filesystem?

hazy saddle
#

But I memcpy it instead

rotund furnace
#

I just map it read only in the process

hazy saddle
#

Yes but posix needs read() semantics proper

#

And apps want that

#

Or somthing like that

#

I could probably have it assign inodes to files

#

And then open() gives then to make a real FD

#

And then read and write gets managed in the back end there?

soft snow
# hazy saddle And then that’s part of the backing filesystem?

I just have a struct with all file descriptors and then when you open smth I assign proc->fds[next_fd()] = file. Then returns next fd to the user and whenever the user does any file op you just access the obj with proc->fds[fd]. Its prob a stupid solution but ye

#

I feel like that is the best approach for me.

#

The fd itself is just a number that responds to the place in the list

hazy saddle
#

FDs start at 0

soft snow
hazy saddle
#

for one these

#

and these need to be per proc to be redirected

soft snow
#

next_fd accounts for them

coarse oasis
#

does it work correctly if you do this? ```c
int fd = open("/path/to/file", O_RDWR);
close(0);
close(1);
close(2);
dup(fd);
dup(fd);
dup(fd);

soft snow
#

So when you open smth I will have a switch statement for them lol.

coarse oasis
#

because this is a valid way to set stdout/in/err per posix

soft snow
#

Ehmm

coarse oasis
soft snow
#

Okay might need to reconsider my approach then.

#

Maybe preallocate them from the start?

hazy saddle
#

do FDs have to go into the lowest posible slot always?

cyan bison
#

yes

soft snow
#

All processes start with 0, 1, 2 allocated, and then everything works as normal.

cyan bison
hazy saddle
cyan bison
#

((but im sure it's fine))

hazy saddle
cyan bison
#

if i knew, i would be doing it trl

soft snow
hazy saddle
#

maybe an RB tree is good @rotund furnace

soft snow
#

Ehh optimizing is a prob for the future won't bother me rn.

hazy saddle
soft snow
#

Ik

rotund furnace
#

why tho?

hazy saddle
#

wait

coarse oasis
#

also also, regarding fds, keep in mind you need two layers

hazy saddle
#

cant you keep track of the lowest FD you last freed @soft snow ?

hazy saddle
#

then check the nexr FD slot if its filled

#

and keep track of that too

coarse oasis
# soft snow Huh?

in the first example i sent, stdout and stderr are different file descriptors but they refer to the same file description (which then refers to the same vnode)

rotund furnace
#

ehhhhhhhh

#

sorta

#

you'd not really save mucH

#

sure it's better

#

but like

coarse oasis
#

the file description contains things like the seek position

coarse oasis
#

the descriptor has stuff like CLOEXEC flags etc

coarse oasis
# soft snow Okay, does that matter?

yes, consider my_program 2>&1 >log on the shell, if my_program writes to stdout and then stderr, if the seek position is per descriptor and not description the second write would corrupt the data written by the first

soft snow
coarse oasis
#

so it can't be a part of the vnode

#

and it can't be a part of the file descriptor

#

so you need a layer in-between

soft snow
#

How can file descriptors be so complex.

#

Its just a array of structs omg.

hazy saddle
#

whats the max size of said array

soft snow
hazy saddle
#

is it a dynamic one?

soft snow
coarse oasis
soft snow
#

I have to rework it tmrw

hazy saddle
coarse oasis
#

file descriptions are not bound to a process

#

if i open and then fork, both processes point to the same file description

hazy saddle
#

So would they be global? And newly created for open() calls?

#

Or rather duplicated per thread spawned by a program on fork()

coarse oasis
#

yeah open et al produces a new one

hazy saddle
#

So FD points to a FDR which points to inode or whatever other backing for it

FD has basic info
FDR has the seek and pos info etc
fork() duplicates FDs and FDRs

coarse oasis
#

fork does not duplicate FDRs

hazy saddle
#

Oh right

#

FDRs would be global for the kernel?

coarse oasis
#

consider a program that forks to execute a subprocess to do something (e.g. make)

hazy saddle
#

And FDs just point there

coarse oasis
#

if i run make >log i want the logs from both make and all the subprocesses to go into the file and for them to not clobber eachother

#

which requires the seek position be shared for all of them

coarse oasis
hazy saddle
#

And then I can ref count it based on FDs that point to it

#

And then free() it after

#

For inodes could I have a union type based on the diffrent backends it could have

#

Like if it’s to a tarFS or some such

#

Or if it’s a devFS like file

#

And then they implement an open() internally that gives the inode to make the FDR to make the FD

coarse oasis
hazy saddle
#

That’s what I thought an inode was

coarse oasis
#

inode refers to the on-disk part

hazy saddle
#

So I would have vnodes that have those pointers and then a pointer to impl data that the impl can use which may be an inode

#

Or some other

coarse oasis
hazy saddle
#

Mmm good good

#

I think I get it now

#

And vnodes would store like file paths right

#

And other data needed

#

Maybe under implementation specific data or some such

coarse oasis
#

no, i/v nodes do not know the file name or parent

#

because consider a hard link, a i/v node can exist under multiple names in a file system

hazy saddle
#

What holds the name of it for like LSing etc

#

Well open() would dig its way back to the filesystem

#

And I guess so would ls()

#

So that’s irrelevant from the sense of i/v nodes

coarse oasis
#

which you read out of a node

#

(well not literally read, but readdir or whatever)

hazy saddle
#

The inode carries that I presume and an inode can connect to a directory too

#

And that’s part of the filesystem

#

And tarfs afaik lacks that?

coarse oasis
#

directories have inodes too

#

and yes tar does not make a distinction

#

i think the best way to use a tar for an initramfs is to unpack it into a tmpfs and discard the tar archive?

hazy saddle
#

It may be good to make a tmpfs that gets filled in by a tar file to get proper

#

Yup yup

hazy saddle
#

Or even gzipd ones

coarse oasis
coarse oasis
hazy saddle
#

I would probably use realloc for writing to a file when it seeks beyond it right?

#

But then i can implement a “real” filesystem

#

And then that can help me get proper things going

#

In terms of a VFS etc

coarse oasis
#

for mmap etc

#

but yeah on write past the current storage you'd just tack on another data page to the node

hazy saddle
#

I could probably use the buddy allocator for this directory too with powers of two

coarse oasis
#

i mean realloc from kernel heap doesn't work

hazy saddle
#

And then HHDM

coarse oasis
#

since mmap maps the file backing store directly into the user's address space

hazy saddle
#

Oh yeah

#

So I’d want to get from the PMM and then map into other virtual address space

hazy saddle
cyan bison
#

my initrd driver does this

coarse oasis
#

i mean can your kernel heap allocator guarantee the returned memory is page aligned

cyan bison
hazy saddle
hazy saddle
#

@peak cloak

#

Do you have a machine with an Intel core ultra on it?

peak cloak
#

WHUAT

peak cloak
#

i have a uhhhh core 2 duo

hazy saddle
#

Damn

#

Uhhh shit try that I wana see how it reacts to it

peak cloak
#

i have an i7 but i dont wanna do any crap with it

peak cloak
#

compatibility trl

hazy saddle
#

I’m tring to get samples on hardware compat anyways

peak cloak
#

do you want me to do a CD or USB or whatever

hazy saddle
#

And maybe it will repro this bug

#

Shit try a CD

#

Would be cool

peak cloak
#

bruhhhhhhhhhhhhh

#

aight

hazy saddle
peak cloak
#

mk

#

whats your os's reaction if a cd cant be read

hazy saddle
#

That would be up to liminen

peak cloak
#

no iso9660??

hazy saddle
#

Oh it uses that

peak cloak
#

ok im gonna go get my 2006 macbook to write the cd

peak cloak
#

EVIL os of doom or limone

hazy saddle
#

The ISO file

peak cloak
#

oh

hazy saddle
#

Even on a USB

#

It’s that filesystem

peak cloak
#

WHAT

hazy saddle
#

Yes

peak cloak
#

holy incompatibility

#

do you have drivers for iso9660

hazy saddle
#

I don’t need drivers for that

#

I don’t read from my own ISO

peak cloak
hazy saddle
#

I read from the initramFS

peak cloak
#

oh

hazy saddle
#

Which is a tar file

rotund furnace
#

limine does

peak cloak
#

limonr

#

lomine

#

@hazy saddle what hard drive mode do you want me to set IDE or SATA

#

i assume ide nobody does sata nooo

#

(or theres just no hard drive drivers at all)

rotund furnace
#

no disk drivers

peak cloak
#

booo

#

crappy os where's my scsi pain

#

ok understandable

hazy saddle
peak cloak
#

does the iso have the doom and bad apple combo

rotund furnace
#

when I do vfs and nvme you can steal from me :P

hazy saddle
#

Also blame @devout path for no disk drivers they promised sata and ext2 PSP1G_pspTrollar

rotund furnace
#

who does it first tho is debatable

peak cloak
#

o my disc burned

hazy saddle
#

I’m gonna be doing my systemcall rework tomorrow

peak cloak
#

nevermind the burn failed

hazy saddle
#

And then probably VFS or heap

#

But the heap although from the other fellow

#

Isn’t so bad

#

So

#

Il leave it

#

I need a better VFS

peak cloak
#

@hazy saddle the burn failed im gonna use a different cd drive

peak cloak
#

never trust 2006 macbook

hazy saddle
#

But yes it includes shareware doom and bad apple

peak cloak
#

doom shartware

hazy saddle
#

You have to compile yourself if you want full game

#

But it works

peak cloak
#

tfw it works

#

ok so the mac drive blanked out the cd

#

then died 😔

hazy saddle
peak cloak
#

k it says the burn went ok

#

never trust mac os

#

also if your fart does EFI boot i have another macbook i can test it on

hazy saddle
#

It does BIOS and UEFI

#

All one ISO

peak cloak
#

shameless plug trl

hazy saddle
#

Now run the bad apple

peak cloak
#

how

hazy saddle
#

BADAPPLE

#

And

#

DOOM

hazy saddle
#

It’s a debug command entered

peak cloak
#

its a sh-

hazy saddle
#

That’s why I’m not adding any of that fluff shit

peak cloak
hazy saddle
#

Like this is what you have

#

It’s shit to test the kernel

#

Not pretending to be a shell even if it’s called that

#

And I renamed it in other places

peak cloak
#

tfw

#

im gonna restart for higher resolution

#

ew 1280x720 trl

hazy saddle
#

That’s the default res

peak cloak
#

set it to 1440 by 900

#

laptop resolution

#

ok its still alive

#

brb

#

i guillotined it for being too loud trl

#

i also humbly apologize for breathing louder than a nuclear bomb

#

im gonna go run doom

#

i have doom video but its compressing

#

lel

hazy saddle
#

If you prove to me you own it i will just compile one with it in for you tho

hazy saddle
peak cloak
#

magnificentn't visual effects

#

to be fair i typed the resolution wrong

#

oops 😔

rotund furnace
#

poor keyboard

peak cloak
#

its the laptop keyboard somehow

#

its insanely good for no reason

peak cloak
#

BUGS BUSG(OSIUFG S(OIUBUGSIOU BUGS GBUGS BUGSUG BUGSUGB

#

BUGS

#

BUGSSS

hazy saddle
#

That’s intended

peak cloak
#

what

hazy saddle
#

If your monitor isn’t big enough

peak cloak
hazy saddle
#

And all BIOS systems can’t properly set the resolutions

peak cloak
#

how big is my monitor SUPPOSED to be

hazy saddle
#

720p 16:9 or bigger

peak cloak
#

ight

#

werks

#

can i do a shameless plug for my service trl

#

nevermind im too ashamed to do a plug depresse

rotund furnace
peak cloak
hazy saddle
#

@peak cloak il do it for you

#

Kvass is best kernel

peak cloak
#

LETS GOOOOOOOOOOO letsgo

#

anyway understandable

#

nice kernel

#

evalyn os best kernel with best vfs

hazy saddle
#

I do think i need a code name for my kennel

#

Something cool

#

What about nova

#

That’s not taken right

#

That’s name name of one of my dogs

peak cloak
# peak cloak evalyn os best kernel with best vfs

it has a very interesting backstory it it was an unholy abomination but then it became unholier abomination and now it sucks but it doesnt suck because it cant suck because it's 1984 and opinions are bad trl

hazy saddle
peak cloak
#

(my worst enemy)

hazy saddle
#

But I’m gonna fix it

peak cloak
#

"i can fix her!!!"

hazy saddle
#

No but like

#

This is code

#

I can just program it proper

mortal bane
peak cloak
hollow crater
#

so

#

just for the fd numbers btw

#

and in order to still support arbitrary number of fds

#

I might do
a dynamic list of bitmaps x free range nodes™

#

one nice convenience of bitmaps is that u can always allocate the lower most set bit by bitwise tricks
similar to how kernighan's popcount works
bit field & bitfield - 1 zeros the lower most bit (allocates the lowest bit)
then __builtin_ctzl the original field value and get the index of that bit trl
(u can also rely on better specialised instructions for bit scanning when possible anyway)

  • width * field index and thats the index into the bitmap
    all are cheap af™ operation so its so fastt
#

but we all know bitmaps are still expensive
like
for a cap of 10k fds (whichs pretty sane for real world installations, afaik)
u will have to have about 1/3rd of a page per process

#

enters the chaining part

#

so say bitmaps will be allocated as blocks of some arbitrary but fixed size
say
64 bytes

#

each block can start with an intrusive list node and some flag bit to indicate whether this is a range node or a bitmap node

#

a range node just has 2 fields for start and limit

#

and it describes a range of free fd numbers

#

since we are always allocating the lowest free index the range here can be arbitrarily set (and ig for most unixes put there thats actually the case o_O)

#

now for a process u can start with one bitmap node describing range from 0-511
then followed by a free range node describing 511-maxcap
when the bitmap gets full it can then carve out 512 fdns from the range node amd insert the new bitmap in between the used up bitmap node and the free range node

#

now as used up and freed up bitmap nodes accumilate they will sure make traversal slower

soft snow
#

ehmm

#

might be a bit complex for my taste

mortal bane
#

holy walls of nerdly text 🤓

hollow crater
#

but u can coalesce them
both totally used and totally free ones
since upper free nodes wont ever get used again until the lowermost free index is used this woukdnt incur much penalty
and but it might be a little more expensive freeing an fd index when its block was coalesced into a used range blob
so im not sure if coalescing contiguous used ranges is worth it (actually I think it is o_O, and u can minimize the extra overhead here by backing this by 2 object caches instead of one lel, one for free bitmap blocks (initialised to all 0), and another for full ones (initialised to 1s) so that its cheap to allocate for either cases, also obviously a third for the range nodes too maybe)
now checking if a bitmap is used up is relatively cheap
and u can always set up a flag for making it even cheaper
and the list wont get too long mostly due to fragmentation bc of the nature of fds (we always allocate lowermost bits, whichs also why i believe multiple specialised lists arent strictly necessary and might even be bad)

#

tho pathological patterns would still be there

#

but despite that
a 1kB overhead and 100 iterations as an upper boundary for handling 10k dispersed fdns doesnt seem that terrible as a worst case

for some other numbers like pids tho, just increment a u64 and call it a day trl

hollow crater
hollow crater
soft snow
#

wall of text = hard impl

hollow crater
#

u can always still use some general purpose allocator here still
cc vmem trl
but I believe vmem would be an overkill for such scenario

hollow crater
#

this shit is also very similar to my nalloc (naive allocator) thingy
it doesnt rely on bitmaps tho only specialised lists of range nodes

hollow crater
# hollow crater but despite that a 1kB overhead and 100 iterations as an upper boundary for hand...

also just for fun I could also have a version where i can also allocate and search for contiguous sequences trl
tho I could only have that without having an significant extra penalty by capping the maximum requested sequence to 64 :P
fdn allocators dont have to support that anyway but it was kinda fun thing to do

thats all for the number allocator tho
first time ever hearing about the multilayer thingy 💀
also nice convo on fds, vfs and memory mapped files overall ✨

#

so
til

hazy saddle
#

But basicsly @hollow crater a linked list of bitmaps?

#

Honestly N is so low it’s not that bad tbh?

#

And you skip many many sections

#

Though using a similar allocator to vmalloc with an RBtrrr isn’t a bad idea PSP1G_pspTrollar

hollow crater
hollow crater
#

u always allocate units of 1 per allocation

#

oh wait u mean the bitmap blocks thingy

#

if so then yea
although

#

say we have someone cap their fdns to 10k

#

then u have around 1kB maximum
which is about 20 nodes or so

#

so I think an rb tree there wouldnt be that much better than the proposed list 💀

#

due to the overhead of balancing etc when its just 20 nodes maximum

#

mind that a program usually uses MUUUUCH less than 10k fds

#

so i dont think an rbt is worth it here

hazy saddle
#

Also @hollow crater i wonder for my tmpfs if i should just make an ext2 driver in memory

#

Or make my own simpler filesystem

#

But one that uses like linked lists for blocks of files

#

So I don’t need contiguous memory

hollow crater
#

well just very little trl

hazy saddle
hollow crater
hazy saddle
#

I think il make my own filesystem for that

#

Il call it llfs

#

Linked list filesystem

hollow crater
#

sounds cool
and on memory filesystems should be simpler afaik so
kewl

hazy saddle
#

There is a linked list of all the files and directories and special files etc

#

And then they have a pointer to a linked list of all the blocks

#

And then the blocks store all the data

hollow crater
hazy saddle
#

This will be kinda shit

#

Wait where do I know where to store things and what blocks are free

#

I could do a free list but like then I can run out of space

#

Every block could have a header with info

#

And then I scan blocks for free ones?

#

@soft snow How did you do your tmpfs

hollow crater
hazy saddle
#

I am lazy

#

Very fucking lazy

hollow crater
#

understandable pain

hazy saddle
#

And I must get away with the least effort possible

#

Why do you think I stole my friends VMM and PMM even though it was so shit

#

Look at the difference between my impl and the old one

hollow crater
hollow crater
hazy saddle
hollow crater
hazy saddle
#

Lowkey I am gonna have to do a huge rewrite for SMP anyways partly too

#

Soooo

#

I’m putting that off until my bash port PSP1G_pspTrollar

hazy saddle
#

And then disk drivers are beta2

#

And x11 is beta3 until it gets stable enough for a 1.0

hollow crater
hollow crater
soft snow
hazy saddle
hollow crater
hazy saddle
#

And I will be doing usb 2.0 and 3.0 controllers

hazy saddle
hollow crater
hazy saddle
#

Wait couldn’t I have the fs spesific data for the vnode contain the linked list of blocks?

#

That way it’s seperate from the system and its easier?

#

Then I just append to that list

hollow crater
hazy saddle
#

I don’t do much C userspace shit

#

Or rather stuff that uses the c standard library much

#

I did do a rv32i emulator in C

#

Anything touching the C standard library is a fucking mess that I used AI and made sure it worked because I’m fucking lazy as shit

#

And partly same for my uservice project

hazy saddle
hollow crater
# hazy saddle I don’t do much C userspace shit

ive actually had very little experience doing userspace at all pain
i did very little python and cpp
well some java for school too but eh
ive mostly read in embedded/systems dev more
not that any of this amounts to much anyway trl

hazy saddle
#

But making device drivers for the timer was annoying

hazy saddle
hollow crater
hazy saddle
#

And I like made sure it worked 🥀

#

And validated the code 🥀

hollow crater
#

fair

#

🥀

hazy saddle
#

AI is a tool and you gotta use it right

#

It was nice for a shit ton of boiler plate too

hazy saddle
hollow crater
hazy saddle
#

I do not use it unless I want to

#

That’s why I use Linux

#

And that shit stays in its own tab

#

And not in my fucking IDE

#

🤮

#

And I barely even open it tbh

hazy saddle
#

I wana make sure I’m not being dumb when doing this

hollow crater
hazy saddle
#

KATE4LIFE

hollow crater
hazy saddle
#

And in that fs specific data I could store said linked list about the blocks

hazy saddle
#

So I can MMAP them properly too

#

@hollow crater smart right PSP1G_pspTrollar

gentle void
hazy saddle
hollow crater
gentle void
#

idk the lsp is doing funny things

hazy saddle
#

There is only one minor annoyance I have but I work around it once

hazy saddle
gentle void
#

and rust analyzer

hazy saddle
#

PSP1G_pspTrollar yeah that shits a bitch and you have to have a global config file for the LSP

#

And I have to swap it in and out

#

Idk what else I’m meant to do

cyan bison
#

i used Kate once upon a time it was interesting

hazy saddle
#

And I had to give it absolute paths

cyan bison
gentle void
#

i mean I've also used eclipse for C before

#

i should probably just use helix tho

hazy saddle
cyan bison
#

oh

gentle void
#

i wanna get quick at using helix/vim but it has such a high learning curve for advanced shit

hazy saddle
#

The vnode file system spesific data may be info for the file system to get the inode

#

The vnode is the kernels inode for the VFS

#

And my tmpfs may just not have the concept of an inode for this and handle it a bit differently

#

Like a hard link may just make two vnodes point to the same FSspesific data

#

Though I don’t need hard links or symlinks for this rn prolly

hollow crater
#

ohhhhhhh
i think i get it :P

hazy saddle
#

FD points to an FDR which has the seen data which points to a vnode

#

The vnode has the function pointers and a payload of data for the VFS etc

#

This way many FDs can point to the same file and work properly

#

And the FD handles information like if it was opened as RO etc

hollow crater
#

ye i get that part
i was confused about the role of vnodes overall and how it interfaces with the underlying interfaces (fs/devices/sockets etc etc)

hazy saddle
#

Also wait this system is so much fucking smarter

#

Because I don’t need to O(N) search though everything

#

It’s o(1) with this

#

Because they all know the node they point to after opening etc

peak cloak
hazy saddle
#

But I like making myself fucking pissed off and wasting my time

peak cloak
hazy saddle
#

I’m not that insane

peak cloak
#

well i was

#

MUAHAHAHAHAHAHAHHAAHAHAHHAHAHAHA

#

it sucks

mortal bane
#

reddit give you more accurate data than any AI

#

fr fact

peak cloak
#

actually no there its just "possible repeat of ..."

mortal bane
#

r/osdev trl

mortal bane
#

a

peak cloak
mortal bane
#

got me "bomboozled"

hazy saddle
mortal bane
#

and have 180IQ

hazy saddle
#

finnaly time to get back to work

#

i do wonder for the VFS how i should route open() calls

#

i could have filesystems have a registered prefix?

#

and if the prefix matches it goes there

#

ans then chroot could be as simple as moving/swapping prefixes

soft snow
#

and then open just calls openat with NULL

#

to signal root

#

or cwd

hazy saddle
#

but what if you want /dev or /mnt/usb or somthing

soft snow
#

openat("/dev/", "tty0") also works fine

hazy saddle
#

i mean for many filesystem types mounted on the system

#

my devfs may not be the same as tarfs

#

or procfs

soft snow
#

so close("/dev/tty0") will do node_tty0->close();

hazy saddle
#

but open() needs to get the node

soft snow
#

and all fs nodes will still need to register with the main fs.

#

or vfs

hazy saddle
#

so devfs could register under /dev
then open("/dev/ps2/kbd") will goto devfs->open()

#

that way they manage thier nodes under thier belt

soft snow
#

i didnt do it like that

hazy saddle
#

i mean all filesystems could register all files to the one registry

#

that way open() knows where to go

#

and not need that extra inderecrtion?

#

thats what i do rn anyways with a linked list

mortal bane
#

some VFS stuff i see

mortal bane
hazy saddle
#

rn is syscall rework but that has some CFS stuff

#

this is super not POSIX

#

im just gonna organize these

#

so the swicth case just calls a function

mortal bane
hazy saddle
#

and a NOP works

#

but i forgot about blocks PSP1G_pspTrollar

#

{}

hazy saddle
#

my rv32i emulator just uses blocks instead of stupid add nops

hazy saddle
mortal bane
#

i see

hazy saddle
#

so i just slapped a bandaid to make my IDE stfu

mortal bane
#

or just restart intellisense true

hazy saddle
#

i mean it is technicaly an issue PSP1G_pspTrollar

urban mulch
hazy saddle
#

i was dumb when making that

#

lmfao

urban mulch
hazy saddle
#

i am 100% gonna need a /dev/fb to MMAP on later

#

i wonder how id implement that through VFS?

#

because these can 100% become MMAP and an IOCTL later

rancid viper
#

just do case x: {} ??

hazy saddle
#

yes yes i know now

#

im redoing this lmfao

rancid viper
#

besides why are ur LSP flags mistmatched to what you compile with

#

just fix that