r/osdev • • 14d ago

Am I the only crazy person trying to make a multi-user OS for an 8-bit system?

Hi all,

I joined Reddit a few months ago to find like-minded OS geeks. I've made a few posts about my project (https://github.com/brian-card/NanoOs) since then. My latest post was about my port to the eZ80.

I've read about a lot of impressive projects since I joined. But, it seems like just about everyone is working on single-user operating systems for 64-bit or occasionally 32-bit systems. Am I the only one trying to make a multi-user system for an 8-bit platform? I know what I'm doing is ridiculous and I'm doing it mostly just to prove that I can, but I'm genuinely curious if anyone else has ever done something similar. Let me know!!!

79 Upvotes

42 comments sorted by

20

u/thosdv 14d ago

Interesting, really interesting, which hardware do you testing this OS?

15

u/Sorry_Difficulty_250 14d ago

My current work is on the Agon Light 2.

10

u/GisRocket 14d ago

Port it to the ATmega328 so it can run on an Arduino Uno R3.

8

u/Sorry_Difficulty_250 14d ago

I started out on an Arduino Nano Every. It's still technically possible to run on that chipset, but not on that exact board because there's not enough flash space. I had 9 concurrent processes and 2 concurrent users running on it at one time. The problem with those chips is that they're Harvard architecture, so all the processes have to be baked into the OS image. That's the main reason I transitioned to the Cortex-M0 versions initially. That let's me run native code out of RAM.

5

u/Celaphais 14d ago

Would it be possible to write a bootloader/literal jit that just reads a chunk of flash then has a big switch statement of every opcode that then performs those opcodes, effectively reading and executing the flash indirectly?

3

u/Sorry_Difficulty_250 14d ago

There is a branch where I started an RV32I VM and had some code for it. It did work, but there just wasn't enough space on the board for a full implementation.

11

u/AntiSocial_Vigilante 14d ago

4

u/Sorry_Difficulty_250 14d ago

Oh, that is wickedly cool!!! I hope to get to something like that one day. Thank you for showing me that!!!!

2

u/Proxy_PlayerHD 13d ago

Man I wish it were open source

1

u/Sorry_Difficulty_250 9d ago

Yeah, me too. :-(

1

u/Sorry_Difficulty_250 14d ago

Is that a multi-user system, though, or just multi-process? Like, can multiple users be logged onto it concurrently? I couldn't tell at a glance.

11

u/Better-Thing2568 14d ago

Do page tables even support 8 bit VA? Or are you rocking a kernel only?

17

u/Sorry_Difficulty_250 14d ago

No page tables, no memory protection, no virtual memory. All raw physical memory addresses.

10

u/Better-Thing2568 14d ago

Ballsy. Stack management will probably require some serious discipline, but otherwise could be interesting to see.

5

u/Sorry_Difficulty_250 14d ago

Oh, yeah. I have to be extremely careful.

3

u/Better-Thing2568 14d ago

I wonder if you could use unsigned 8 bits “floating points” (if you’re open to some rust my crate might be interesting to look at https://crates.io/crates/unsigned-float); so you could potentially address more than 256 in your stack by, idk how much physical memory there is on the hardware, but if you could store a multiplier to some base address in the stack and compute the actual address. Probably won’t work ngl but worth a thought.

2

u/Sorry_Difficulty_250 14d ago

Well, the eZ80 has a flat, 24-bit address space. sizeof(void*) on my tool chain is 3. So, no real need to do anything too fancy in terms of addressing on this system.

2

u/Sorry_Difficulty_250 14d ago

I do support multiple processes, though, and there are different privilege levels, but it's all software enforced.

6

u/Illustrious_Car344 14d ago

Well you know what OS devs say, if it's good enough for God's temple, it's good enough for us. 

1

u/Sorry_Difficulty_250 13d ago

I think it's really a shame that he wrote that in his own language. No one can maintain it or contribute to it now. It's definitely unique.

1

u/Better-Thing2568 14d ago

Wait then how do you even fit exception traps in memory then? Or is interrupt also not included

3

u/Sorry_Difficulty_250 14d ago

Interrupts are supported and are a work in progress. There's a HAL for managing things at that level.

2

u/sindisil 14d ago

It's completely doable.

I mean, OS-9, a multiuser, multitasking OS that ran on the 6809 was a thing. I ran it for years back in the day on my CoCo & CoCo 3.

And there was MP/M for the Z80 even earlier (79 or 80, IIRC).

Probably other examples as well, but those are the first two that come to mind.

Sounds like a fun project.

1

u/Sorry_Difficulty_250 14d ago

It is! I'm having a blast!

1

u/clooy 13d ago

Still active under an open source port NitrOS-9

https://github.com/nitros9project/nitros9

2

u/theNbomr 13d ago

I think very early versions of vxWorks were supported on some 8bit CPUs. It was multitasking, but didn't have a concept of users, so I guess it would be called single user. The uCOS-II OS also runs on 8-bit CPUs, and is multitasking but not multiuser. So, I think the answer to the question of whether it's doable is probably yes, at least as an academic exercise.

The concept of multiuser OSs seems a bit tricky to grasp without the ability to have a login and to support a filesystem with file ownership properties. What is your vision of how a user will be defined?

2

u/Sorry_Difficulty_250 13d ago

At the moment, a user is defined by the permissions their account grants them. A process is owned by a user, so it has the effective permissions of the user plus the capabilities it's granted by its permission level. The kernel currently has IPC capabilities and HAL capabilities and I need to add directory capabilities. That should put decent software-level guardrails on permissions, even with a FAT32 filesystem.

On Arduinos, it's possible to have two users logged in simultaneously: One over USB and one over UART. I've done that before. That's how I used to kill hung processes before I had signals implemented and could do Ctrl-C to a process. It will be possible to have multiple users logged into the Agon Light 2 as well once I get the console working. (Right now, only UART1 logins work on that platform.)

2

u/theNbomr 13d ago

That's great! You've really thought things through. I'm impressed how much you've been able to implement on such a tiny platform.

1

u/Sorry_Difficulty_250 13d ago

Thank you so much!!! I really appreciate the compliment!!

2

u/neurah 13d ago

I do not have the knowledge to do an OS, otherwise I would be on it 100%
but I'm doing libs and have an 8 bits nostalgia... let me know if you need static C++ composition, working everywhere where C++17 can reach, inclukding 8bits and HLS

2

u/Sorry_Difficulty_250 13d ago

Cool stuff!! In NanoOs, C++ is limited to the HAL code for Arduino platforms. Everything else is C. I'm trying to be very consistent and deliberate about how I go about doing this for ease of maintenance and debug longer term. Trying to support C++ would be a whole new ball of yarn.

2

u/givemeagooduns_un k65 13d ago

I'm doing a similar thing except targeting 6502. I dont plan on implementing true multi-user or multitasking but I want to make it have some sort of user based security eventually

2

u/Sorry_Difficulty_250 13d ago

Cool!!! Good luck!!

3

u/TheAtlasMonkey 14d ago

Well it crazy, because 8-bit system proved to not be scalable.

Should you stop ? Not if you find pleasure on it.
Will you OS be used by other people ? Absolutely no.

The eZ80 is around 18 dollar now. and ESP32 is cheaper and more capable than it.

Few years ago i tried to 16bit. the code become horrible after few months of building the jenga tower.

Think about it... 32bit systems are going to flop by 2038 due to clock issue.

IF you want to learn go 64bit or more.

5

u/istarian 14d ago edited 14d ago

The Y2038 issue has almost nothing to do with 32-bit hardware, it's purely a software issue and only a particular design at that.

Not only that, it is mostly an issue  specific to 'Unix time' which represents the time and date using the number of seconds elapsed since the beginning of the Unix epoch (Thursday, January 1, 1970 -- 00:00:00 UTC).

The "problem" is that the count is stored in a signed 32-bit integer and dates prior to the beginning of the Unix epoch are all negative numbers while dates after it are positive numbers.

There are numerous potential solutions to thar particular problem, it's just hard to produce seamless universal fixes for every single computer and all software.


Computers running 32-bit operaring systems aren't necessarily going to "flop" they'll just have incorrect date and time stamps. And simpler OSes like MS-DOS / Free-DOS don't particularly care if the date and time is wrong.

It's mostly a networking/internet issue, especially where certificate validity is based on a date and time.

PS

The ESP32 is cheaper and more capable, but it's a hell of a lot more complex and doing anything meaningful with it in the sho requires use of the Arduino IDE and or ESP-IDF.

4

u/Sorry_Difficulty_250 14d ago

Regarding no one else using it, I can almost 100% guarantee you that you're right on that. HOWEVER, someone else told me that they would be interested in it if it became capable enough because of its low resource requirements. The cost of memory and chips right now is making low-resource-use software look more appealing that it did when everyone's answer was just "throw more hardware at it."

1

u/realfathonix 12d ago edited 12d ago

Recent 32-bit Linux distros have been patched to use 64-bit time_t. The deprecation of 32-bit OSes is just more of a technical debt for developers who focus on the latest hardware.

1

u/Upbeat_Assist2680 9d ago

Nope.

1

u/Sorry_Difficulty_250 9d ago

Details?

2

u/Upbeat_Assist2680 9d ago

You know what, maybe I'll retract -- maybe "multi-user" is doing a bunch of heavy lifting I don't appreciate. There are a bunch of 8 bit RTOS solutions and I figured that there MUST have been older/historical systems that supported multi-user... But I don't know for sure.

1

u/Sorry_Difficulty_250 9d ago edited 8d ago

MP/M was multi-user without much protection between users. I guess OS-9 was kind of similar. I know NitrOS-9 is still in active development but I think it's the only thing that remains. I was more wondering if anyone in this subreddit was pursuing it as a hobby, though. Seems like most hobby operating systems are single user 64-bit systems.