简体   繁体   中英

if you create your own OS , do you need to make your own compilers/interpreters to write normal programs?

out of curiosity i am learning OS development and attempting to create an operating system for a raspberry pi, my end goal of this project is to be able to run python programs on it. So if i have a bare bones os kernel, how would i get to the stage of being able to run applications (maybe like a terminal) on it and would i need to write my own python interpreter to run python programs?

You first need to understand what is an operating system.

My recommendation: read a good textbook on operating system then Advanced Linux Programming

Notice that not every OS has files. For example, EROS don't have any. Some toy OSes have toy file systems (à la FAT16 ) without any directories .

You then need to understand what is a compiler , an interpreter , a bytecode , a programming language , an executable , a linker , virtual memory , paging ....

My recommendation: read the Dragon Book then Programming Language Pragmatics then Lisp In Small Pieces

At last, you should be interested by sites, such as OSDEV , giving concrete advice about operating system development. Obviously, an OS is depending on the hardware (perhaps an emulator such as Qemu ) it is running on.

A lot of operating systems, and the Python interpreter, are open source .

My recommendation: study their source code . For Linux kernel , see http://kernelfornewbies.org/ ; look also, for inspiration, into OpenBSD and GNU Hurd and FreeRTOS and Contiki and MirageOS .

So if i have a bare bones os kernel,

You need to document its design and, if it has some, its system calls . Some OSes don't have any syscalls, eg Singularity . Linux has many syscalls(2) .

being able to run applications (maybe like a terminal)

In 2020, real world terminals do not exist any more (except in museums). A famous one was the VT220 . You might want to code a terminal emulator understanding ANSI escape codes . These are complex things. Maybe you want to code something like xterm , but then you'll need some display server (eg driving HDMI ). For Linux, read termios(3) .

Today (in 2020), most keyboards are USB . Your OS need an USB driver, whose details depend upon your actual hardware and USB controller.

Be prepared to the idea of writing (or borrowing, or reusing from GNU/Linux ) millions of lines of C code. Study existing open source code.

budget a decade of full time work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM