Which programming languages can be used to make an operating system? [closed] - c

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I was looking around bored for stuff to do, then I stumbled across a guide on making your own simple C & Assembly command line operating system.
Im just wondering, is it just major operating system that use things like C or can an operating system be created in other languages, like android with java.

The lowest level of an operating system is the kernel, it runs on the CPU, so the languages used can't depend on virtual machines or interpreters. Compilers create machine code from the language, and generally package the output in modules with well defined formats. Those modules can be used to create libraries, applications, or an operating system kernel. You need a language that lets you specify the module contents with a fair amount of control, a language like C is fairly easy, a language like C++ makes it much harder, so is not used for the low level of an operating system.
At the lowest level, you need complete control over the output, because it has to match the hardware, not a module format, so you use assembly language for that.
Above the kernel, there's a lot of stuff that uses higher level interfaces, so doesn't need to be a specific binary module, and can use an interpreter or virtual machine. Those levels can be in Java like Android is.
The original MacOS was written in a version of Pascal. Some IBM mainframe OSes used PL/1. Those are no longer popular, but both compiled into modules like C does.

Related

Is Rust entirely independent of the OS and C? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is Rust entirely independent of other languages and OSs like C is, or is it not?
Is Rust entirely independent of the OS and C?
Rust normally relies on the host system to support things like I/O. But it can be independent.
For OS development, you would use no_std: an environment for Rust without host support. This environment includes the core library (a subset of the std library) with no threads, no dynamic memory, no I/O. Implementing those would be part of developing the OS.
In C, there are a few constraints you should respect, such as not using any concurrency, limiting the use of the standard library, and such.
Not exactly. In freestanding C, there are a few standard library facilities that are guaranteed to be available.
Further, whether there may be several threads of execution is implementation-defined. When developing the usual OS with SMP etc, you will need a freestanding implementation with such support.
In Rust however, I have found that you should explicitly specify certain parts of your code to use C's linking implementation rather than Rust's, and taking many more aspects of your programming behaviour into consideration.
Not exactly either. One can program an operating system using only Rust's ABI to interface with assembly files and other bits. The problem is that such ABI is not going to be stable for the foreseeable future. Therefore, if you are willing to follow the changes, you could do it. But it is simpler to use C's instead.
Another possibility to avoid dealing with an ABI is trying to do everything with inline assembly instead.
So my question is, is Rust entirely independent of other languages and OSs like C is, or is it not?
Both can be, for freestanding purposes.

Port C Project from Windows to Linux [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am tasked with porting a massive c project from windows to linux. I have never ported anything over to linux before and am pretty new to linux. The project uses quite a bit of win32 calls. I have looked through some of it and understand what those parts do, however there are many moving parts and i feel it would take too much time to look through it all. What would be the best way to port it over? Is it foolish of me to think I can move the project over to the linux machine and work through the errors one by one?
Thank you in advanced!
Wine is a Windows Emulator for Linux, more exactly a re-implementation of the Windows API and binary interface, mainly for Unix-like OSes. It has also a builtin library named libwine, which is essentially a compatibility layer between the relevant Linux APIs (mainly: libc and X11) and the Win32.
Compiling the project with libwine, you will compile a Linux executable (binary), using the libwine as a shared lib (shared lib == dll). On this way, you can use the Windows API calls in a Linux project.
Your knowledge of the Win32 API helps a lot, most likely the compatibility isn't 100%. Probably you will have to modify the code a little bit (but not too much).

How to create a multistage bootloader with asm and c? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to create a simple 32-bit text-based operating system.
Bootloader :
Firstly I want to create a multistage bootloader.
Stage 1 : Assembly code (NASM-Compiler)
Stage 2 : C (GCC-Compiler)
Kernel:
Then it should load Kernel which should be written in C (GCC-Compiler)
I would also like to know how to properly compile and execute it.
Emulator should be Qemu
A sample 32-bit Operating System that displays "Hello world" would be helpful.
Don't write your own bootloader. Configure and use an existing bootloader, probably GRUB. This would make using your toy OS much easier (both for you and for other users).
Read http://osdev.org/ since they have a lot of resources about OS building on PCs (including a hello world OS).
Read also some good operating system book (e.g. Operating Systems: Three Easy Pieces). You'll find out that there cannot be very simple OSes. See also this answer.
Also, be at least quite fluent with POSIX and with Linux system programming (read Advanced Linux Programming at first).

simple Filesystem [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wanna implement a very, very simple filesystem. I just came across the following resource
and I am wondering if maybe someone tried to do the same and could point me out where
it is best to start for me.
Many thanks
http://web.archive.org/web/20091027130707/http://geocities.com/ravikiran_uvs/articles/rkfs.html
You could look at FUSE - Filesystem in Userspace. It is a system that makes filesystem development much easier than normal filesystem development inside the Kernel. For example the hellofs is a small, extremely limited filesystem in less than 100 lines of C code.
I designed a small series of homeworks for students to development an really simple filesystem using FUSE. Unfortunatelly, the resources for the course are currently only available in German. The filesystem used is based on the book "UNIX Filesystems" by Steve Pate - A pretty good resource on filesystem development.
Try and look at some of the first, non-journaling filesystems on Minix or Linux. You should be able to find something to look at by browsing their legacy code.
Also pick up a book like Modern Operating Systems by Tanenbaum. This contains some low-level theory. If you want to write the driver for Linux then there is a free book on writing drivers/fs modules for Linux
Good Luck
FAT (specifically FAT16) is an extremely simple filesystem -- so simple in fact that building a FAT16 filesystem driver was a single programming lab assignment for a 200-level Computer Science course when I was in school.
If you want to get an idea of the minimum complexity necessary for a real-world filesystem, that's a decent one to look at.

What alternatives to Hans Boehm GC are out there for small devices? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'd like to use a virtual machine like NekoVM into a small device but to build it, it requires Boehm GC, however there is no port of that GC to that small device so I was wondering if there is any alternative to it, something that could be done exclusively with C code?
I'd say your best option would be to port the GC to your platform, for which there are instructions (libgc porting instructions).
Additionally, it should be possible to swap out the GC implementation (NekoVM FAQ), see vm/alloc.c file.
EDIT:
Hopefully useful additional links: (untested)
Smieciuch Garbage Collector
libgcroots (based on libgc 7, abstracts architecture dependant bits)
Squirrel programming language
Perhaps you'd be better off with Lua, which has a very small but powerful virtual machine, has its own garbage collector built in, and runs on any platform that supports ANSI Standard C. With just a little effort you can even build Lua on a machine that lacks standard input and standard output. I have seen Lua running on an embedded device that was a small LCD touch screen with an embedded CPU stuck on the back. Neko is good work, but I think you'll find Lua every bit as satisfying.
I could suggest TinyGC (tinygc.sf.net) - an independent lightweight implementation of the BoehmGC targeting small devices. It is fully API-compatible (even more, binary compatible) with BoehmGC v7+ but only a small subset of the API is implemented (but sufficient for Java/GCJ-like memory management) and there is no automatic threads and static data roots registration. The latter, however, may require some efforts to make NekoVM work with it (i.e., call GC_register_my_thread() and GC_add_roots()).

Resources