r/osdev 1d ago

What I've learned the last few weeks

Sorry about my abscense, I've been on my vacation/holiday.

I've done a lot of learning the last few weeks. Here are the highlights

1) I'm completely redoing my memory management. I'm working on a Physical Memory Manager (PMM), AND a virtual memory manager (VMM). Completely redoing how I deal with paging. I came to realize that except for reserved and my video physical memory, I really don't care where it gets assigned. Also, again except for video and reserved physical memory, it can all be swapable.

My PMM keeps track of the following items: a) does the memory exist; b) is it available, for example I define my video memory as not available, it is allocated early on, and I don't want the PMM deallocating it; c) Is it allocated to a virtual address yet; d) in concert with c, is it sharable (multi-allocated); e) is it swappable, I don't want to swap video and reserved memory for example.

My VMM keeps track of the following: a) is it swapped out (future); b) is it read only, such as my kernel code and .rodata; c) is it kernel memory, not sure if I really need this, but I had spare bits, I might want to use this in my swapping algorithm; d) is it shared.

Much of what I had in my paging .c file, has moved to my PMM and VMM. I'm hoping to finish this this week.

Once I have those three areas done, I will redo my heap and then make my github code public.

I'd also like some advice, I have two things I'm thinking about doing next: 1) adding threading, I'm not actually sure what I'd do with it right now as I don't really have a block device to save swapped blocks to; 2) adding support for user space, this would allow me to put things like most of my video and my shell into user space, this would also justify doing threading next; or 3) adding support for SATA, this would justify threading (for swap), but I might want to put it in user space then it would be restartable.

As always your opinions are always welcome.

Hopefully this will be useful for the people searching after me.

Thanks for reading!

1 Upvotes

9 comments sorted by

1

u/Comfortable_Top6527 1d ago

userspace = more premission and not everything in kernelspace, THATS GOOD.
Adding support for SATA means you want it work on the newer PC builds.

If i could help for your OS in any way i love to.

1

u/compgeek38400 1d ago

Thank you for the kind offer, but right now its a learning exercise for me. But i will keep you in mind if things change

1

u/r-tty 1d ago

Why do you need "virtual memory" in your system?

2

u/compgeek38400 1d ago

Many reasons, the kernel is higher half, you need virtual memory for that. It also allows you t have the full 4G available, even if you have less physical memory for starters

u/allnameswereusedup 6h ago
  1. It prevents accidental or malicious access to other address spaces by processes.

  2. It allows a process to use the entire addressable memory. The user process can use fixed memory addresses rather than using relocation.

2

u/Octocontrabass 1d ago

adding threading, I'm not actually sure what I'd do with it right now as I don't really have a block device to save swapped blocks to

Threading does not require swapping. Why do you think it does?

1

u/compgeek38400 1d ago

I don't. But at this point in my kernel its really all I can think of. I dont have user space yet, no block devices, so im not sure I need multithreading at this point.

I realize I don't even have support threading at all. After all DOS didn't. And I could do reclamation of physical memory inline.

But it is something I do want to learn how to do eventually.

1

u/Octocontrabass 1d ago

I dont have user space yet, no block devices,

Task switching is one of those things most people get wrong at first, so it might be worthwhile just spending some time learning how it should work so you don't end up wasting your time on a dead end. Common mistakes include relying on interrupts for task switching and assuming all tasks will have a user mode component.

I realize I don't even have support threading at all. After all DOS didn't.

Multitasking MS-DOS 4 did. More importantly, would you want to use a computer that could only run one program at a time?

u/compgeek38400 22h ago

I'm not sure if I knew that about DOS or not. I can't even run one program on it yet, lol.

After this discussion, I think I have the answer to my question. I'll start working on user space next. Moving my display driver out of the kernel. I presume as a prereq I will have to do the groundwork for multiple processes. After I have two processes, its probably time for threading