Share your repls and programming experiences

← Back to all posts
ReplOS - A *REAL* Operating System on repl.it!
h
CSharpIsGud (646)

With pure C and Assembly. This is very quirky, I had to change a lot of stuff moving it onto replit.

Due to the way I did gdt setup and other things I couldn't actually get paging or switching to user mode to work. I still made what was essentially a "user program" but it cant even be loaded on replit!

Im not going to be improving this any more due to its inability to enter user mode. After I failed paging I intended to just use segmentation but without being able to enter user mode users could just change their own segments to anything they wanted. The only way to implement user programs now is some kind of interpreter embedded into the kernel.

Commentshotnewtop
MrEconomical (2238)

incredible job making something as complex as this... definitely deserves more recognition

Highwayman (1396)

@sugarfi not necessarily...

Due to the way I did gdt setup and other things I couldn't actually get paging or switching to user mode to work. I still made what was essentially a "user program" but it cant even be loaded on replit!

sugarfi (587)

@Highwayman good, looks like i still have time to finish my latest os...

Highwayman (1396)

@sugarfi actually it looks like you’ll have forever...

Im not going to be improving this any more due to its inability to enter user mode.

Hope you get yours working I’m sure it’ll be awesome :)

CSharpIsGud (646)

@sugarfi Good luck with user mode, but don't just rush past gdt and forget about it as soon as you get segmentation working. do it right or you wont be able to finish it

sugarfi (587)

@CSharpIsGud I know. I just now got syscalls working, and I am going to set up a shell and then user mode.

CSharpIsGud (646)

@sugarfi user mode first, shells do not run in kernel space.

vve (17)

@sugarfi Me, too. (Mine’s gonna have a command line)

MaxwellUlepic (11)

so sloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooow

DysonBird (2)

Wow that's cool. How did you do it?

CSharpIsGud (646)

@DysonBird I copied a bunch of stuff from my computer to make qemu work

codernoah (0)

OMG. Thank you so much!

AmazingMech2418 (941)

How did you do this? Also, could you actually compile this to make a standalone OS? I've been looking up how to make an OS, but have no idea how. I've been learning the C programming language, but don't know how to use it to make an OS. Also, do you know how to create a desktop OS? Of course, it is best to start with a command line OS, but a desktop OS is best for a final product.

CSharpIsGud (646)

@AmazingMech2418 Yes, it gets compiled to a standalone OS, but to test it without putting it on real hardware you need an emulator like qemu or bochs(preferred). I was going to add a gui but without paging it would not of been very useful, im going to be uploading an improved version of this which can enable paging and enter user mode once I finish it.

Littleosbook covers setting up the build environment and getting it working with C.
But you should also get familiar with assembly as you can't make an operating system in just C alone

AmazingMech2418 (941)

@CSharpIsGud Why can't you use an assembler to convert C to Assembly?

CSharpIsGud (646)

@AmazingMech2418 its an assembler not a C compiler, and C already compiles to machine code

AmazingMech2418 (941)

@CSharpIsGud Well, I know that you can at least compile C into an executable and then disassemble it to Assembly.

TheForArkLD (734)

Sooooooo slowlyyyyyy
But very good

MatthewDoan1 (328)

My god that is cool!!!

RobertFurr (63)

the only thing I know how to do is display help (spoiler alert there is none)

CSharpIsGud (646)

@RobertFurr All it can do is help, clear and exit due to the shortcomings of how I made it, the mistakes I made and trying to make it work on replit

Trent66 (2)

gud day 2 u orll
luv mee
hav a gr8t tiim
wil u b my frend

Trent66 (2)

his repl are sick

CSharpIsGud (646)

@Trent66 That guy has 1 cycle and literally no repls, consider him checked out

[deleted]

If he never posted anything, why does he have a cycle? You start at 0. @CSharpIsGud

CSharpIsGud (646)

@CodeABC123 I said he had no repls, not no posts/comments. He probably got it on a post or comment.

[deleted]

I looked. He doesn’t have anything at all on his account! @CSharpIsGud

CSharpIsGud (646)

@CodeABC123 You can delete your comments and posts.

TW04 (0)

@CSharpIsGud punk amjad will get you
luv harv xx

Trent66 (2)

@CSharpIsGud level 452 and your still woeful

jeeeez punk rocker

CSharpIsGud (646)

@Trent66 Not sure what your problem is.

RayhanADev (1009)

@CSharpIsGud I’m looking through past threads and I see this xDxDxD, imagine being called a punk rocker lol. You’re not wrong though.

Trent66 (2)

could do better however

ThatSmart (88)

boutta make snowflakeOS

Foster_Bryant (100)

I love your posts always.

Zexogon (874)

Yknow what I want to do this in python

JordanDixon1 (374)

@Zexogon Same. Could I help you with it?

CSharpIsGud (646)

@JordanDixon1 Then it wouldn't be a real OS anymore though.

JordanDixon1 (374)

@CSharpIsGud How so? Isn't C a language as well?

CSharpIsGud (646)

@JordanDixon1 an OS cant be done in just any language.

CSharpIsGud (646)

@JordanDixon1 C and C++ compile to assembly, which is why you can use them in OS Dev. There are projects like Cosmos which allow you to use C# and some others which let you use languages that don't normally compile to assembly. but all of those projects you will find they compile the language to assembly first

CSharpIsGud (646)

@JordanDixon1 When a computer is booting it isn't running an OS that can understand executables like a python interpreter right off the bat, and to make an OS in python it would imply that the machine somehow has a hardware python interpreter built in

JordanDixon1 (374)

@CSharpIsGud Ok... Could you maybe teach me some C? It looks similar to Java (except Java sucks, because its so dang complicated)

CSharpIsGud (646)

@JordanDixon1 Java is fairly simple, no pointers, strings. No having to worry about segfaults.
In the case of OS Dev though, a segfault doesn't necessarily exist and you don't get any descriptive messages or even hints if your doing something wrong with memory

JordanDixon1 (374)

@CSharpIsGud I just dont like the fact you have to type SO much for SO little. Like how to print to the terminal is this (not including the main method):

System.out.println("Hello Java!");
Zexogon (874)

@JordanDixon1 I get pinged every time you guys reply to my original comment =w=

DeBeast591 (134)

@JordanDixon1, you have to use a low-level programming language, the are C, Assembly, and probably more. Python is a high-level programming language. If you use the right things then you may be able to, but Python is not structured to be a language to write an OS in.

[deleted]

@DeBeast591 You could use python to write an OS, but only if you make the interpreter in assembly

DeBeast591 (134)

@TaylorLiang, yeah, but Python can't make the best graphical things, but it can make a cool terminal-only OS. (Like my PyDOS)

CSharpIsGud (646)

@DeBeast591 terminal-only console application*

CSharpIsGud (646)

@TaylorLiang Or a compiler to convert py source files to assembly

RobertFurr (63)

@Zexogon Just do:
import os
os.system("install-pkg qemu")
os.system("install-pkg nasm")
os.system("bash Compile.sh")

sugarfi (587)

@CSharpIsGud you could use something like numba or micropython.

CSharpIsGud (646)

@sugarfi Micropython is hardware, and Numba is a JIT compiler. You still need an interpreter, even if you manage to compile python to assembly without the risk of compilation mistakes.
1) It would still be slower than when done in C and Assembly
2) Python has no form of memory management

sugarfi (587)

@CSharpIsGud not really - cpython is a JIT compiler. It compiles to python bytecode.
1) You could write a python VM in asm and it would be very fast.
2) If you wrote a python asm VM, you could simply build in some functions to call asm to do memory management

CSharpIsGud (646)

@sugarfi Im not talking about running speed, im talking about the extra steps it takes to do things C comes built in with.

You could try to add memory management into python, but it isn't built for that and C is, so when something goes wrong you might be questioning whether your doing something wrong or if the memory management itself is buggy

sugarfi (587)

@CSharpIsGud you could also use something like cython, which compiles python to c and allows you to interact with c

CSharpIsGud (646)

@sugarfi Does it add pointers to python

sugarfi (587)

@CSharpIsGud no, but you could: just have a function to do it for you. something like:

void pointer_set(int addr, char val) {
    char* p = (char*) addr;
    *p = val;
}
CSharpIsGud (646)

@sugarfi All those extra steps aren't worth it just to make parts of an OS with forced indentation

sugarfi (587)

@CSharpIsGud I know, I'm just saying you could do it if you wanted to. There was some guy who wrote a whole new JS VM just so he could write an OS in JS.

MatthewDoan1 (328)

@JordanDixon1 Yes Java is verbose but it is also a very simple language. There's so much you can make, and it's one of the biggest languages out there.

[deleted]

dangit beat me to it
also how did you get qemu to work?

CSharpIsGud (646)

@TaylorLiang I copied all the library files it said it was missing from my computer.

SixBeeps (3221)

Ooo, fancy. I like the idea of a windowed terminal.
Though, I wouldn't call this a real OS because that would imply that it is a bootable image on the computer, not just some overlay program.

CSharpIsGud (646)

@SixBeeps This is a real bootable OS, QEMU is an emulator. No implying necessary because it IS a bootable image on a computer.

SixBeeps (3221)

@CSharpIsGud Oh, my bad. I thought QEMU was just some sort of console application. Good work with this!

Foster_Bryant (100)

@CSharpIsGud How would I go about making an OS that has a UI and stuff and not just a kernel?

CSharpIsGud (646)

@Foster_Bryant https://wiki.osdev.org/Drawing_In_Protected_Mode https://wiki.osdev.org/VGA_Resources
But this is something reserved for after you already have stuff like paging, user mode and interrupts.

Foster_Bryant (100)

@CSharpIsGud thx, any sources for were you learned OS development? I have an assembly book but idk where to start on os development

btdmaster (0)

@CSharpIsGud I know I'm 1 month late, but ReplOS2 doesn't seem to work on repl. Is this intended? Will it ever work on repl? I really enjoy tinkering with an OS with no risk attached : P